6.26. Memory Management [DEPRECATED]
This section describes deprecated memory management functions of the CUDA runtime application programming interface.
Some functions have overloaded C++ API template versions documented separately in the C++ API Routines module.
Functions
- __host__ cudaError_t cudaMemcpyArrayToArray(cudaArray_t dst, size_t wOffsetDst, size_t hOffsetDst, cudaArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t count, enum cudaMemcpyKind kind=cudaMemcpyDeviceToDevice)
Copies data between host and device.
- __host__ cudaError_t cudaMemcpyFromArray(void *dst, cudaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
- __host__ cudaError_t cudaMemcpyFromArrayAsync(void *dst, cudaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream=0)
Copies data between host and device.
- __host__ cudaError_t cudaMemcpyToArray(cudaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
- __host__ cudaError_t cudaMemcpyToArrayAsync(cudaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream=0)
Copies data between host and device.
6.26.1. Functions
-
__host__ cudaError_t cudaMemcpyArrayToArray(cudaArray_t dst, size_t wOffsetDst, size_t hOffsetDst, cudaArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t count, enum cudaMemcpyKind kind = cudaMemcpyDeviceToDevice)
Copies data between host and device.
Copies
countbytes from the CUDA arraysrcstarting athOffsetSrcrows andwOffsetSrcbytes from the upper left corner to the CUDA arraydststarting athOffsetDstrows andwOffsetDstbytes from the upper left corner, wherekindspecifies the direction of the copy, and must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMemcpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that support unified virtual addressing.See also
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFromSymbolAsync, ::cuMemcpyAtoA
Note
Note that this function may also return error codes from previous, asynchronous launches.
Note
Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficientDriver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in such case.
- Parameters
dst – - Destination memory address
wOffsetDst – - Destination starting X offset (columns in bytes)
hOffsetDst – - Destination starting Y offset (rows)
src – - Source memory address
wOffsetSrc – - Source starting X offset (columns in bytes)
hOffsetSrc – - Source starting Y offset (rows)
count – - Size in bytes to copy
kind – - Type of transfer
- Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
-
__host__ cudaError_t cudaMemcpyFromArray(void *dst, cudaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
Copies
countbytes from the CUDA arraysrcstarting athOffsetrows andwOffsetbytes from the upper left corner to the memory area pointed to bydst, wherekindspecifies the direction of the copy, and must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMemcpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that support unified virtual addressing.See also
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFromSymbolAsync, ::cuMemcpyAtoH, ::cuMemcpyAtoD
Note
Note that this function may also return error codes from previous, asynchronous launches.
Note
This function exhibits synchronous behavior for most use cases.
Note
Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficientDriver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in such case.
- Parameters
dst – - Destination memory address
src – - Source memory address
wOffset – - Source starting X offset (columns in bytes)
hOffset – - Source starting Y offset (rows)
count – - Size in bytes to copy
kind – - Type of transfer
- Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
-
__host__ cudaError_t cudaMemcpyFromArrayAsync(void *dst, cudaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream = 0)
Copies data between host and device.
Copies
countbytes from the CUDA arraysrcstarting athOffsetrows andwOffsetbytes from the upper left corner to the memory area pointed to bydst, wherekindspecifies the direction of the copy, and must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMemcpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that support unified virtual addressing.cudaMemcpyFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero
streamargument. Ifkindis cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost andstreamis non-zero, the copy may overlap with operations in other streams.See also
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFromSymbolAsync, ::cuMemcpyAtoHAsync, ::cuMemcpy2DAsync
Note
Note that this function may also return error codes from previous, asynchronous launches.
Note
This function exhibits asynchronous behavior for most use cases.
Note
This function uses standard default stream semantics.
Note
Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficientDriver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in such case.
- Parameters
dst – - Destination memory address
src – - Source memory address
wOffset – - Source starting X offset (columns in bytes)
hOffset – - Source starting Y offset (rows)
count – - Size in bytes to copy
kind – - Type of transfer
stream – - Stream identifier
- Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
-
__host__ cudaError_t cudaMemcpyToArray(cudaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
Copies
countbytes from the memory area pointed to bysrcto the CUDA arraydststarting athOffsetrows andwOffsetbytes from the upper left corner, wherekindspecifies the direction of the copy, and must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMemcpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that support unified virtual addressing.See also
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFromSymbolAsync, ::cuMemcpyHtoA, ::cuMemcpyDtoA
Note
Note that this function may also return error codes from previous, asynchronous launches.
Note
This function exhibits synchronous behavior for most use cases.
Note
Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficientDriver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in such case.
- Parameters
dst – - Destination memory address
wOffset – - Destination starting X offset (columns in bytes)
hOffset – - Destination starting Y offset (rows)
src – - Source memory address
count – - Size in bytes to copy
kind – - Type of transfer
- Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
-
__host__ cudaError_t cudaMemcpyToArrayAsync(cudaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream = 0)
Copies data between host and device.
Copies
countbytes from the memory area pointed to bysrcto the CUDA arraydststarting athOffsetrows andwOffsetbytes from the upper left corner, wherekindspecifies the direction of the copy, and must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMemcpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that support unified virtual addressing.cudaMemcpyToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero
streamargument. Ifkindis cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost andstreamis non-zero, the copy may overlap with operations in other streams.See also
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFromSymbolAsync, ::cuMemcpyHtoAAsync, ::cuMemcpy2DAsync
Note
Note that this function may also return error codes from previous, asynchronous launches.
Note
This function exhibits asynchronous behavior for most use cases.
Note
This function uses standard default stream semantics.
Note
Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficientDriver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in such case.
- Parameters
dst – - Destination memory address
wOffset – - Destination starting X offset (columns in bytes)
hOffset – - Destination starting Y offset (rows)
src – - Source memory address
count – - Size in bytes to copy
kind – - Type of transfer
stream – - Stream identifier
- Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection