Is there a standard/recommended way to use OpenMP features selectively depending on
- capabilities of the compiler
- capabilities of the hardware
What I mean is the following. If I write a code that should be usable on several systems which different compiler versions installed then I would like to use, say
!$omp parallel do simd do i=1:n y(i) = y(i) + a * x(i) end do !$omp end parallel do
if the compiler supports the OpenMP 4.0 standard. However, for older versions the following code needs to be used
!$omp parallel do do i=1:n y(i) = y(i) + a * x(i) !$omp end parallel do
Another example is the use of devices such as Intel MIC. If it is present then I would like to use it. Otherwise, I just run the code on the CPU.
At the moment, I am separating the different capabilities via #ifdef HAS_OPENMPXY at the cost of poor readability of the code. Moreover, this completely contradicts the original idea of OpenMP to have one code that works sequentially and in parallel.