在我的 c++ 项目中到处禁用 OpenMP pragma 语句 [英] Disabling OpenMP pragma statements everywhere in my c++ project

查看:22
本文介绍了在我的 c++ 项目中到处禁用 OpenMP pragma 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 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 for private(i) 语句?

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.

推荐答案

最简单的解决方案是:

  1. 禁用 OpenMP
  2. 链接 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆