views:

60

answers:

1

I am new to cuda and graphics. I had several questions about cuda, hope someone will have proper answers:

These are for driver API:

-- What is the meaning of a cuda context? when i was reading cuda c book (3.1) i've learned that it is analogous to a process in CPU. I don't understand this, the actual host c code becomes a process in cpu and the device code becomes a code which is named a context?

-- It also said that the libraries can create and attach itself to a cuda context. If that is true why don't libraries just always attach themselves to a context and bother creating another context? the same reason why making a new process in CPU? Also what is the meaning of libraries in this case?? host or device libraries? our device code on PTX or cubin?

-- Is cuda based on preemption or scheduling? I mean cuda runs the context until it is done(0 references)?? and then pops the stack or some kind of deque is involved in this case?

These are for Cuda C (runtime API):

-- If we use Cuda C what is the buttom line of the device code? Context? Cubin? ...? or some kind of GPU Assembly somewhat?

Thanks.

A: 

Most of your questions are answered in the CUDA Programming Guide. You can find additional information about the CUDA Toolkit on the developer website http://developer.nvidia.com/object/cuda_3_2_toolkit_rc.html. Especially the Best Pratices Guide and the Reference Manual could prove useful.

You might also want to look at the SDK code examples. There is an example demonstrating the use of contextes in CUDA. More examples are available at the Cuda Zone.

To more or less answer your questions: A context in CUDA is like a process on the host in the sense that all device pointers are only valid in their associated context. Context creation is implicit with the Runtime API. It is built on top of the Driver API. It should not be neccessary to use the Driver API directly. Hope it helps.

LumpN
Thanks for your hints. I already took a look at these references. There were no real answers anywhere so i just asked here. Tanx anyway
Green Code