以很好的方式禁用的OpenMP [英] disable OpenMP in nice way

查看:686
本文介绍了以很好的方式禁用的OpenMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有C ++ code与OpenMP编译进去。我要测试的这款code既为多线程模式(使用OpenMP)和单线程模式(没有OpenMP的)。现在,在模式我需要评论的的#pragma OMP (或至少平行)。

什么是最干净的,或默认,方式启用/禁用OpenMP的?


解决方案

看看能否禁用OpenMP的交换机的编译器手册。对于GCC,OpenMP是默认禁用,并与-fopenmp选项启用。

另一种选择是运行code设置为1 OMP_NUM_THREADS环境变量,虽然这是不完全一样的摆在首位没有OpenMP的编译。

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 switch between modes I need to comment #pragma omp (or at least parallel).

What is the cleanest, or default, way to enable / disable OpenMP?

解决方案

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.

这篇关于以很好的方式禁用的OpenMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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