I want to use a #define flag to control using openmp or not. Since #pragma can't not be inside a #define, so I tried
#define USE_OPENMP // Toggle this on/off
#ifdef USE_OPENMP
#define OMP_FOR(n) __pragma("omp parallel for if(n>10)")
#else
#define OMP_FOR(n) // do nothing
#endif
then in my code I can:
int size_of_the_loop = 11;
OMP_FOR(size_of_the_loop) // activate openmp if(n>10)
for(){
//do stuff
}
I'm not familiar with the #define related stuff, and wondering if it's possible achieve this? Thanks.