CUDA tutorial: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=Introduction=
 
==What is GPU ?==
=What is GPU ?=
GPU, or a graphics processing unit, is a single-chip processor that performs rapid mathematical calculations, primarily for the purpose of rendering images.
GPU, or a graphics processing unit, is a single-chip processor that performs rapid mathematical calculations, primarily for the purpose of rendering images.
However, in the recent years, such capability is being harnessed more broadly to accelerate computational workloads of the cutting-edge scientific research areas.
However, in the recent years, such capability is being harnessed more broadly to accelerate computational workloads of the cutting-edge scientific research areas.
==What is CUDA ?==
=What is CUDA ?=
'''CUDA''' = '''C'''ompute '''U'''nified '''D'''evice '''A'''rchitecture
'''CUDA''' = '''C'''ompute '''U'''nified '''D'''evice '''A'''rchitecture
Provides access to instructions and memory of massively parallel elements in GPU.
Provides access to instructions and memory of massively parallel elements in GPU.
Another definition: CUDA is scalable parallel programming model and software environment for parallel computing.  
Another definition: CUDA is scalable parallel programming model and software environment for parallel computing.  
== Terminology ==
= 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)
=CUDA Programming Model=
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:
* Declare and allocate both the Host and Device memories
* Initialize the Host memory
* Transfer data from Host memory to Device memory
* Execute GPU functions (kernels)
* Transfer data back to the Host memory

Revision as of 19:04, 3 November 2016

What is GPU ?

GPU, or a graphics processing unit, is a single-chip processor that performs rapid mathematical calculations, primarily for the purpose of rendering images. However, in the recent years, such capability is being harnessed more broadly to accelerate computational workloads of the cutting-edge scientific research areas.

What is CUDA ?

CUDA = Compute Unified Device Architecture Provides access to instructions and memory of massively parallel elements in GPU. Another definition: CUDA is scalable parallel programming model and software environment for parallel computing.

Terminology

  • Host – The CPU and its memory (host memory)
  • Device – The GPU and its memory (device memory)

CUDA Programming Model

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:

  • Declare and allocate both the Host and Device memories
  • Initialize the Host memory
  • Transfer data from Host memory to Device memory
  • Execute GPU functions (kernels)
  • Transfer data back to the Host memory