Managing memory
Just as conventional C++ uses standard C functions to handle memory, CUDA also uses its own memory management functions in a similar fashion. CUDA does not use C functions for managing device (GPU) memory variables. It has its own functions for allocating memory for GPU device variables, but they are designed to be used through similar syntax as in C. On the other hand, variables with unified memory allocations through CUDA can be used on both a host and a device. C++ code is referred to as host code, while CUDA code is known as device code. The following functions are very frequently used when developing GPU programs and code execution through device kernels:
|
Conventional C/C++ functions |
CUDA version of the same functions ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access