CUDA tutorial: Difference between revisions

Jump to navigation Jump to search
Line 34: Line 34:
**They perform actual computations
**They perform actual computations
**Each SM has its own control init, registers, execution pipelines, etc
**Each SM has its own control init, registers, execution pipelines, etc
=CUDA Programming Model=
=CUDA programming model=
Before we start talking about programming model, let us go over some useful terminology:
Before we start talking about the programming model, let's go over some useful terminology:
*Host – The CPU and its memory (host memory)
*Host – The CPU and its memory (host memory)
*Device – The GPU and its memory (device memory)
*Device – The GPU and its memory (device memory)


The CUDA programming model is a heterogeneous model in which both the CPU and GPU are used.
The CUDA programming model is a heterogeneous model in which both the CPU and GPU are used.
CUDA code is capable of managing memory of both CPU and GPU as well as executing GPU functions, called kernels. Such kernels are executed by many GPU threads in parallel. Here is the 5-steps recipe of a typical CUDA code:
CUDA code is capable of managing memory of both the CPU and the GPU as well as executing GPU functions, called kernels. Such kernels are executed by many GPU threads in parallel. Here is a five step recipe for a typical CUDA code:
* Declare and allocate both the Host and Device memories
* Declare and allocate both the host and device memories
* Initialize the Host memory
* Initialize the host memory
* Transfer data from Host memory to Device memory
* Transfer data from Host memory to device memory
* Execute GPU functions (kernels)  
* Execute GPU functions (kernels)  
* Transfer data back to the Host memory
* Transfer data back to the host memory
 
=CUDA Execution Model= <!--T:2-->
=CUDA Execution Model= <!--T:2-->
Simple CUDA code executed on GPU is called KERNEL. There are several questions we may ask at this point:
Simple CUDA code executed on GPU is called KERNEL. There are several questions we may ask at this point:
Bureaucrats, cc_docs_admin, cc_staff
2,314

edits

Navigation menu