在我的c ++项目中禁用OpenMP pragma语句 [英] Disabling OpenMP pragma statements everywhere in my c++ project
问题描述
在我的c ++项目中,有几个 #pragma omp parallel for private(i)
语句。当我尝试使用valgrind跟踪我的代码中的错误,OpenMP装饰导致可能丢失的内存泄漏消息。我想完全禁用所有上述 #pragma
语句,以便我可以隔离问题。
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.
但是,我在我的代码中使用 omp_get_wtime()
,我不想禁用这些函数调用。所以我不想完全禁用我的项目中的所有OpenMP功能。
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.
如何简单地关闭所有 #pragma omp parallel
How can I simply turn off all the #pragma omp parallel for private(i)
statements?
我使用Eclipse CDT自动管理makefile,所以我通常在发布模式下编译: make all -C release
。理想情况下,我想要一个解决我的问题,允许我使用一个语句,如 make all -C release -TURN_OFF_PARALLEL
编译,这将导致所有上述 #pragma
语句关闭。
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.
推荐答案
最简单的解决方案是: p>
The simplest solution is to:
- 禁用OpenMP
- 链接OpenMP存根库函数
如果您的OpenMP实现不提供存根函数,您可以从标准。
In case your OpenMP implementation doesn't provide stub functions, you can create your own copying from Appendix B of the standard.
这篇关于在我的c ++项目中禁用OpenMP pragma语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!