在cuda主机代码中使用openMP? [英] Using openMP in the cuda host code?
问题描述
是否可以在CUDA文件中使用openMP编译指示(而不是在内核代码中使用)?
It it possible to use openMP pragmas in the CUDA-Files (not in the kernel code)?
我将结合gpu和cpu计算.但是,如果我将porgram与openmp选项链接(在Linux下),则nvvc编译器将失败,并显示找不到未知选项'openmp'"
I will combine gpu and cpu computation. But nvvc compiler fails with "cannot find Unknown option 'openmp' ", if i am linking the porgram with a openmp option (under linux)
一种解决方法是仅在c/c ++文件中使用openMP语句.
A wayaround is to use openMP-statments only in c/c++ files.
推荐答案
我刚刚找到了这个
http://www.cse.buffalo.edu/系/米勒/课程/CSE710/heavner.pdf
第25页说:
使用gcc:-#include omp.h
With gcc: -#include omp.h
添加 -fopenmp
标志
对于nvcc,这应该是 -Xcompiler -fopenmp
,因为这需要直接传递给gcc-Xcompiler将标志直接传递给主机编译器
With nvcc, this should be -Xcompiler -fopenmp
as this needs to be passed directly to gcc
-Xcompiler passes flags directly to host compiler
在链接阶段添加 -lgomp
标志.
我还没有尝试过...
I haven't tried it yet...
这篇关于在cuda主机代码中使用openMP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!