17
Oct
0

[C++][Omp] OpenMP version _OPENMP directive

Sometime you may want to know what version of openmp you are using at compile time.
This is possible using the _OPENMP directive.

Based on the specification:
http://openmp.org/wp/openmp-specifications/
You can notice that the openmp vers. 3.0 has been released in 2008.05
From this information you can use task or not depending on the version of your openmp.

#include <cstdio>
#include <omp.h>

int main(){
#if _OPENMP >= 200805
    // I use tasks
    printf("_OPENMP >= 200805 (vers = %d)\n",_OPENMP);
#else
    // Tasks do not exist...
    printf("_OPENMP < 200805 (vers = %d)\n",_OPENMP);
#endif

    return 0;
}
Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.

Comments are closed.

Celadon theme by the Themes Boutique