Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using openMP in the cuda host code?

Tags:

c++

cuda

openmp

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.

like image 800
LonliLokli Avatar asked Jul 09 '10 10:07

LonliLokli


People also ask

What is Cuda OpenMP?

OpenMP is mostly famous for shared memory multiprocessing programming. MPI is mostly famous for message-passing multiprocessing programming. CUDA technology is mostly famous for GPGPU computing and parallelising tasks in Nvidia GPUs.

Does OpenMP use GPU?

The OpenMP program (C, C++ or Fortran) with device constructs is fed into the High-Level Optimizer and partitioned into the CPU and GPU parts. The intermediate code is optimized by High-level Optimizer. Note that such optimization benefits both code for CPU as well as GPU.

How do I enable OpenMP?

Enable OpenMPRight-click on your project in Solution Explorer, and select properties. Select C/C++ -> Language, and change OpenMP Support to Yes. Click ok, and make sure your application still compiles and runs.


2 Answers

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

like image 144
Javier Ruiz Avatar answered Sep 28 '22 19:09

Javier Ruiz


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.

like image 29
Hüseyin Yağlı Avatar answered Sep 28 '22 19:09

Hüseyin Yağlı