如何测试C++是否正在使用openmp
How can I test whether C++ is using openmp?
我有一个程序,可以对一堆图像进行独立计算。这似乎是一个使用OpenMP:的好主意
//file: WoodhamData.cpp
#include <omp.h>
...
void WoodhamData::GenerateLightingDirection() {
int imageWidth = (this->normalMap)->width();
int imageHeight = (this->normalMap)->height();
#pragma omp paralell for num_threads(2)
for (int r = 0; r < RadianceMaps.size(); r++) {
if (omp_get_thread_num() == 0){
std::cout<<"threads="<<omp_get_num_threads()<<std::endl;
}
...
}
}
为了使用OpenMP,我将-fopenmp
添加到我的makefile中,因此它输出:
g++ -g -o test.exe src/test.cpp src/WoodhamData.cpp -pthread -L/usr/X11R6/lib -fopenmp --std=c++0x -lm -lX11 -Ilib/eigen/ -Ilib/CImg
然而,我很难过地说,我的程序报告threads=1
(从终端./test.exe ...
运行)
有人知道可能出了什么问题吗?这是我程序中最慢的部分,如果能加快一点就太好了。
您的OpenMP指令是错误的-它是"parallel"而不是"pararell"。
相关文章:
- 在 openmp 中,omp_get_thread_num是否绑定到物理线程?
- 是否可以使用OpenMP并行化一个列表,该列表可以在每次迭代中添加新元素
- OpenMP:决定它们是否是素数
- 结合std::execution和OpenMP是否可取
- 是否可以在并行区域中为共享 2D 数组创建选定元素的线程本地副本?(共享,私有,障碍:OPenMP)
- OpenMP:当我按线程 ID 访问共享变量时,我是否需要一个关键部分
- 使用 OpenMP 并行执行比串行执行 c++ 花费更长的时间,我计算执行时间是否正确?
- 使用 openMP simd 进行以下循环是否安全?
- 是否可以使用G 或Clang -OpenMP获得矢量化报告
- openMP 的 SIMD 结构是否需要特定类型的硬件?
- OpenMP 是否将已完成部分的线程重用到另一个线程?
- 是否保证 OpenMP 矢量化
- 如何在OpenMP并行区域内找到是否
- 是否无法对长双数据类型执行openMP矢量化操作
- 如何测试C++是否正在使用openmp
- OpenMP 是否复制私有对象
- 如何判断 OpenMP 是否正常工作
- 是否有可能通过使用openMP在fstream(文件读取)上获得一些性能提升
- openmp是否可以在同一个cpu(核心)上运行不同的线程?
- OpenMP:是否有一个超时的并行部分