主机软件
CUDA C++ 编程语言CUDA C++ programming language
CUDA C++ 是 CUDA 编程模型 的一种实现,作为 C++ 编程语言的扩展。
为实现 CUDA 编程模型,CUDA C++ 为 C++ 语言添加了若干特性,具体如下:
- 使用
__global__定义 **内核 (Kernel)**。CUDA **内核 (Kernel)** C++ 函数的形式实现,这类函数接收指针作为参数、返回类型为 void,并使用该关键字进行标注。 - 使用
<<<>>>启动 **内核 (Kernel)**。**内核 (Kernel)** 通过三重括号语法从 CPU 主机端执行,该语法用于设置 线程块网格 (Thread Block Grid) 的维度。 - 使用
shared关键字分配 **共享内存 (Shared Memory)**,使用内置函数__syncthreads()实现 屏障同步,以及使用blockDim和threadIdx内置变量进行 线程块 (Thread Block) 和 线程 (Thread) 的索引。
CUDA C++ 程序的编译由主机端 C/C++ 编译器(如 gcc)与 NVIDIA CUDA 编译器驱动 nvcc 共同编译。
英文原文(Modal GPU Glossary)
CUDA C++ is an implementation of the CUDA programming model as an extension of the C++ programming language.
CUDA C++ adds several features to C++ to implement the CUDA programming model, including:
- Kernel definition with
__global__*. CUDA kernels are- implemented as C++ functions that take in pointers and have return type
-
void, annotated with this keyword. - Kernel launches with
<<<>>>. - Kernels are executed from the CPU host
- using a triple bracket syntax that sets the
- thread block grid
- dimensions.
- Shared memory allocation
- with the
sharedkeyword, barrier synchronization with the -
__syncthreads()intrinsic function, and - thread block* and
- thread indexing* with the
-
blockDimandthreadIdxbuilt-in variables.
CUDA C++ programs are compiled by a combination of host C/C++ compiler drivers like gcc and the NVIDIA CUDA Compiler Driver, nvcc.
For information on how to use CUDA C++ on Modal, see this guide.
相关词条
本词条改编自 Modal GPU Glossary(CC BY 4.0)· 中文翻译 miter6/gpu-glossary-zh,MAE 整理排版。