Using openMP in the cuda host code?

17,831

Solution 1

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...

Solution 2

I tried writing the parameter in "Additional Compiler Options" but it didn't work.

What I did for Visual Studio 2010 and CUDA 4.2:

In Project Properties -> Configuration Properties -> CUDA C/C++ -> Command Line -> Additional Options: -Xcompiler "/openmp"

This resulted in two -Xcompiler parameters in the resulting build command but did not cause any problems and worked successfully.

Share:
17,831
LonliLokli
Author by

LonliLokli

Updated on June 09, 2022

Comments

  • LonliLokli
    LonliLokli about 2 years

    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.

  • Tristan
    Tristan over 10 years
    Be careful coping and pasting the arguments. If you look closely the dashes on -Xcompiler -fopenmp are different from command line dashes.
  • Doug Lipinski
    Doug Lipinski about 10 years
    The dashes are fixed now.