Alex Rivera | Logout

Compiling and linking CUDA source files with OpenMP support

Asked 2010-07-09T10:09:32.067
21

It it possible to use OpenMP pragmas in CUDA source files (not in kernel code)?

I will combine GPU and CPU computation. But the nvcc compiler fails with "cannot find Unknown option 'openmp'", when I link the program with an openmp option (under Linux).

A workaround is to use OpenMP pragmas only in C/C++ files.

Edit
Report

1 Answer

22

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 -fompenmp [sic] 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.

Note the misspelling of -fopenmp in the third line.

answered 2010-07-19T15:51:51.510

Your Answer