Bureaucrats, cc_docs_admin, cc_staff
2,314
edits
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 | =CUDA programming model= | ||
Before we start talking about programming model, let | 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 | 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 | * Declare and allocate both the host and device memories | ||
* Initialize the | * Initialize the host memory | ||
* Transfer data from Host memory to | * Transfer data from Host memory to device memory | ||
* Execute GPU functions (kernels) | * Execute GPU functions (kernels) | ||
* Transfer data back to the | * 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: |