[llvm-bugs] [Bug 37536] New: -fopenmp-simd incorrectly defines _OPENMP

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 21 02:08:56 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37536

            Bug ID: 37536
           Summary: -fopenmp-simd incorrectly defines _OPENMP
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: steffen.seckler at tum.de
                CC: llvm-bugs at lists.llvm.org

clang incorrectly defines _OPENMP if -fopenmp-simd is specified. This should
only happen if full openmp support is available:

this shows, whether _OPENMP has been defined, based on different parameters:

> clang -fopenmp-simd -dM -E - < /dev/null | grep -i openmp 
#define _OPENMP 201511
(this should not be defined here)

> clang -fno-openmp -fopenmp-simd -dM -E - < /dev/null | grep -i openmp 
#define _OPENMP 201511
(this should not be defined here)

> clang -fopenmp -dM -E - < /dev/null | grep -i openmp 
#define _OPENMP 201107
(ok, should be defined)

> clang -fopenmp-simd -fopenmp -dM -E - < /dev/null | grep -i openmp 
#define _OPENMP 201107
(ok, should be defined)

The openmp standard provides a reference style to check for openmp support,
that is checking for the definition of _OPENMP, e.g. example from openmp
standard (https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf, page 35):

> #ifdef _OPENMP
> iam = omp_get_thread_num() + &index
> #endif

This simple example code breaks if -fopenmp-simd is defined and -fopenmp is
not.

build environment:
clang version: 6.0.1-svn331815-1~exp1~20180510082943.84


comparison with other compilers:
g++ 7.3.0:
> g++ -fopenmp-simd -dD -E - < /dev/null | grep -i openmp
(empty, _OPENMP not defined)
> g++ -fopenmp-simd -fopenmp -dD -E - < /dev/null | grep -i openmp
#define _OPENMP 201511

icpc 16.0.4:
> icpc -dD -E -qopenmp-simd - </dev/null | grep -i openmp
(empty, _OPENMP not defined)
> icpc -dD -E -qopenmp -qopenmp-simd - </dev/null | grep -i openmp
#define _OPENMP 201307

icpc 17.0.6:
> icpc -dD -E -qopenmp-simd - </dev/null | grep -i openmp
(empty, _OPENMP not defined)
> icpc -dD -E -qopenmp -qopenmp-simd - </dev/null | grep -i openmp
#define _OPENMP 201511



P.S: it also seems, that the defined openmp versions are quite erratic (201511
if openmp has not been defined, but openmp-simd has; 201107 if openmp has ALSO
been defined)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180521/13386fea/attachment-0001.html>


More information about the llvm-bugs mailing list