CUDA学习(2)--编程模型

来源:互联网 发布:人工智能语音识别 编辑:程序博客网 时间:2024/06/06 09:09

Key Abstraction of CUDA

  • Thread Hierarchy –> Divide thread into several blocks
  • Memory Hierarchy –> Local memory of threads, shared memory of blocks and global memory of grid
  • Heterogonous Programming –> Kernel executes on the device and the rest of C code executes on the host

Thread Hierarchy

Divide thread into several blocks. And every block is independent, which means they can both execute parallel or serial.

Thread Hierarchy

Memory Hierarchy

The programming model of CUDA separate the memory of a program into three different part. And They are local memory of threads, shared memory of blocks and global memory of the grid.

Memory Hierarchy

Heterogeneous Programming

Heterogeneous programming of CUDA means the kernels execute on a GPU and the rest of C program executes on a CPU. And data can be transferred between CPU and GPU.

Heterogeneous Programming

CPU(the host) executes the serial code and the GPU executes the parallel kernels.