Just as conventional C++ uses standard C functions to handle memory, HIP also has memory-management functions that it uses in a similar manner. C++ code is referred to as host code, while HIP code is known as device code. The following functions are frequently used with HIP when developing or porting AMD/NVIDIA GPU programs and during code execution through device kernels:
CUDA version |
HIP version of the same functions |
cudaMalloc |
hipMalloc |
cudaMemcpy |
hipMemcpy |
cudaFree |
hipFree |
Similar to CUDA, hipMemcpyHostToDevice and hipMemcpyHostToDevice on HIP correspond to what cudaMemcpyHostToDevice and cudaMemcpyDeviceToHost are meant to do on CUDA.