Skip to main content

cudaMallocArray

Function cudaMallocArray 

Source
pub unsafe extern "C" fn cudaMallocArray(
    array: *mut cudaArray_t,
    desc: *const cudaChannelFormatDesc,
    width: size_t,
    height: size_t,
    flags: c_uint,
) -> cudaError_t
Expand description

Allocate an array on the device.

Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new CUDA array in *array.

The cudaChannelFormatDesc is defined as:

struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};

where cudaChannelFormatKind is one of cudaChannelFormatKind::cudaChannelFormatKindSigned , cudaChannelFormatKind::cudaChannelFormatKindUnsigned , or cudaChannelFormatKind::cudaChannelFormatKindFloat .

The flags parameter enables different options to be specified that affect the allocation, as follows.

  • cudaArrayDefault: This flag’s value is defined to be 0 and provides default array allocation
  • cudaArraySurfaceLoadStore: Allocates an array that can be read from or written to using a surface reference
  • cudaArrayTextureGather: This flag indicates that texture gather operations will be performed on the array.
  • cudaArraySparse: Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling cuMemMapArrayAsync. The physical backing memory must be allocated via cuMemCreate.
  • cudaArrayDeferredMapping: Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling cuMemMapArrayAsync. The physical backing memory must be allocated via cuMemCreate.

width and height must meet certain size requirements. See cudaMalloc3DArray for more details.

Note that this function may also return error codes from previous, asynchronous launches.

Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

§Parameters

  • array: Pointer to allocated array in device memory.
  • desc: Requested channel format.
  • width: Requested array allocation width.
  • height: Requested array allocation height.
  • flags: Requested properties of allocated array.

§Return value

See also: cudaMalloc, cudaMallocPitch, cudaFree, cudaFreeArray, cudaMallocHost (C API), cudaFreeHost, cudaMalloc3D, cudaMalloc3DArray, cudaHostAlloc, cuArrayCreate.