Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nemequ
New Contributor I
170 Views

Macro to indicate OpenMP SIMD support

I'm planning on adding OpenMP SIMD pragmas to a project of mine, but I don't really need the full OpenMP; the -openmp-simd option is perfect for me.

The problem is that _OPENMP is (correctly) only defined for full OpenMP; when only -openmp-simd is used there doesn't seem to be any way to detect that the compiler supports it.  It would be nice if there were a macro (_OPENMP_SIMD seems logical) to tell if omp simd pragmas are supported.  I'd love to be able to do something like

#if (defined(_OPENMP) && (_OPENMP >= 201307L)) || (defined(_OPENMP_SIMD) && (_OPENMP_SIMD >= 201307L))
#pragma omp simd ...
#endif

I'd probably wrap it up in a macro, but that's beside the point.  As it stands the best I can do is pass something like -DOPENMP_SIMD from the build system, which isn't terrible, but it would be nice to have something a bit more standard so the code is easier to copy around across projects.

FWIW, gcc doesn't have anything for -fopenmp-simd either, but I figured I'd start with ICC since that's where the idea for -fopenmp-simd originated.

0 Kudos
5 Replies
Anoop_M_Intel
Employee
170 Views

I have raised a feature request for the same. Will keep you posted when I hear back from the development team on this.

SergeyKostrov
Valued Contributor II
170 Views

It is a known problem with OpenMP runtime libraries and I've been checking a version of OpenMP using _OPENMP macro as well. At the end of my verifications there is a piece of code like that: ... #ifdef _RTPRAGMAOMP_PARALLELFORSIMD #define _RTSIMD simd #else #undef _RTSIMD #endif ... And I do that for every C/C++ compiler used on a project.
nemequ
New Contributor I
170 Views

I filed GCC bug #80502 about this issue.  Assuming they make the requested change, it would be great if ICC and GCC could use the same macro name…

SergeyKostrov
Valued Contributor II
170 Views

>>...It would be nice if there were a macro (_OPENMP_SIMD seems logical... I agree with you but I would proceed with a workaround based on checking a version of _OPENMP macro regardless of a decision from GCC or Intel C++ compiler teams to implement it or not ( it could take months... ). A workaround could be deleted as soon as there is a support for that feature by both teams. But, if it is implemented by just one team then a workaround is still needed to work for a 2nd compiler.
nemequ
New Contributor I
170 Views

Yes, I'm doing that.  in addition to checking _OPENMP_SIMD (and living in hope), I'm checking _OPENMP, and allowing people to define a project-specific macro (SIMDE_ENABLE_OPENMP) to force the issue.  Now that GCC 7 is out I'll try find someone to poke about that patch…

Reply