Ignore OpenMP on machine that does not have it

后端 未结 5 1302
暖寄归人
暖寄归人 2021-02-03 20:21

I have a C++ program using OpenMP, which will run on several machines that may have or not have OpenMP installed.

How could I make my program know if a machine has no O

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-03 21:20

    OpenMP compilation adds the preprocessor definition "_OPENMP", so you can do:

    #if defined(_OPENMP)
       #pragma omp ...
    #endif
    

    For some examples, see http://bisqwit.iki.fi/story/howto/openmp/#Discussion and the code which follows.

提交回复
热议问题