Using openMP in the cuda host code?

LonliLokli picture LonliLokli · Jul 9, 2010 · Viewed 15.7k times · Source

It it possible to use openMP pragmas in the CUDA-Files (not in the kernel code)?

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)

A wayaround is to use openMP-statments only in c/c++ files.

Answer

Javier Ruiz picture Javier Ruiz · Jul 19, 2010

I've just found this

http://www.cse.buffalo.edu/faculty/miller/Courses/CSE710/heavner.pdf

Page 25 says:

With gcc: -#include omp.h

Add the -fopenmp flag

With nvcc, this should be -Xcompiler -fopenmp as this needs to be passed directly to gcc -Xcompiler passes flags directly to host compiler

Add -lgomp flag during the linking stage.

I haven't tried it yet...