2

I am working with cuda and using openMP for parallel threading:

#pragma omp parallel
{
    unsigned int cpu_thread_id = omp_get_thread_num();
    cudaSetDevice(cpu_thread_id);

    if(cpu_thread_id==0) 
    {
        // call kernel function
    }
}

It is always working with cpu_thread_id=0 even I have 4 gpus. So when I change the cpu_thread_id to another number 1,2, and 3 for testing. I got: segmentation fault. with this error, I have no idea why it the problem.

Did you notice any thing?

Thanks in advance

2
  • 1
    Can you edit the question to include some information about how the arguments you are passing in the kernel are being allocated (especially threading)? Also, what CUDA version are you doing this with?
    – talonmies
    Oct 27, 2011 at 20:32
  • Are you sure that all your CUDA GPUs are detected correctly? Try a call to cudaGetDeviceCount and see if it returns the correct number of GPUs.
    – Tudor
    Oct 31, 2011 at 15:10

1 Answer 1

0

I added a mutex in between the threads and it works. I dont know why it is like that...

1
  • You could try to use the Cuda API to determine the last encountered Cuda error and print it.
    – Tudor
    Nov 2, 2011 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.