HIP: Heterogenous-computing Interface for Portability
Typedefs | Functions | Variables
Memory Management

Typedefs

typedef _Float16 __2f16 __attribute__((ext_vector_type(2)))
 Copies the size of symbol symbolName to size. More...
 

Functions

hipError_t hipPointerGetAttributes (hipPointerAttribute_t *attributes, const void *ptr)
 Return attributes for the specified pointer. More...
 
hipError_t hipMalloc (void **ptr, size_t size)
 Allocate memory on the default accelerator. More...
 
hipError_t hipExtMallocWithFlags (void **ptr, size_t sizeBytes, unsigned int flags)
 Allocate memory on the default accelerator. More...
 
hipError_t hipMallocHost (void **ptr, size_t size)
 Allocate pinned host memory [Deprecated]. More...
 
hipError_t hipHostMalloc (void **ptr, size_t size, unsigned int flags)
 Allocate device accessible page locked host memory. More...
 
hipError_t hipMallocManaged (void **devPtr, size_t size, unsigned int flags __dparm(0))
 Allocates memory that will be automatically managed by the Unified Memory system. More...
 
hipError_t hipHostAlloc (void **ptr, size_t size, unsigned int flags)
 Allocate device accessible page locked host memory [Deprecated]. More...
 
hipError_t hipHostGetDevicePointer (void **devPtr, void *hstPtr, unsigned int flags)
 Get Device pointer from Host Pointer allocated through hipHostMalloc. More...
 
hipError_t hipHostGetFlags (unsigned int *flagsPtr, void *hostPtr)
 Return flags associated with host pointer. More...
 
hipError_t hipHostRegister (void *hostPtr, size_t sizeBytes, unsigned int flags)
 Register host memory so it can be accessed from the current device. More...
 
hipError_t hipHostUnregister (void *hostPtr)
 Un-register host pointer. More...
 
hipError_t hipMallocPitch (void **ptr, size_t *pitch, size_t width, size_t height)
 
hipError_t hipFree (void *ptr)
 Free memory allocated by the hcc hip memory allocation API. This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More...
 
hipError_t hipFreeHost (void *ptr)
 Free memory allocated by the hcc hip host memory allocation API. [Deprecated]. More...
 
hipError_t hipHostFree (void *ptr)
 Free memory allocated by the hcc hip host memory allocation API This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More...
 
hipError_t hipMemcpy (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind)
 Copy data from src to dst. More...
 
hipError_t hipMemcpyHtoD (hipDeviceptr_t dst, void *src, size_t sizeBytes)
 Copy data from Host to Device. More...
 
hipError_t hipMemcpyDtoH (void *dst, hipDeviceptr_t src, size_t sizeBytes)
 Copy data from Device to Host. More...
 
hipError_t hipMemcpyDtoD (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes)
 Copy data from Device to Device. More...
 
hipError_t hipMemcpyHtoDAsync (hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream)
 Copy data from Host to Device asynchronously. More...
 
hipError_t hipMemcpyDtoHAsync (void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
 Copy data from Device to Host asynchronously. More...
 
hipError_t hipMemcpyDtoDAsync (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
 Copy data from Device to Device asynchronously. More...
 
 __attribute__ ((visibility("hidden"))) hipError_t hipGetSymbolAddress(void **devPtr
 Copies the memory address of symbol symbolName to devPtr. More...
 
return hip_impl::read_agent_global_from_process & devPtr (const char *) symbolName
 
const void size_t size_t offset __dparm (0)
 
const void size_t size_t offset hipMemcpyKind kind __dparm (hipMemcpyHostToDevice))
 
const void size_t size_t offset hipMemcpyKind kind __dparm (hipMemcpyDeviceToHost))
 
hipError_t hipMemcpyAsync (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream __dparm(0))
 Copy data from src to dst asynchronously. More...
 
hipError_t hipMemset (void *dst, int value, size_t sizeBytes)
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More...
 
hipError_t hipMemsetD8 (hipDeviceptr_t dest, unsigned char value, size_t sizeBytes)
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More...
 
hipError_t hipMemsetD32 (hipDeviceptr_t dest, int value, size_t count)
 Fills the memory area pointed to by dest with the constant integer value for specified number of times. More...
 
hipError_t hipMemsetAsync (void *dst, int value, size_t sizeBytes, hipStream_t stream __dparm(0))
 Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value value. More...
 
hipError_t hipMemsetD32Async (hipDeviceptr_t dst, int value, size_t count, hipStream_t stream __dparm(0))
 Fills the memory area pointed to by dev with the constant integer value for specified number of times. More...
 
hipError_t hipMemset2D (void *dst, size_t pitch, int value, size_t width, size_t height)
 Fills the memory area pointed to by dst with the constant value. More...
 
hipError_t hipMemset2DAsync (void *dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream __dparm(0))
 Fills asynchronously the memory area pointed to by dst with the constant value. More...
 
hipError_t hipMemset3D (hipPitchedPtr pitchedDevPtr, int value, hipExtent extent)
 Fills synchronously the memory area pointed to by pitchedDevPtr with the constant value. More...
 
hipError_t hipMemset3DAsync (hipPitchedPtr pitchedDevPtr, int value, hipExtent extent, hipStream_t stream __dparm(0))
 Fills asynchronously the memory area pointed to by pitchedDevPtr with the constant value. More...
 
hipError_t hipMemGetInfo (size_t *free, size_t *total)
 Query memory info. Return snapshot of free memory, and total allocatable memory on the device. More...
 
hipError_t hipMemPtrGetInfo (void *ptr, size_t *size)
 
hipError_t hipMallocArray (hipArray **array, const hipChannelFormatDesc *desc, size_t width, size_t height __dparm(0), unsigned int flags __dparm(hipArrayDefault))
 Allocate an array on the device. More...
 
hipError_t hipArrayCreate (hipArray **pHandle, const HIP_ARRAY_DESCRIPTOR *pAllocateArray)
 
hipError_t hipArray3DCreate (hipArray **array, const HIP_ARRAY3D_DESCRIPTOR *pAllocateArray)
 
hipError_t hipMalloc3D (hipPitchedPtr *pitchedDevPtr, hipExtent extent)
 
hipError_t hipFreeArray (hipArray *array)
 Frees an array on the device. More...
 
hipError_t hipMalloc3DArray (hipArray **array, const struct hipChannelFormatDesc *desc, struct hipExtent extent, unsigned int flags)
 Allocate an array on the device. More...
 
hipError_t hipMemcpy2D (void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind)
 Copies data between host and device. More...
 
hipError_t hipMemcpyParam2D (const hip_Memcpy2D *pCopy)
 Copies memory for 2D arrays. More...
 
hipError_t hipMemcpy2DAsync (void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0))
 Copies data between host and device. More...
 
hipError_t hipMemcpy2DToArray (hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind)
 Copies data between host and device. More...
 
hipError_t hipMemcpyToArray (hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t count, hipMemcpyKind kind)
 Copies data between host and device. More...
 
hipError_t hipMemcpyFromArray (void *dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset, size_t count, hipMemcpyKind kind)
 Copies data between host and device. More...
 
hipError_t hipMemcpyAtoH (void *dst, hipArray *srcArray, size_t srcOffset, size_t count)
 Copies data between host and device. More...
 
hipError_t hipMemcpyHtoA (hipArray *dstArray, size_t dstOffset, const void *srcHost, size_t count)
 Copies data between host and device. More...
 
hipError_t hipMemcpy3D (const struct hipMemcpy3DParms *p)
 Copies data between host and device. More...
 

Variables

const void * symbolName
 
size_t size = 0
 
void * devPtr = nullptr
 
const void * src
 
const void size_t sizeBytes
 
const void size_t size_t offset
 
const void size_t size_t hipMemcpyKind kind
 

Detailed Description

----------------------------------------------------------------------------------------------—

The following CUDA APIs are not currently supported:

Typedef Documentation

__device__ __attribute__ ( (ext_vector_type(2))  )
inline

Copies the size of symbol symbolName to size.

Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol.

Parameters
[in]symbolName- Symbol on device
[out]size- Pointer to the size of the symbol
Returns
#hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound
See also
hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync

The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.

Parameters
[in]symbolName- Symbol destination on device
[in]src- Data being copy from
[in]sizeBytes- Data size in bytes
[in]offset- Offset from start of symbol in bytes
[in]kind- Type of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync

The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice hipMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before copy is complete. TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.

Parameters
[in]symbolName- Symbol destination on device
[in]src- Data being copy from
[in]sizeBytes- Data size in bytes
[in]offset- Offset from start of symbol in bytes
[in]kind- Type of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync

Function Documentation

__attribute__ ( (visibility("hidden"))  )
inline

Copies the memory address of symbol symbolName to devPtr.

Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol.

Copies the size of symbol symbolName to size.

Parameters
[in]symbolName- Symbol on device
[out]devPtr- Pointer to a pointer to the memory referred to by the symbol
Returns
#hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound
See also
hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync
Parameters
[in]symbolName- Symbol on device
[out]size- Pointer to the size of the symbol
Returns
#hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound
See also
hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync

The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.

Parameters
[in]symbolName- Symbol destination on device
[in]src- Data being copy from
[in]sizeBytes- Data size in bytes
[in]offset- Offset from start of symbol in bytes
[in]kind- Type of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync

The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice hipMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before copy is complete. TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.

Parameters
[in]symbolName- Symbol destination on device
[in]src- Data being copy from
[in]sizeBytes- Data size in bytes
[in]offset- Offset from start of symbol in bytes
[in]kind- Type of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync
hipError_t hipExtMallocWithFlags ( void **  ptr,
size_t  sizeBytes,
unsigned int  flags 
)

Allocate memory on the default accelerator.

Parameters
[out]ptrPointer to the allocated memory
[in]sizeRequested memory size
[in]flagsType of memory allocation

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
#hipSuccess, #hipErrorMemoryAllocation, #hipErrorInvalidValue (bad context, null *ptr)
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc
hipError_t hipFree ( void *  ptr)

Free memory allocated by the hcc hip memory allocation API. This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned.

Parameters
[in]ptrPointer to memory to be freed
Returns
#hipSuccess
#hipErrorInvalidDevicePointer (if pointer is invalid, including host pointers allocated with hipHostMalloc)
See also
hipMalloc, hipMallocPitch, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
hipError_t hipFreeArray ( hipArray array)

Frees an array on the device.

Parameters
[in]arrayPointer to array to free
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError
See also
hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree
hipError_t hipFreeHost ( void *  ptr)

Free memory allocated by the hcc hip host memory allocation API. [Deprecated].

Parameters
[in]ptrPointer to memory to be freed
Returns
#hipSuccess, #hipErrorInvalidValue (if pointer is invalid, including device pointers allocated with hipMalloc)
Deprecated:
use hipHostFree() instead
hipError_t hipHostAlloc ( void **  ptr,
size_t  size,
unsigned int  flags 
)

Allocate device accessible page locked host memory [Deprecated].

Parameters
[out]ptrPointer to the allocated host pinned memory
[in]sizeRequested memory size
[in]flagsType of host memory allocation

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
#hipSuccess, #hipErrorMemoryAllocation
Deprecated:
use hipHostMalloc() instead
hipError_t hipHostFree ( void *  ptr)

Free memory allocated by the hcc hip host memory allocation API This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned.

Parameters
[in]ptrPointer to memory to be freed
Returns
#hipSuccess, #hipErrorInvalidValue (if pointer is invalid, including device pointers allocated with hipMalloc)
See also
hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
hipError_t hipHostGetDevicePointer ( void **  devPtr,
void *  hstPtr,
unsigned int  flags 
)

Get Device pointer from Host Pointer allocated through hipHostMalloc.

Parameters
[out]dstPtrDevice Pointer mapped to passed host pointer
[in]hstPtrHost Pointer allocated through hipHostMalloc
[in]flagsFlags to be passed for extension
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryAllocation
See also
hipSetDeviceFlags, hipHostMalloc
hipError_t hipHostGetFlags ( unsigned int *  flagsPtr,
void *  hostPtr 
)

Return flags associated with host pointer.

Parameters
[out]flagsPtrMemory location to store flags
[in]hostPtrHost Pointer allocated through hipHostMalloc
Returns
#hipSuccess, #hipErrorInvalidValue
See also
hipHostMalloc
hipError_t hipHostMalloc ( void **  ptr,
size_t  size,
unsigned int  flags 
)

Allocate device accessible page locked host memory.

Parameters
[out]ptrPointer to the allocated host pinned memory
[in]sizeRequested memory size
[in]flagsType of host memory allocation

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
#hipSuccess, #hipErrorMemoryAllocation
See also
hipSetDeviceFlags, hipHostFree
hipError_t hipHostRegister ( void *  hostPtr,
size_t  sizeBytes,
unsigned int  flags 
)

Register host memory so it can be accessed from the current device.

Parameters
[out]hostPtrPointer to host memory to be registered.
[in]sizeBytessize of the host memory
[in]flags.See below.

Flags:

After registering the memory, use hipHostGetDevicePointer to obtain the mapped device pointer. On many systems, the mapped device pointer will have a different value than the mapped host pointer. Applications must use the device pointer in device code, and the host pointer in device code.

On some systems, registered memory is pinned. On some systems, registered memory may not be actually be pinned but uses OS or hardware facilities to all GPU access to the host memory.

Developers are strongly encouraged to register memory blocks which are aligned to the host cache-line size. (typically 64-bytes but can be obtains from the CPUID instruction).

If registering non-aligned pointers, the application must take care when register pointers from the same cache line on different devices. HIP's coarse-grained synchronization model does not guarantee correct results if different devices write to different parts of the same cache block - typically one of the writes will "win" and overwrite data from the other registered memory region.

Returns
#hipSuccess, #hipErrorMemoryAllocation
See also
hipHostUnregister, hipHostGetFlags, hipHostGetDevicePointer
hipError_t hipHostUnregister ( void *  hostPtr)

Un-register host pointer.

Parameters
[in]hostPtrHost pointer previously registered with hipHostRegister
Returns
Error code
See also
hipHostRegister
hipError_t hipMalloc ( void **  ptr,
size_t  size 
)

Allocate memory on the default accelerator.

Parameters
[out]ptrPointer to the allocated memory
[in]sizeRequested memory size

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
#hipSuccess, #hipErrorMemoryAllocation, #hipErrorInvalidValue (bad context, null *ptr)
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc
hipError_t hipMalloc3DArray ( hipArray **  array,
const struct hipChannelFormatDesc desc,
struct hipExtent  extent,
unsigned int  flags 
)

Allocate an array on the device.

Parameters
[out]arrayPointer to allocated array in device memory
[in]descRequested channel format
[in]extentRequested array allocation width, height and depth
[in]flagsRequested properties of allocated array
Returns
#hipSuccess, #hipErrorMemoryAllocation
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
hipError_t hipMallocArray ( hipArray **  array,
const hipChannelFormatDesc desc,
size_t  width,
size_t height   __dparm0,
unsigned int flags   __dparmhipArrayDefault 
)

Allocate an array on the device.

Parameters
[out]arrayPointer to allocated array in device memory
[in]descRequested channel format
[in]widthRequested array allocation width
[in]heightRequested array allocation height
[in]flagsRequested properties of allocated array
Returns
#hipSuccess, #hipErrorMemoryAllocation
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
hipError_t hipMallocHost ( void **  ptr,
size_t  size 
)

Allocate pinned host memory [Deprecated].

Parameters
[out]ptrPointer to the allocated host pinned memory
[in]sizeRequested memory size

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
#hipSuccess, #hipErrorMemoryAllocation
Deprecated:
use hipHostMalloc() instead
hipError_t hipMallocManaged ( void **  devPtr,
size_t  size,
unsigned int flags   __dparm
)

Allocates memory that will be automatically managed by the Unified Memory system.

Parameters
[out]ptrPointer to the allocated managed memory
[in]sizeRequested memory size
[in]flagsmust be either hipMemAttachGlobal/hipMemAttachHost
Returns
#hipSuccess, #hipErrorMemoryAllocation
hipError_t hipMallocPitch ( void **  ptr,
size_t *  pitch,
size_t  width,
size_t  height 
)

Allocates at least width (in bytes) * height bytes of linear memory Padding may occur to ensure alighnment requirements are met for the given row The change in width size due to padding will be returned in *pitch. Currently the alignment is set to 128 bytes

Parameters
[out]ptrPointer to the allocated device memory
[out]pitchPitch for allocation (in bytes)
[in]widthRequested pitched allocation width (in bytes)
[in]heightRequested pitched allocation height

If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.

Returns
Error code
See also
hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
hipError_t hipMemcpy ( void *  dst,
const void *  src,
size_t  sizeBytes,
hipMemcpyKind  kind 
)

Copy data from src to dst.

It supports memory from host to device, device to host, device to device and host to host The src and dst must not overlap.

For hipMemcpy, the copy is always performed by the current device (set by hipSetDevice). For multi-gpu or peer-to-peer configurations, it is recommended to set the current device to the device where the src data is physically located. For optimal peer-to-peer copies, the copy device must be able to access the src and dst pointers (by calling hipDeviceEnablePeerAccess with copy agent as the current device and src/dest as the peerDevice argument. if this is not done, the hipMemcpy will still work, but will perform the copy using a staging buffer on the host.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
[in]copyTypeMemory copy type
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknowni
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpy2D ( void *  dst,
size_t  dpitch,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height,
hipMemcpyKind  kind 
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]dpitchPitch of destination memory
[in]srcSource memory address
[in]spitchPitch of source memory
[in]widthWidth of matrix transfer (columns in bytes)
[in]heightHeight of matrix transfer (rows)
[in]kindType of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpy2DAsync ( void *  dst,
size_t  dpitch,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height,
hipMemcpyKind  kind,
hipStream_t stream   __dparm
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]dpitchPitch of destination memory
[in]srcSource memory address
[in]spitchPitch of source memory
[in]widthWidth of matrix transfer (columns in bytes)
[in]heightHeight of matrix transfer (rows)
[in]kindType of transfer
[in]streamStream to use
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpy2DToArray ( hipArray dst,
size_t  wOffset,
size_t  hOffset,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height,
hipMemcpyKind  kind 
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]dpitchPitch of destination memory
[in]srcSource memory address
[in]spitchPitch of source memory
[in]widthWidth of matrix transfer (columns in bytes)
[in]heightHeight of matrix transfer (rows)
[in]kindType of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpy3D ( const struct hipMemcpy3DParms p)

Copies data between host and device.

Parameters
[in]p3D memory copy parameters
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpyAsync ( void *  dst,
const void *  src,
size_t  sizeBytes,
hipMemcpyKind  kind,
hipStream_t stream   __dparm
)

Copy data from src to dst asynchronously.

Warning
If host or dest are not pinned, the memory copy will be performed synchronously. For best performance, use hipHostMalloc to allocate host memory that is transferred asynchronously.
on HCC hipMemcpyAsync does not support overlapped H2D and D2H copies. For hipMemcpy, the copy is always performed by the device associated with the specified stream.

For multi-gpu or peer-to-peer configurations, it is recommended to use a stream which is a attached to the device where the src data is physically located. For optimal peer-to-peer copies, the copy device must be able to access the src and dst pointers (by calling hipDeviceEnablePeerAccess with copy agent as the current device and src/dest as the peerDevice argument. if this is not done, the hipMemcpy will still work, but will perform the copy using a staging buffer on the host.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
[in]accelerator_viewAccelerator view which the copy is being enqueued
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync
hipError_t hipMemcpyAtoH ( void *  dst,
hipArray srcArray,
size_t  srcOffset,
size_t  count 
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]srcArraySource array
[in]srcoffsetOffset in bytes of source array
[in]countSize of memory copy in bytes
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpyDtoD ( hipDeviceptr_t  dst,
hipDeviceptr_t  src,
size_t  sizeBytes 
)

Copy data from Device to Device.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyDtoDAsync ( hipDeviceptr_t  dst,
hipDeviceptr_t  src,
size_t  sizeBytes,
hipStream_t  stream 
)

Copy data from Device to Device asynchronously.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyDtoH ( void *  dst,
hipDeviceptr_t  src,
size_t  sizeBytes 
)

Copy data from Device to Host.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyDtoHAsync ( void *  dst,
hipDeviceptr_t  src,
size_t  sizeBytes,
hipStream_t  stream 
)

Copy data from Device to Host asynchronously.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyFromArray ( void *  dst,
hipArray_const_t  srcArray,
size_t  wOffset,
size_t  hOffset,
size_t  count,
hipMemcpyKind  kind 
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]srcArraySource memory address
[in]woffsetSource starting X offset
[in]hOffsetSource starting Y offset
[in]countSize in bytes to copy
[in]kindType of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpyHtoA ( hipArray dstArray,
size_t  dstOffset,
const void *  srcHost,
size_t  count 
)

Copies data between host and device.

Parameters
[in]dstArrayDestination memory address
[in]dstOffsetOffset in bytes of destination array
[in]srcHostSource host pointer
[in]countSize of memory copy in bytes
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpyHtoD ( hipDeviceptr_t  dst,
void *  src,
size_t  sizeBytes 
)

Copy data from Host to Device.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyHtoDAsync ( hipDeviceptr_t  dst,
void *  src,
size_t  sizeBytes,
hipStream_t  stream 
)

Copy data from Host to Device asynchronously.

Parameters
[out]dstData being copy to
[in]srcData being copy from
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorDeInitialized, #hipErrorNotInitialized, #hipErrorInvalidContext, #hipErrorInvalidValue
See also
hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer
hipError_t hipMemcpyParam2D ( const hip_Memcpy2D pCopy)

Copies memory for 2D arrays.

Parameters
[in]pCopyParameters for the memory copy
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemcpyToArray ( hipArray dst,
size_t  wOffset,
size_t  hOffset,
const void *  src,
size_t  count,
hipMemcpyKind  kind 
)

Copies data between host and device.

Parameters
[in]dstDestination memory address
[in]dpitchPitch of destination memory
[in]srcSource memory address
[in]spitchPitch of source memory
[in]widthWidth of matrix transfer (columns in bytes)
[in]heightHeight of matrix transfer (rows)
[in]kindType of transfer
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
hipError_t hipMemGetInfo ( size_t *  free,
size_t *  total 
)

Query memory info. Return snapshot of free memory, and total allocatable memory on the device.

Returns in *free a snapshot of the current free memory.

Returns
#hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue
Warning
On HCC, the free memory only accounts for memory allocated by this process and may be optimistic.
hipError_t hipMemset ( void *  dst,
int  value,
size_t  sizeBytes 
)

Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value.

Parameters
[out]dstData being filled
[in]constantvalue to be set
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
hipError_t hipMemset2D ( void *  dst,
size_t  pitch,
int  value,
size_t  width,
size_t  height 
)

Fills the memory area pointed to by dst with the constant value.

Parameters
[out]dstPointer to device memory
[in]pitch- data size in bytes
[in]value- constant value to be set
[in]width
[in]height
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemset2DAsync ( void *  dst,
size_t  pitch,
int  value,
size_t  width,
size_t  height,
hipStream_t stream   __dparm
)

Fills asynchronously the memory area pointed to by dst with the constant value.

Parameters
[in]dstPointer to device memory
[in]pitch- data size in bytes
[in]value- constant value to be set
[in]width
[in]height
[in]stream
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemset3D ( hipPitchedPtr  pitchedDevPtr,
int  value,
hipExtent  extent 
)

Fills synchronously the memory area pointed to by pitchedDevPtr with the constant value.

Parameters
[in]pitchedDevPtr
[in]value- constant value to be set
[in]extent
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemset3DAsync ( hipPitchedPtr  pitchedDevPtr,
int  value,
hipExtent  extent,
hipStream_t stream   __dparm
)

Fills asynchronously the memory area pointed to by pitchedDevPtr with the constant value.

Parameters
[in]pitchedDevPtr
[in]value- constant value to be set
[in]extent
[in]stream
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemsetAsync ( void *  dst,
int  value,
size_t  sizeBytes,
hipStream_t stream   __dparm
)

Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value value.

hipMemsetAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams.

Parameters
[out]dstPointer to device memory
[in]value- Value to set for each byte of specified memory
[in]sizeBytes- Size in bytes to set
[in]stream- Stream identifier
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemsetD32 ( hipDeviceptr_t  dest,
int  value,
size_t  count 
)

Fills the memory area pointed to by dest with the constant integer value for specified number of times.

Parameters
[out]dstData being filled
[in]constantvalue to be set
[in]numberof values to be set
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
hipError_t hipMemsetD32Async ( hipDeviceptr_t  dst,
int  value,
size_t  count,
hipStream_t stream   __dparm
)

Fills the memory area pointed to by dev with the constant integer value for specified number of times.

hipMemsetD32Async() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams.

Parameters
[out]dstPointer to device memory
[in]value- Value to set for each byte of specified memory
[in]count- number of values to be set
[in]stream- Stream identifier
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
hipError_t hipMemsetD8 ( hipDeviceptr_t  dest,
unsigned char  value,
size_t  sizeBytes 
)

Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value.

Parameters
[out]dstData ptr to be filled
[in]constantvalue to be set
[in]sizeBytesData size in bytes
Returns
#hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
hipError_t hipPointerGetAttributes ( hipPointerAttribute_t attributes,
const void *  ptr 
)

Return attributes for the specified pointer.

Parameters
[out]attributesfor the specified pointer
[in]pointerto get attributes for
Returns
#hipSuccess, #hipErrorInvalidDevice, #hipErrorInvalidValue
See also
hipGetDeviceCount, hipGetDevice, hipSetDevice, hipChooseDevice

Variable Documentation

const void * symbolName
Initial value:
{
hip_impl::hip_init()