Skip to main content

cudaMalloc

Function cudaMalloc 

Source
pub unsafe extern "C" fn cudaMalloc(
    devPtr: *mut *mut c_void,
    size: size_t,
) -> cudaError_t
Expand description

Allocate memory on the device.

Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. cudaMalloc returns cudaErrorMemoryAllocation in case of failure.

The device version of cudaFree cannot be used with a *devPtr allocated using the host API, and vice versa.

Note:

See also:

cudaMallocPitch, cudaFree, cudaMallocArray, cudaFreeArray, cudaMalloc3D, cudaMalloc3DArray, cudaMallocHost ( C API), cudaFreeHost, cudaHostAlloc, cuMemAlloc.

ยงParameters

  • devPtr: Pointer to allocated device memory.
  • size: Requested allocation size in bytes.