Search code examples
c++macrosopenmppragma

Disabling OpenMP pragma statements everywhere in my c++ project


In my c++ project, there are several #pragma omp parallel for private(i) statements. When I try to track down bugs in my code using valgrind, the OpenMP adornments result in "possibly lost" memory leak messages. I would like to totally disable all of the aforementioned #pragma statements so that I can isolate the problem.

However, I use omp_get_wtime() in my code, and I do not wish to disable these function calls. So I don't want to totally disable all OpenMP functionality in my project.

How can I simply turn off all the #pragma omp parallel for private(i) statements?

I use Eclipse CDT to automatically manage makefiles, and so I normally compile in release mode by: make all -C release. Ideally, I would like a solution to my problem that permits me to compile using a statement such as make all -C release -TURN_OFF_PARALLEL which would result in all the aforementioned #pragma statements being turned off.


Solution

  • The simplest solution is to:

    1. disable OpenMP
    2. link the OpenMP stub library functions

    In case your OpenMP implementation doesn't provide stub functions, you can create your own copying from Appendix B of the standard.