How to disable OpenMP directives in a nice way?

后端 未结 3 691
不思量自难忘°
不思量自难忘° 2020-12-15 06:10

I have C++ code with OpenMP pragmas inside. I want to test this code both for multithread mode (with OpenMP) and in single thread mode (no OpenMP).

For now, to swit

3条回答
  •  盖世英雄少女心
    2020-12-15 06:41

    Look into the compiler manual for the switch that disables OpenMP. For GCC, OpenMP is disabled by default and enabled with the -fopenmp option.

    Another option would be to run the code with the OMP_NUM_THREADS environment variable set to 1, though that is not exactly the same as compiling without OpenMP in the first place.

提交回复
热议问题