Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a CUDA context?

Can anyone please explain or refer me some good source about what is a CUDA context? I searched CUDA developer guide and I was not satisfied with it.

Any explanation or help will be great.

like image 332
Vraj Pandya Avatar asked Apr 06 '17 02:04

Vraj Pandya


People also ask

What is CUDA context?

The context holds all the management data to control and use the device. For instance, it holds the list of allocated memory, the loaded modules that contain device code, the mapping between CPU and GPU memory for zero copy, etc.

How do I create a CUDA context?

The canonical way to force runtime API context establishment is to call cudaFree(0) . If you have multiple devices, call cudaSetDevice() with the ID of the device you want to establish a context on, then cudaFree(0) to establish the context.

What is CUDA used for?

CUDA is a parallel computing platform and programming model for general computing on graphical processing units (GPUs). With CUDA, you can speed up applications by harnessing the power of GPUs.

What is execution context in GPU?

A GPU context is described here. It represents all the state (data, variables, conditions, etc.) that are collectively required and instantiated to perform certain tasks (e.g. CUDA compute, graphics, H. 264 encode, etc).


1 Answers

The cuda API exposes features of a stateful library: two consecutive calls relate one-another. In short, the context is its state.

The runtime API is a wrapper/helper of the driver API. You can see in the driver API that the context is explicitly made available, and you can have a stack of contexts for convenience. There is one specific context which is shared between driver and runtime API (See primary context)).

The context holds all the management data to control and use the device. For instance, it holds the list of allocated memory, the loaded modules that contain device code, the mapping between CPU and GPU memory for zero copy, etc.

Finally, note that this post is more from experience than documentation-proofed.

like image 52
Florent DUGUET Avatar answered Oct 01 '22 23:10

Florent DUGUET