[Openmp-dev] Bug in clang/openmp: max-reduction fails if data type is "long double"

Cownie, James H via Openmp-dev openmp-dev at lists.llvm.org
Tue Mar 15 02:43:16 PDT 2016


This looks like an inconsistency in our knowledge of LLVM/Clang.

Historically LLVM did not support 16 byte floating point, so the OpenMP runtime does not have support for them when compiled with clang (because the necessary routines couldn't be compiled!).

If your code really is using 16 byte floating point numbers, then the tests in the runtime that don't compile those routines need to be enabled.

It'd be worth checking, though, that the "long double" really is 16 bytes, so maybe you could just check sizeof(real_t).

p.s. You don't need to initialize max_val; whatever value you put there will be ignored anyway, since the OpenMP standard says that the per-thread reduction values are initialized with the most negative value of the type.

-- Jim

James Cownie <james.h.cownie at intel.com>
SSG/DPD/TCAR (Technical Computing, Analyzers and Runtimes)
Tel: +44 117 9071438

-----Original Message-----
From: Openmp-dev [mailto:openmp-dev-bounces at lists.llvm.org] On Behalf Of Stefan Illy via Openmp-dev
Sent: Friday, March 11, 2016 7:36 AM
To: openmp-dev at lists.llvm.org
Subject: [Openmp-dev] Bug in clang/openmp: max-reduction fails if data type is "long double"

Hello everybody,

When I compile the simple test program attached below I get the 
following error message:

openmpbug.cc:(.text+0x2de): undefined reference to 
`__sync_val_compare_and_swap_16'
openmpbug.cc:(.text+0x3a7): undefined reference to 
`__sync_val_compare_and_swap_16'
clang-3.8: error: linker command failed with exit code 1 (use -v to see 
invocation)

This is caused by the OMP max-reduction statement. It also fails if I 
switch from "max" to "min".
I use version 3.8 of clang on an Ubuntu 14.04 LTS system. It also fails 
with version 3.9 (trunk, self-compiled).
If I switch the floating point data type (real_t) from "long double" to 
"double" or "float", the code compiles and runs without problems.

I hope this helps to make clang+openmp even better!


Here comes the simple test program:
---------------------------------------SNIP-------------------------------------------
#include <iostream>

using namespace std;

//typedef float real_t;
//typedef double real_t;
typedef long double real_t;

int
main()
{
   real_t maxval = -1.0e-10;
#pragma omp parallel for reduction(max: maxval)
   for (int i = 1; i <= 1000; i++) maxval = max(maxval, real_t(i));
   cout << maxval << endl;
   return 0;
}
------------------------------------SNIP------------------------------------------------

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the Openmp-dev mailing list