Function Type Qualifiers
Function type qualifiers are used in function declarations and definitions. They specify where the functions can be called from and where they can be executed. Host is the CPU side, and device is the GPU side. |
|
Executed on the device. Callable from the device only. |
|
Executed on the device. Callable from the host or from the device for devices of compute capability 3.x or higher. Must have void return type. |
|
Executed on the host. Callable from the host only (equivalent to declaring the function without any qualifiers). |
Built-in Vector Types
Types
Note: |
|
Constructor Function
|
|
Component Access The 1st, 2nd, 3rd, and 4th components are
accessible through the fields |
|
Example
|
Built-in Variables
Inside functions executed on the device (GPU), grid and block dimensions, and block and thread indices can be accessed using built-in variables listed below. |
|
Dimensions of the grid ( |
|
Block index within the grid ( |
|
Dimensions of the block ( |
|
Thread index within the block ( |
|
Warp size in threads ( |
Device Memory Management
Allocating memory
Allocates |
|
Freeing memory
Frees the memory space pointed to by |
|
Transferring data
Copies |
Kernel Launch
A kernel function declared as
|
Notes
- Based on CUDA C Programming Guide and CUDA Runtime API.