1

I have application which is embarrassingly parallel. Is it possible to launch multiple CPU threads so that a thread manages a GPU?If it is possible, what threading library should I use on CPU side? OpenMP?Pthreads?

1 Answer 1

3

It is possible, but since Cuda 4.0 was released, unnecessary. The Cuda API is now thread safe, so you can asynchronously manage multiple devices using a single host thread.

If you really want to use multiple host threads, just about any host library will do. I have successfully used pthreads, boost::thread and Apple's grand central dispatch with Cuda on linux and OS X.

Sign up to request clarification or add additional context in comments.

5 Comments

So is it possible to manage ith CUDA device with ith thread so that ith CPU thread sends ith chunk of my data to ith device?
Yes, nothing special is required. The only thing you need to be careful about is making sure each thread gets a unique GPU. For that, either have a master thread enumerate all the devices and assign and broadcast device IDs to each thread, or use the compute exclusive settings in the TCC/Linux driver and let the driver automagically assign a device to each thread.
can you please elaborate compute exclusive settings in TCC?
you can use the -c option in nvidia-smi to set the GPU to compute exclusive mode, although I seem to remember that was the default anyway. There is/was a TCC driver whitepaper which explains everything about the driver and its settings.
What happens if each host thread does not get a unique GPU? Does it result in crash/undefined behavior?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.