OpenMP with Cuda Documentation

Hey guys,
Was wondering if there’s any documentation for proper openmp usage with cuda. I wish to compute for example:

#pragma omp parallel for
for (int n=0; n<ngpu; n++)
{
cudaSetDevice(n);
CODE
}

CODE

#pragma omp parallel for
for (int n=0; n<ngpu; n++)
{
cudaSetDevice(n);
CODE
}
I’m wondering if this is possible within cuda. I’m not sure exactly how contexts work, but I imagine this could cause problems since thread are created at the start and destroyed at the end of each loop. Can someone advise? :)

You might find interesting the NVIDIA_GPU_Computing_SDK-5.0/0_Simple/cudaOpenMP example. It shows how to use OpenMP API to write an application for multiple GPUs.

Best,
Pablo.

Hey,
Thanks for the reply. I understand #pragma omp parallel works, but am unsure whether omp parallel for would equally work (making it much simpler to code) if I have several #omp parallel sections will they clash??