Memory Management

Memory Management#

HIP Runtime API Reference: Memory Management
Memory Management
Collaboration diagram for Memory Management:

Functions

hipError_t hipPointerGetAttributes (hipPointerAttribute_t *attributes, const void *ptr)
 Return attributes for the specified pointer. More...
 
hipError_t hipPointerGetAttribute (void *data, hipPointer_attribute attribute, hipDeviceptr_t ptr)
 Returns information about the specified pointer.[BETA]. More...
 
hipError_t hipDrvPointerGetAttributes (unsigned int numAttributes, hipPointer_attribute *attributes, void **data, hipDeviceptr_t ptr)
 Returns information about the specified pointer.[BETA]. More...
 
hipError_t hipImportExternalSemaphore (hipExternalSemaphore_t *extSem_out, const hipExternalSemaphoreHandleDesc *semHandleDesc)
 Imports an external semaphore. More...
 
hipError_t hipSignalExternalSemaphoresAsync (const hipExternalSemaphore_t *extSemArray, const hipExternalSemaphoreSignalParams *paramsArray, unsigned int numExtSems, hipStream_t stream)
 Signals a set of external semaphore objects. More...
 
hipError_t hipWaitExternalSemaphoresAsync (const hipExternalSemaphore_t *extSemArray, const hipExternalSemaphoreWaitParams *paramsArray, unsigned int numExtSems, hipStream_t stream)
 Waits on a set of external semaphore objects. More...
 
hipError_t hipDestroyExternalSemaphore (hipExternalSemaphore_t extSem)
 Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits must have completed before the semaphore is destroyed. More...
 
hipError_t hipImportExternalMemory (hipExternalMemory_t *extMem_out, const hipExternalMemoryHandleDesc *memHandleDesc)
 Imports an external memory object. More...
 
hipError_t hipExternalMemoryGetMappedBuffer (void **devPtr, hipExternalMemory_t extMem, const hipExternalMemoryBufferDesc *bufferDesc)
 Maps a buffer onto an imported memory object. More...
 
hipError_t hipDestroyExternalMemory (hipExternalMemory_t extMem)
 Destroys an external memory object. 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 hipMemAllocHost (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 **dev_ptr, size_t size, unsigned int flags __dparm(hipMemAttachGlobal))
 Allocates memory that will be automatically managed by HIP. More...
 
hipError_t hipMemPrefetchAsync (const void *dev_ptr, size_t count, int device, hipStream_t stream __dparm(0))
 Prefetches memory to the specified destination device using HIP. More...
 
hipError_t hipMemAdvise (const void *dev_ptr, size_t count, hipMemoryAdvise advice, int device)
 Advise about the usage of a given memory range to HIP. More...
 
hipError_t hipMemRangeGetAttribute (void *data, size_t data_size, hipMemRangeAttribute attribute, const void *dev_ptr, size_t count)
 Query an attribute of a given memory range in HIP. More...
 
hipError_t hipMemRangeGetAttributes (void **data, size_t *data_sizes, hipMemRangeAttribute *attributes, size_t num_attributes, const void *dev_ptr, size_t count)
 Query attributes of a given memory range in HIP. More...
 
hipError_t hipStreamAttachMemAsync (hipStream_t stream, void *dev_ptr, size_t length __dparm(0), unsigned int flags __dparm(hipMemAttachSingle))
 Attach memory to a stream asynchronously in HIP. 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 hipMemAllocPitch (hipDeviceptr_t *dptr, size_t *pitch, size_t widthInBytes, size_t height, unsigned int elementSizeBytes)
 
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 hipMemcpyWithStream (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream)
 
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...
 
hipError_t hipModuleGetGlobal (hipDeviceptr_t *dptr, size_t *bytes, hipModule_t hmod, const char *name)
 Returns a global pointer from a module. Returns in *dptr and *bytes the pointer and size of the global of name name located in module hmod. If no variable of that name exists, it returns hipErrorNotFound. Both parameters dptr and bytes are optional. If one of them is NULL, it is ignored and hipSuccess is returned. More...
 
hipError_t hipGetSymbolAddress (void **devPtr, const void *symbol)
 Gets device pointer associated with symbol on the device. More...
 
hipError_t hipGetSymbolSize (size_t *size, const void *symbol)
 Gets the size of the given symbol on the device. More...
 
hipError_t hipMemcpyToSymbol (const void *symbol, const void *src, size_t sizeBytes, size_t offset __dparm(0), hipMemcpyKind kind __dparm(hipMemcpyHostToDevice))
 Copies data to the given symbol on the device. Symbol HIP APIs allow a kernel to define a device-side data symbol which can be accessed on the host side. The symbol can be in __constant or device space. Note that the symbol name needs to be encased in the HIP_SYMBOL macro. This also applies to hipMemcpyFromSymbol, hipGetSymbolAddress, and hipGetSymbolSize. For detail usage, see the example at https://github.com/ROCm-Developer-Tools/HIP/blob/rocm-5.0.x/docs/markdown/hip_porting_guide.md. More...
 
hipError_t hipMemcpyToSymbolAsync (const void *symbol, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream __dparm(0))
 Copies data to the given symbol on the device asynchronously. More...
 
hipError_t hipMemcpyFromSymbol (void *dst, const void *symbol, size_t sizeBytes, size_t offset __dparm(0), hipMemcpyKind kind __dparm(hipMemcpyDeviceToHost))
 Copies data from the given symbol on the device. More...
 
hipError_t hipMemcpyFromSymbolAsync (void *dst, const void *symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream __dparm(0))
 Copies data from the given symbol on the device asynchronously. More...
 
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 count)
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More...
 
hipError_t hipMemsetD8Async (hipDeviceptr_t dest, unsigned char value, size_t count, hipStream_t stream __dparm(0))
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More...
 
hipError_t hipMemsetD16 (hipDeviceptr_t dest, unsigned short value, size_t count)
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant short value value. More...
 
hipError_t hipMemsetD16Async (hipDeviceptr_t dest, unsigned short value, size_t count, hipStream_t stream __dparm(0))
 Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant short 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 hipArrayDestroy (hipArray *array)
 
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 hipFreeMipmappedArray (hipMipmappedArray_t mipmappedArray)
 Frees a mipmapped 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 hipMallocMipmappedArray (hipMipmappedArray_t *mipmappedArray, const struct hipChannelFormatDesc *desc, struct hipExtent extent, unsigned int numLevels, unsigned int flags __dparm(0))
 Allocate a mipmapped array on the device. More...
 
hipError_t hipGetMipmappedArrayLevel (hipArray_t *levelArray, hipMipmappedArray_const_t mipmappedArray, unsigned int level)
 Gets a mipmap level of a HIP mipmapped array. 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 hipMemcpyParam2DAsync (const hip_Memcpy2D *pCopy, hipStream_t stream __dparm(0))
 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 hipMemcpy2DToArrayAsync (hipArray *dst, size_t wOffset, size_t hOffset, 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 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 hipMemcpy2DFromArray (void *dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind)
 Copies data between host and device. More...
 
hipError_t hipMemcpy2DFromArrayAsync (void *dst, size_t dpitch, hipArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0))
 Copies data between host and device asynchronously. 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...
 
hipError_t hipMemcpy3DAsync (const struct hipMemcpy3DParms *p, hipStream_t stream __dparm(0))
 Copies data between host and device asynchronously. More...
 
hipError_t hipDrvMemcpy3D (const HIP_MEMCPY3D *pCopy)
 Copies data between host and device. More...
 
hipError_t hipDrvMemcpy3DAsync (const HIP_MEMCPY3D *pCopy, hipStream_t stream)
 Copies data between host and device asynchronously. More...
 

Detailed Description



This section describes the memory management functions of HIP runtime API. The following CUDA APIs are not currently supported:

  • cudaMalloc3D
  • cudaMalloc3DArray
  • TODO - more 2D, 3D, array APIs here.


This section describes the managed memory management functions of HIP runtime API.

Function Documentation

◆ hipArray3DCreate()

hipError_t hipArray3DCreate ( hipArray **  array,
const HIP_ARRAY3D_DESCRIPTOR pAllocateArray 
)

◆ hipArrayCreate()

hipError_t hipArrayCreate ( hipArray **  pHandle,
const HIP_ARRAY_DESCRIPTOR pAllocateArray 
)

◆ hipArrayDestroy()

hipError_t hipArrayDestroy ( hipArray array)

◆ hipDestroyExternalMemory()

hipError_t hipDestroyExternalMemory ( hipExternalMemory_t  extMem)

Destroys an external memory object.

Parameters
[in]extMemExternal memory object to be destroyed
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipDestroyExternalSemaphore()

hipError_t hipDestroyExternalSemaphore ( hipExternalSemaphore_t  extSem)

Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits must have completed before the semaphore is destroyed.

Parameters
[in]extSemhandle to an external memory object
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipDrvMemcpy3D()

hipError_t hipDrvMemcpy3D ( const HIP_MEMCPY3D pCopy)

◆ hipDrvMemcpy3DAsync()

hipError_t hipDrvMemcpy3DAsync ( const HIP_MEMCPY3D pCopy,
hipStream_t  stream 
)

Copies data between host and device asynchronously.

Parameters
[in]pCopy3D memory copy parameters
[in]streamStream to use
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync

◆ hipDrvPointerGetAttributes()

hipError_t hipDrvPointerGetAttributes ( unsigned int  numAttributes,
hipPointer_attribute attributes,
void **  data,
hipDeviceptr_t  ptr 
)

Returns information about the specified pointer.[BETA].

Parameters
[in]numAttributesnumber of attributes to query for
[in]attributesattributes to query for
[in,out]dataa two-dimensional containing pointers to memory locations where the result of each attribute query will be written to
[in]ptrpointer to get attributes for
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue

@beta This API is marked as beta, meaning, while this is feature complete, it is still open to changes and may have outstanding issues.

See also
hipPointerGetAttribute

◆ hipExternalMemoryGetMappedBuffer()

hipError_t hipExternalMemoryGetMappedBuffer ( void **  devPtr,
hipExternalMemory_t  extMem,
const hipExternalMemoryBufferDesc bufferDesc 
)

Maps a buffer onto an imported memory object.

Parameters
[out]devPtrReturned device pointer to buffer
[in]extMemHandle to external memory object
[in]bufferDescBuffer descriptor
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipExtMallocWithFlags()

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, hipErrorOutOfMemory, hipErrorInvalidValue (bad context, null *ptr)
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc

◆ hipFree()

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

◆ hipFreeArray()

hipError_t hipFreeArray ( hipArray array)

Frees an array on the device.

Parameters
[in]arrayPointer to array to free
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
See also
hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree

◆ hipFreeHost()

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

◆ hipFreeMipmappedArray()

hipError_t hipFreeMipmappedArray ( hipMipmappedArray_t  mipmappedArray)

Frees a mipmapped array on the device.

Parameters
[in]mipmappedArray- Pointer to mipmapped array to free
Returns
hipSuccess, hipErrorInvalidValue

◆ hipGetMipmappedArrayLevel()

hipError_t hipGetMipmappedArrayLevel ( hipArray_t *  levelArray,
hipMipmappedArray_const_t  mipmappedArray,
unsigned int  level 
)

Gets a mipmap level of a HIP mipmapped array.

Parameters
[out]levelArray- Returned mipmap level HIP array
[in]mipmappedArray- HIP mipmapped array
[in]level- Mipmap level
Returns
hipSuccess, hipErrorInvalidValue

◆ hipGetSymbolAddress()

hipError_t hipGetSymbolAddress ( void **  devPtr,
const void *  symbol 
)

Gets device pointer associated with symbol on the device.

Parameters
[out]devPtrpointer to the device associated the symbole
[in]symbolpointer to the symbole of the device
Returns
hipSuccess, hipErrorInvalidValue

◆ hipGetSymbolSize()

hipError_t hipGetSymbolSize ( size_t *  size,
const void *  symbol 
)

Gets the size of the given symbol on the device.

Parameters
[in]symbolpointer to the device symbole
[out]sizepointer to the size
Returns
hipSuccess, hipErrorInvalidValue

◆ hipHostAlloc()

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, hipErrorOutOfMemory
Deprecated:
use hipHostMalloc() instead

◆ hipHostFree()

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

◆ hipHostGetDevicePointer()

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, hipErrorOutOfMemory
See also
hipSetDeviceFlags, hipHostMalloc

◆ hipHostGetFlags()

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

◆ 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, hipErrorOutOfMemory
See also
hipSetDeviceFlags, hipHostFree

◆ hipHostRegister()

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, hipErrorOutOfMemory
See also
hipHostUnregister, hipHostGetFlags, hipHostGetDevicePointer

◆ hipHostUnregister()

hipError_t hipHostUnregister ( void *  hostPtr)

Un-register host pointer.

Parameters
[in]hostPtrHost pointer previously registered with hipHostRegister
Returns
Error code
See also
hipHostRegister

◆ hipImportExternalMemory()

hipError_t hipImportExternalMemory ( hipExternalMemory_t extMem_out,
const hipExternalMemoryHandleDesc memHandleDesc 
)

Imports an external memory object.

Parameters
[out]extMem_outReturned handle to an external memory object
[in]memHandleDescMemory import handle descriptor
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipImportExternalSemaphore()

hipError_t hipImportExternalSemaphore ( hipExternalSemaphore_t extSem_out,
const hipExternalSemaphoreHandleDesc semHandleDesc 
)

Imports an external semaphore.

Parameters
[out]extSem_outExternal semaphores to be waited on
[in]semHandleDescSemaphore import handle descriptor
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipMalloc()

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, hipErrorOutOfMemory, hipErrorInvalidValue (bad context, null *ptr)
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc

◆ hipMalloc3D()

hipError_t hipMalloc3D ( hipPitchedPtr pitchedDevPtr,
hipExtent  extent 
)

◆ hipMalloc3DArray()

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, hipErrorOutOfMemory
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree

◆ hipMallocArray()

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, hipErrorOutOfMemory
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree

◆ hipMallocHost()

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, hipErrorOutOfMemory
Deprecated:
use hipHostMalloc() instead

◆ hipMallocManaged()

hipError_t hipMallocManaged ( void **  dev_ptr,
size_t  size,
unsigned int flags   __dparmhipMemAttachGlobal 
)

Allocates memory that will be automatically managed by HIP.

Parameters
[out]dev_ptr- pointer to allocated device memory
[in]size- requested allocation size in bytes
[in]flags- must be either hipMemAttachGlobal or hipMemAttachHost (defaults to hipMemAttachGlobal)
Returns
hipSuccess, hipErrorMemoryAllocation, hipErrorNotSupported, hipErrorInvalidValue

◆ hipMallocMipmappedArray()

hipError_t hipMallocMipmappedArray ( hipMipmappedArray_t *  mipmappedArray,
const struct hipChannelFormatDesc desc,
struct hipExtent  extent,
unsigned int  numLevels,
unsigned int flags   __dparm
)

Allocate a mipmapped array on the device.

Parameters
[out]mipmappedArray- Pointer to allocated mipmapped array in device memory
[in]desc- Requested channel format
[in]extent- Requested allocation size (width field in elements)
[in]numLevels- Number of mipmap levels to allocate
[in]flags- Flags for extensions
Returns
hipSuccess, hipErrorInvalidValue, hipErrorMemoryAllocation

◆ hipMallocPitch()

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

◆ hipMemAdvise()

hipError_t hipMemAdvise ( const void *  dev_ptr,
size_t  count,
hipMemoryAdvise  advice,
int  device 
)

Advise about the usage of a given memory range to HIP.

Parameters
[in]dev_ptrpointer to memory to set the advice for
[in]countsize in bytes of the memory range
[in]adviceadvice to be applied for the specified memory range
[in]devicedevice to apply the advice for
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemAllocHost()

hipError_t hipMemAllocHost ( 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, hipErrorOutOfMemory
Deprecated:
use hipHostMalloc() instead

◆ hipMemAllocPitch()

hipError_t hipMemAllocPitch ( hipDeviceptr_t dptr,
size_t *  pitch,
size_t  widthInBytes,
size_t  height,
unsigned int  elementSizeBytes 
)

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]dptrPointer 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. The intended usage of pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of type T, the address is computed as: T pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column;

Returns
Error code
See also
hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc

◆ hipMemcpy()

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. Calling hipMemcpy with dst and src pointers that do not match the hipMemcpyKind results in undefined behavior.

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

◆ hipMemcpy2D()

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

◆ hipMemcpy2DAsync()

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

◆ hipMemcpy2DFromArray()

hipError_t hipMemcpy2DFromArray ( void *  dst,
size_t  dpitch,
hipArray_const_t  src,
size_t  wOffset,
size_t  hOffset,
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]wOffsetSource starting X offset
[in]hOffsetSource starting Y offset
[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

◆ hipMemcpy2DFromArrayAsync()

hipError_t hipMemcpy2DFromArrayAsync ( void *  dst,
size_t  dpitch,
hipArray_const_t  src,
size_t  wOffset,
size_t  hOffset,
size_t  width,
size_t  height,
hipMemcpyKind  kind,
hipStream_t stream   __dparm
)

Copies data between host and device asynchronously.

Parameters
[in]dstDestination memory address
[in]dpitchPitch of destination memory
[in]srcSource memory address
[in]wOffsetSource starting X offset
[in]hOffsetSource starting Y offset
[in]widthWidth of matrix transfer (columns in bytes)
[in]heightHeight of matrix transfer (rows)
[in]kindType of transfer
[in]streamAccelerator view which the copy is being enqueued
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync

◆ hipMemcpy2DToArray()

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]wOffsetDestination starting X offset
[in]hOffsetDestination starting Y offset
[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

◆ hipMemcpy2DToArrayAsync()

hipError_t hipMemcpy2DToArrayAsync ( hipArray dst,
size_t  wOffset,
size_t  hOffset,
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]wOffsetDestination starting X offset
[in]hOffsetDestination starting Y offset
[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]streamAccelerator view which the copy is being enqueued
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync

◆ hipMemcpy3D()

hipError_t hipMemcpy3D ( const struct hipMemcpy3DParms p)

◆ hipMemcpy3DAsync()

hipError_t hipMemcpy3DAsync ( const struct hipMemcpy3DParms p,
hipStream_t stream   __dparm
)

Copies data between host and device asynchronously.

Parameters
[in]p3D memory copy parameters
[in]streamStream to use
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync

◆ 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

◆ hipMemcpyAtoH()

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

◆ hipMemcpyDtoD()

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

◆ hipMemcpyDtoDAsync()

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

◆ hipMemcpyDtoH()

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

◆ hipMemcpyDtoHAsync()

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

◆ hipMemcpyFromArray()

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

◆ hipMemcpyFromSymbol()

hipError_t hipMemcpyFromSymbol ( void *  dst,
const void *  symbol,
size_t  sizeBytes,
size_t offset   __dparm0,
hipMemcpyKind kind   __dparmhipMemcpyDeviceToHost 
)

Copies data from the given symbol on the device.

Parameters
[out]dptrReturns pointer to destinition memory address
[in]symbolpointer to the symbole address on the device
[in]sizeBytessize in bytes to copy
[in]offsetoffset in bytes from the start of symbole
[in]kindtype of memory transfer
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemcpyFromSymbolAsync()

hipError_t hipMemcpyFromSymbolAsync ( void *  dst,
const void *  symbol,
size_t  sizeBytes,
size_t  offset,
hipMemcpyKind  kind,
hipStream_t stream   __dparm
)

Copies data from the given symbol on the device asynchronously.

Parameters
[out]dptrReturns pointer to destinition memory address
[in]symbolpointer to the symbole address on the device
[in]sizeBytessize in bytes to copy
[in]offsetoffset in bytes from the start of symbole
[in]kindtype of memory transfer
[in]streamstream identifier
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemcpyHtoA()

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

◆ hipMemcpyHtoD()

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

◆ hipMemcpyHtoDAsync()

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

◆ hipMemcpyParam2D()

◆ hipMemcpyParam2DAsync()

hipError_t hipMemcpyParam2DAsync ( const hip_Memcpy2D pCopy,
hipStream_t stream   __dparm
)

◆ hipMemcpyToArray()

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]wOffsetDestination starting X offset
[in]hOffsetDestination starting Y offset
[in]srcSource memory address
[in]countsize in bytes to copy
[in]kindType of transfer
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync

◆ hipMemcpyToSymbol()

hipError_t hipMemcpyToSymbol ( const void *  symbol,
const void *  src,
size_t  sizeBytes,
size_t offset   __dparm0,
hipMemcpyKind kind   __dparmhipMemcpyHostToDevice 
)

Copies data to the given symbol on the device. Symbol HIP APIs allow a kernel to define a device-side data symbol which can be accessed on the host side. The symbol can be in __constant or device space. Note that the symbol name needs to be encased in the HIP_SYMBOL macro. This also applies to hipMemcpyFromSymbol, hipGetSymbolAddress, and hipGetSymbolSize. For detail usage, see the example at https://github.com/ROCm-Developer-Tools/HIP/blob/rocm-5.0.x/docs/markdown/hip_porting_guide.md.

Parameters
[out]symbolpointer to the device symbole
[in]srcpointer to the source address
[in]sizeBytessize in bytes to copy
[in]offsetoffset in bytes from start of symbole
[in]kindtype of memory transfer
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemcpyToSymbolAsync()

hipError_t hipMemcpyToSymbolAsync ( const void *  symbol,
const void *  src,
size_t  sizeBytes,
size_t  offset,
hipMemcpyKind  kind,
hipStream_t stream   __dparm
)

Copies data to the given symbol on the device asynchronously.

Parameters
[out]symbolpointer to the device symbole
[in]srcpointer to the source address
[in]sizeBytessize in bytes to copy
[in]offsetoffset in bytes from start of symbole
[in]kindtype of memory transfer
[in]streamstream identifier
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemcpyWithStream()

hipError_t hipMemcpyWithStream ( void *  dst,
const void *  src,
size_t  sizeBytes,
hipMemcpyKind  kind,
hipStream_t  stream 
)

◆ hipMemGetInfo()

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.

◆ hipMemPrefetchAsync()

hipError_t hipMemPrefetchAsync ( const void *  dev_ptr,
size_t  count,
int  device,
hipStream_t stream   __dparm
)

Prefetches memory to the specified destination device using HIP.

Parameters
[in]dev_ptrpointer to be prefetched
[in]countsize in bytes for prefetching
[in]devicedestination device to prefetch to
[in]streamstream to enqueue prefetch operation
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemPtrGetInfo()

hipError_t hipMemPtrGetInfo ( void *  ptr,
size_t *  size 
)

◆ hipMemRangeGetAttribute()

hipError_t hipMemRangeGetAttribute ( void *  data,
size_t  data_size,
hipMemRangeAttribute  attribute,
const void *  dev_ptr,
size_t  count 
)

Query an attribute of a given memory range in HIP.

Parameters
[in,out]dataa pointer to a memory location where the result of each attribute query will be written to
[in]data_sizethe size of data
[in]attributethe attribute to query
[in]dev_ptrstart of the range to query
[in]countsize of the range to query
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemRangeGetAttributes()

hipError_t hipMemRangeGetAttributes ( void **  data,
size_t *  data_sizes,
hipMemRangeAttribute attributes,
size_t  num_attributes,
const void *  dev_ptr,
size_t  count 
)

Query attributes of a given memory range in HIP.

Parameters
[in,out]dataa two-dimensional array containing pointers to memory locations where the result of each attribute query will be written to
[in]data_sizesan array, containing the sizes of each result
[in]attributesthe attribute to query
[in]num_attributesan array of attributes to query (numAttributes and the number of attributes in this array should match)
[in]dev_ptrstart of the range to query
[in]countsize of the range to query
Returns
hipSuccess, hipErrorInvalidValue

◆ hipMemset()

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

◆ hipMemset2D()

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

◆ hipMemset2DAsync()

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

◆ hipMemset3D()

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

◆ hipMemset3DAsync()

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

◆ hipMemsetAsync()

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

◆ hipMemsetD16()

hipError_t hipMemsetD16 ( hipDeviceptr_t  dest,
unsigned short  value,
size_t  count 
)

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

Parameters
[out]dstData ptr to be filled
[in]constantvalue to be set
[in]numberof values to be set
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized

◆ hipMemsetD16Async()

hipError_t hipMemsetD16Async ( hipDeviceptr_t  dest,
unsigned short  value,
size_t  count,
hipStream_t stream   __dparm
)

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

hipMemsetD16Async() 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]dstData ptr to be filled
[in]constantvalue to be set
[in]numberof values to be set
[in]stream- Stream identifier
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized

◆ hipMemsetD32()

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

◆ hipMemsetD32Async()

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

◆ hipMemsetD8()

hipError_t hipMemsetD8 ( hipDeviceptr_t  dest,
unsigned char  value,
size_t  count 
)

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]numberof values to be set
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized

◆ hipMemsetD8Async()

hipError_t hipMemsetD8Async ( hipDeviceptr_t  dest,
unsigned char  value,
size_t  count,
hipStream_t stream   __dparm
)

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

hipMemsetD8Async() 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]dstData ptr to be filled
[in]constantvalue to be set
[in]numberof values to be set
[in]stream- Stream identifier
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized

◆ hipModuleGetGlobal()

hipError_t hipModuleGetGlobal ( hipDeviceptr_t dptr,
size_t *  bytes,
hipModule_t  hmod,
const char *  name 
)

Returns a global pointer from a module. Returns in *dptr and *bytes the pointer and size of the global of name name located in module hmod. If no variable of that name exists, it returns hipErrorNotFound. Both parameters dptr and bytes are optional. If one of them is NULL, it is ignored and hipSuccess is returned.

Parameters
[out]dptrReturns global device pointer
[out]bytesReturns global size in bytes
[in]hmodModule to retrieve global from
[in]nameName of global to retrieve
Returns
hipSuccess, hipErrorInvalidValue, hipErrorNotFound, hipErrorInvalidContext

◆ hipPointerGetAttribute()

hipError_t hipPointerGetAttribute ( void *  data,
hipPointer_attribute  attribute,
hipDeviceptr_t  ptr 
)

Returns information about the specified pointer.[BETA].

Parameters
[in,out]datareturned pointer attribute value
[in]atributeattribute to query for
[in]ptrpointer to get attributes for
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue

@beta This API is marked as beta, meaning, while this is feature complete, it is still open to changes and may have outstanding issues.

See also
hipPointerGetAttributes

◆ hipPointerGetAttributes()

hipError_t hipPointerGetAttributes ( hipPointerAttribute_t attributes,
const void *  ptr 
)

Return attributes for the specified pointer.

Parameters
[out]attributesattributes for the specified pointer
[in]ptrpointer to get attributes for
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also
hipPointerGetAttribute

◆ hipSignalExternalSemaphoresAsync()

hipError_t hipSignalExternalSemaphoresAsync ( const hipExternalSemaphore_t extSemArray,
const hipExternalSemaphoreSignalParams paramsArray,
unsigned int  numExtSems,
hipStream_t  stream 
)

Signals a set of external semaphore objects.

Parameters
[in]extSem_outExternal semaphores to be waited on
[in]paramsArrayArray of semaphore parameters
[in]numExtSemsNumber of semaphores to wait on
[in]streamStream to enqueue the wait operations in
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also

◆ hipStreamAttachMemAsync()

hipError_t hipStreamAttachMemAsync ( hipStream_t  stream,
void *  dev_ptr,
size_t length   __dparm0,
unsigned int flags   __dparmhipMemAttachSingle 
)

Attach memory to a stream asynchronously in HIP.

Parameters
[in]stream- stream in which to enqueue the attach operation
[in]dev_ptr- pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory)
[in]length- length of memory (defaults to zero)
[in]flags- must be one of hipMemAttachGlobal, hipMemAttachHost or hipMemAttachSingle (defaults to hipMemAttachSingle)
Returns
hipSuccess, hipErrorInvalidValue

◆ hipWaitExternalSemaphoresAsync()

hipError_t hipWaitExternalSemaphoresAsync ( const hipExternalSemaphore_t extSemArray,
const hipExternalSemaphoreWaitParams paramsArray,
unsigned int  numExtSems,
hipStream_t  stream 
)

Waits on a set of external semaphore objects.

Parameters
[in]extSem_outExternal semaphores to be waited on
[in]paramsArrayArray of semaphore parameters
[in]numExtSemsNumber of semaphores to wait on
[in]streamStream to enqueue the wait operations in
Returns
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
See also