Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Macro to indicate OpenMP SIMD support

nemequ
New Contributor I
780 Views

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
780 Views

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

0 Kudos
SergeyKostrov
Valued Contributor II
780 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.
0 Kudos
nemequ
New Contributor I
780 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…

0 Kudos
SergeyKostrov
Valued Contributor II
780 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.
0 Kudos
nemequ
New Contributor I
780 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…

0 Kudos
Reply