tags: deep learning, cuda programming, programming

cudaMalloc() is used to allocate memory on the global memory on the device memory. The first parameter is a generic pointer to the pointer that will point to the address of allocated data on the GPU.

It is casted to void ** to make it able to change the contents of the original pointer which is in the host, if we just passes the pointer, it will be like we passed the pointer by value, it will not change it’s value.

The return type of cudaMalloc is cudaError_t, it an error code number type, we can then pull the error string using cudaGetErrorString(cudaError_t err).

References

  1. Parallel programming and GPU programming