Memory Management#
Modules | |
External Resource Interoperability | |
Memory Management [Deprecated] | |
Managed Memory | |
Stream Ordered Memory Allocator | |
Functions | |
hipError_t | hipPointerSetAttribute (const void *value, hipPointer_attribute attribute, hipDeviceptr_t ptr) |
Sets information on the specified pointer.[BETA]. | |
hipError_t | hipPointerGetAttributes (hipPointerAttribute_t *attributes, const void *ptr) |
Returns attributes for the specified pointer. | |
hipError_t | hipPointerGetAttribute (void *data, hipPointer_attribute attribute, hipDeviceptr_t ptr) |
Returns information about the specified pointer.[BETA]. | |
hipError_t | hipDrvPointerGetAttributes (unsigned int numAttributes, hipPointer_attribute *attributes, void **data, hipDeviceptr_t ptr) |
Returns information about the specified pointer.[BETA]. | |
hipError_t | hipMalloc (void **ptr, size_t size) |
Allocate memory on the default accelerator. | |
hipError_t | hipExtMallocWithFlags (void **ptr, size_t sizeBytes, unsigned int flags) |
Allocate memory on the default accelerator. | |
hipError_t | hipHostMalloc (void **ptr, size_t size, unsigned int flags) |
Allocates device accessible page locked (pinned) host memory. | |
hipError_t | hipHostAlloc (void **ptr, size_t size, unsigned int flags) |
Allocate device accessible page locked host memory. | |
hipError_t | hipHostGetDevicePointer (void **devPtr, void *hstPtr, unsigned int flags) |
Get Device pointer from Host Pointer allocated through hipHostMalloc. | |
hipError_t | hipHostGetFlags (unsigned int *flagsPtr, void *hostPtr) |
Return flags associated with host pointer. | |
hipError_t | hipHostRegister (void *hostPtr, size_t sizeBytes, unsigned int flags) |
Register host memory so it can be accessed from the current device. | |
hipError_t | hipHostUnregister (void *hostPtr) |
Un-register host pointer. | |
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. | |
hipError_t | hipMemcpy (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind) |
Copy data from src to dst. | |
hipError_t | hipMemcpyWithStream (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) |
Memory copy on the stream. It allows single or multiple devices to do memory copy on single or multiple streams. | |
hipError_t | hipMemcpyHtoD (hipDeviceptr_t dst, void *src, size_t sizeBytes) |
Copy data from Host to Device. | |
hipError_t | hipMemcpyDtoH (void *dst, hipDeviceptr_t src, size_t sizeBytes) |
Copy data from Device to Host. | |
hipError_t | hipMemcpyDtoD (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) |
Copy data from Device to Device. | |
hipError_t | hipMemcpyAtoD (hipDeviceptr_t dstDevice, hipArray_t srcArray, size_t srcOffset, size_t ByteCount) |
Copies from one 1D array to device memory. | |
hipError_t | hipMemcpyDtoA (hipArray_t dstArray, size_t dstOffset, hipDeviceptr_t srcDevice, size_t ByteCount) |
Copies from device memory to a 1D array. | |
hipError_t | hipMemcpyAtoA (hipArray_t dstArray, size_t dstOffset, hipArray_t srcArray, size_t srcOffset, size_t ByteCount) |
Copies from one 1D array to another. | |
hipError_t | hipMemcpyHtoDAsync (hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream) |
Copy data from Host to Device asynchronously. | |
hipError_t | hipMemcpyDtoHAsync (void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) |
Copy data from Device to Host asynchronously. | |
hipError_t | hipMemcpyDtoDAsync (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) |
Copy data from Device to Device asynchronously. | |
hipError_t | hipMemcpyAtoHAsync (void *dstHost, hipArray_t srcArray, size_t srcOffset, size_t ByteCount, hipStream_t stream) |
Copies from one 1D array to host memory. | |
hipError_t | hipMemcpyHtoAAsync (hipArray_t dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount, hipStream_t stream) |
Copies from host memory to a 1D array. | |
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. | |
hipError_t | hipGetSymbolAddress (void **devPtr, const void *symbol) |
Gets device pointer associated with symbol on the device. | |
hipError_t | hipGetSymbolSize (size_t *size, const void *symbol) |
Gets the size of the given symbol on the device. | |
hipError_t | hipGetProcAddress (const char *symbol, void **pfn, int hipVersion, uint64_t flags, hipDriverProcAddressQueryResult *symbolStatus) |
Gets the pointer of requested HIP driver function. | |
hipError_t | hipMemcpyToSymbol (const void *symbol, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind) |
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 detailed usage, see the memcpyToSymbol example in the HIP Porting Guide. | |
hipError_t | hipMemcpyToSymbolAsync (const void *symbol, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) |
Copies data to the given symbol on the device asynchronously. | |
hipError_t | hipMemcpyFromSymbol (void *dst, const void *symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind) |
Copies data from the given symbol on the device. | |
hipError_t | hipMemcpyFromSymbolAsync (void *dst, const void *symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) |
Copies data from the given symbol on the device asynchronously. | |
hipError_t | hipMemcpyAsync (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) |
Copy data from src to dst asynchronously. | |
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. | |
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. | |
hipError_t | hipMemsetD8Async (hipDeviceptr_t dest, unsigned char value, size_t count, hipStream_t stream) |
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. | |
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. | |
hipError_t | hipMemsetD16Async (hipDeviceptr_t dest, unsigned short value, size_t count, hipStream_t stream) |
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant short value value. | |
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. | |
hipError_t | hipMemsetAsync (void *dst, int value, size_t sizeBytes, hipStream_t stream) |
Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value value. | |
hipError_t | hipMemsetD32Async (hipDeviceptr_t dst, int value, size_t count, hipStream_t stream) |
Fills the memory area pointed to by dev with the constant integer value for specified number of times. | |
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. | |
hipError_t | hipMemset2DAsync (void *dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream) |
Fills asynchronously the memory area pointed to by dst with the constant value. | |
hipError_t | hipMemset3D (hipPitchedPtr pitchedDevPtr, int value, hipExtent extent) |
Fills synchronously the memory area pointed to by pitchedDevPtr with the constant value. | |
hipError_t | hipMemset3DAsync (hipPitchedPtr pitchedDevPtr, int value, hipExtent extent, hipStream_t stream) |
Fills asynchronously the memory area pointed to by pitchedDevPtr with the constant value. | |
hipError_t | hipMemGetInfo (size_t *free, size_t *total) |
Query memory info. | |
hipError_t | hipMemPtrGetInfo (void *ptr, size_t *size) |
Get allocated memory size via memory pointer. | |
hipError_t | hipMallocArray (hipArray_t *array, const hipChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags) |
Allocate an array on the device. | |
hipError_t | hipArrayCreate (hipArray_t *pHandle, const HIP_ARRAY_DESCRIPTOR *pAllocateArray) |
Create an array memory pointer on the device. | |
hipError_t | hipArrayDestroy (hipArray_t array) |
Destroy an array memory pointer on the device. | |
hipError_t | hipArray3DCreate (hipArray_t *array, const HIP_ARRAY3D_DESCRIPTOR *pAllocateArray) |
Create a 3D array memory pointer on the device. | |
hipError_t | hipMalloc3D (hipPitchedPtr *pitchedDevPtr, hipExtent extent) |
Create a 3D memory pointer on the device. | |
hipError_t | hipFreeArray (hipArray_t array) |
Frees an array on the device. | |
hipError_t | hipMalloc3DArray (hipArray_t *array, const struct hipChannelFormatDesc *desc, struct hipExtent extent, unsigned int flags) |
Allocate an array on the device. | |
hipError_t | hipArrayGetInfo (hipChannelFormatDesc *desc, hipExtent *extent, unsigned int *flags, hipArray_t array) |
Gets info about the specified array. | |
hipError_t | hipArrayGetDescriptor (HIP_ARRAY_DESCRIPTOR *pArrayDescriptor, hipArray_t array) |
Gets a 1D or 2D array descriptor. | |
hipError_t | hipArray3DGetDescriptor (HIP_ARRAY3D_DESCRIPTOR *pArrayDescriptor, hipArray_t array) |
Gets a 3D array descriptor. | |
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. | |
hipError_t | hipMemcpyParam2D (const hip_Memcpy2D *pCopy) |
Copies memory for 2D arrays. | |
hipError_t | hipMemcpyParam2DAsync (const hip_Memcpy2D *pCopy, hipStream_t stream) |
Copies memory for 2D arrays. | |
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) |
Copies data between host and device. | |
hipError_t | hipMemcpy2DToArray (hipArray_t 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. | |
hipError_t | hipMemcpy2DToArrayAsync (hipArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) |
Copies data between host and device. | |
hipError_t | hipMemcpy2DArrayToArray (hipArray_t dst, size_t wOffsetDst, size_t hOffsetDst, hipArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, hipMemcpyKind kind) |
Copies data between host and device. | |
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. | |
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) |
Copies data between host and device asynchronously. | |
hipError_t | hipMemcpyAtoH (void *dst, hipArray_t srcArray, size_t srcOffset, size_t count) |
Copies data between host and device. | |
hipError_t | hipMemcpyHtoA (hipArray_t dstArray, size_t dstOffset, const void *srcHost, size_t count) |
Copies data between host and device. | |
hipError_t | hipMemcpy3D (const struct hipMemcpy3DParms *p) |
Copies data between host and device. | |
hipError_t | hipMemcpy3DAsync (const struct hipMemcpy3DParms *p, hipStream_t stream) |
Copies data between host and device asynchronously. | |
hipError_t | hipDrvMemcpy3D (const HIP_MEMCPY3D *pCopy) |
Copies data between host and device. | |
hipError_t | hipDrvMemcpy3DAsync (const HIP_MEMCPY3D *pCopy, hipStream_t stream) |
Copies data between host and device asynchronously. | |
template<typename T > | |
hipError_t | hipGetSymbolAddress (void **devPtr, const T &symbol) |
Gets the address of a symbol. | |
template<typename T > | |
hipError_t | hipGetSymbolSize (size_t *size, const T &symbol) |
Gets the size of a symbol. | |
template<typename T > | |
hipError_t | hipMemcpyToSymbol (const T &symbol, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind) |
Copies data to the given symbol on the device. | |
template<typename T > | |
hipError_t | hipMemcpyToSymbolAsync (const T &symbol, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) |
Copies data to the given symbol on the device asynchronously on the stream. | |
template<typename T > | |
hipError_t | hipMemcpyFromSymbol (void *dst, const T &symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind) |
Copies data from the given symbol on the device. | |
template<typename T > | |
hipError_t | hipMemcpyFromSymbolAsync (void *dst, const T &symbol, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) |
Copies data from the given symbol on the device asynchronously on the stream. | |
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.
Function Documentation
◆ hipArray3DCreate()
hipError_t hipArray3DCreate | ( | hipArray_t * | array, |
const HIP_ARRAY3D_DESCRIPTOR * | pAllocateArray | ||
) |
Create a 3D array memory pointer on the device.
- Parameters
-
[out] array Pointer to the 3D array memory [in] pAllocateArray Requested array desciptor
- See also
- hipMallocArray, hipArrayDestroy, hipFreeArray
◆ hipArray3DGetDescriptor()
hipError_t hipArray3DGetDescriptor | ( | HIP_ARRAY3D_DESCRIPTOR * | pArrayDescriptor, |
hipArray_t | array | ||
) |
Gets a 3D array descriptor.
- Parameters
-
[out] pArrayDescriptor - Returned 3D array descriptor [in] array - 3D array to get descriptor of
- Returns
- hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue hipErrorInvalidHandle, hipErrorContextIsDestroyed
- See also
- hipArray3DCreate, hipArrayCreate, hipArrayDestroy, hipArrayGetDescriptor, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpy3D, hipMemcpy3DAsync, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoD, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer, hipMemsetD8, hipMemsetD16, hipMemsetD32, hipArrayGetInfo
◆ hipArrayCreate()
hipError_t hipArrayCreate | ( | hipArray_t * | pHandle, |
const HIP_ARRAY_DESCRIPTOR * | pAllocateArray | ||
) |
Create an array memory pointer on the device.
- Parameters
-
[out] pHandle Pointer to the array memory [in] pAllocateArray Requested array desciptor
- See also
- hipMallocArray, hipArrayDestroy, hipFreeArray
◆ hipArrayDestroy()
hipError_t hipArrayDestroy | ( | hipArray_t | array | ) |
Destroy an array memory pointer on the device.
- Parameters
-
[in] array Pointer to the array memory
- Returns
- hipSuccess, hipErrorInvalidValue
- See also
- hipArrayCreate, hipArrayDestroy, hipFreeArray
◆ hipArrayGetDescriptor()
hipError_t hipArrayGetDescriptor | ( | HIP_ARRAY_DESCRIPTOR * | pArrayDescriptor, |
hipArray_t | array | ||
) |
Gets a 1D or 2D array descriptor.
- Parameters
-
[out] pArrayDescriptor - Returned array descriptor [in] array - Array to get descriptor of
- Returns
- hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue hipErrorInvalidHandle
- See also
- hipArray3DCreate, hipArray3DGetDescriptor, hipArrayCreate, hipArrayDestroy, hipMemAlloc, hipMemAllocHost, hipMemAllocPitch, hipMemcpy2D, hipMemcpy2DAsync, hipMemcpy2DUnaligned, hipMemcpy3D, hipMemcpy3DAsync, hipMemcpyAtoA, hipMemcpyAtoD, hipMemcpyAtoH, hipMemcpyAtoHAsync, hipMemcpyDtoA, hipMemcpyDtoD, hipMemcpyDtoDAsync, hipMemcpyDtoH, hipMemcpyDtoHAsync, hipMemcpyHtoA, hipMemcpyHtoAAsync, hipMemcpyHtoD, hipMemcpyHtoDAsync, hipMemFree, hipMemFreeHost, hipMemGetAddressRange, hipMemGetInfo, hipMemHostAlloc, hipMemHostGetDevicePointer, hipMemsetD8, hipMemsetD16, hipMemsetD32, hipArrayGetInfo
◆ hipArrayGetInfo()
hipError_t hipArrayGetInfo | ( | hipChannelFormatDesc * | desc, |
hipExtent * | extent, | ||
unsigned int * | flags, | ||
hipArray_t | array | ||
) |
Gets info about the specified array.
- Parameters
-
[out] desc - Returned array type [out] extent - Returned array shape. 2D arrays will have depth of zero [out] flags - Returned array flags [in] array - The HIP array to get info for
◆ hipDrvMemcpy3D()
hipError_t hipDrvMemcpy3D | ( | const HIP_MEMCPY3D * | pCopy | ) |
Copies data between host and device.
- Parameters
-
[in] pCopy 3D memory copy parameters
◆ hipDrvMemcpy3DAsync()
hipError_t hipDrvMemcpy3DAsync | ( | const HIP_MEMCPY3D * | pCopy, |
hipStream_t | stream | ||
) |
Copies data between host and device asynchronously.
- Parameters
-
[in] pCopy 3D memory copy parameters [in] stream Stream to use
◆ hipDrvPointerGetAttributes()
hipError_t hipDrvPointerGetAttributes | ( | unsigned int | numAttributes, |
hipPointer_attribute * | attributes, | ||
void ** | data, | ||
hipDeviceptr_t | ptr | ||
) |
Returns information about the specified pointer.[BETA].
- Parameters
-
[in] numAttributes number of attributes to query for [in] attributes attributes to query for [in,out] data a two-dimensional containing pointers to memory locations where the result of each attribute query will be written to [in] ptr pointer to get attributes for
- Warning
- This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.
- See also
- hipPointerGetAttribute
◆ hipExtMallocWithFlags()
hipError_t hipExtMallocWithFlags | ( | void ** | ptr, |
size_t | sizeBytes, | ||
unsigned int | flags | ||
) |
Allocate memory on the default accelerator.
- Parameters
-
[out] ptr Pointer to the allocated memory [in] sizeBytes Requested memory size [in] flags Type of memory allocation
If requested memory size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
The memory allocation flag should be either hipDeviceMallocDefault, hipDeviceMallocFinegrained, hipDeviceMallocUncached, or hipMallocSignalMemory. If the flag is any other value, the API returns hipErrorInvalidValue.
- Returns
- hipSuccess, hipErrorOutOfMemory, hipErrorInvalidValue (bad context, null *ptr)
◆ 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] ptr Pointer to memory to be freed
- Returns
- hipSuccess
- hipErrorInvalidDevicePointer (if pointer is invalid, including host pointers allocated with hipHostMalloc)
◆ hipFreeArray()
hipError_t hipFreeArray | ( | hipArray_t | array | ) |
Frees an array on the device.
- Parameters
-
[in] array Pointer to array to free
- See also
- hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree
◆ hipGetProcAddress()
hipError_t hipGetProcAddress | ( | const char * | symbol, |
void ** | pfn, | ||
int | hipVersion, | ||
uint64_t | flags, | ||
hipDriverProcAddressQueryResult * | symbolStatus | ||
) |
Gets the pointer of requested HIP driver function.
- Parameters
-
[in] symbol The Symbol name of the driver function to request. [out] pfn Output pointer to the requested driver function. [in] hipVersion The HIP version for the requested driver function symbol. HIP version is defined as 100*version_major + version_minor. For example, in HIP 6.1, the hipversion is 601, for the symbol function "hipGetDeviceProperties", the specified hipVersion 601 is greater or equal to the version 600, the symbol function will be handle properly as backend compatible function. [in] flags Currently only default flag is suppported. [out] symbolStatus Optional enumeration for returned status of searching for symbol driver function based on the input hipVersion.
Returns hipSuccess if the returned pfn is addressed to the pointer of found driver function.
- Returns
- hipSuccess, hipErrorInvalidValue.
◆ hipGetSymbolAddress() [1/2]
hipError_t hipGetSymbolAddress | ( | void ** | devPtr, |
const T & | symbol | ||
) |
Gets the address of a symbol.
- Parameters
-
[out] devPtr - Returns device pointer associated with symbol. [in] symbol - Device symbol.
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipGetSymbolAddress() [2/2]
hipError_t hipGetSymbolAddress | ( | void ** | devPtr, |
const void * | symbol | ||
) |
Gets device pointer associated with symbol on the device.
- Parameters
-
[out] devPtr pointer to the device associated the symbole [in] symbol pointer to the symbole of the device
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipGetSymbolSize() [1/2]
hipError_t hipGetSymbolSize | ( | size_t * | size, |
const T & | symbol | ||
) |
Gets the size of a symbol.
- Parameters
-
[out] size - Returns the size of a symbol. [in] symbol - Device symbol address.
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipGetSymbolSize() [2/2]
hipError_t hipGetSymbolSize | ( | size_t * | size, |
const void * | symbol | ||
) |
Gets the size of the given symbol on the device.
- Parameters
-
[in] symbol pointer to the device symbole [out] size pointer 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.
- Parameters
-
[out] ptr Pointer to the allocated host pinned memory [in] size Requested memory size in bytes [in] flags Type of host memory allocation see below
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
Flags:
- hipHostAllocDefault Default pinned memory allocation on the host.
- hipHostAllocPortable Memory is considered allocated by all contexts.
- hipHostAllocMapped Map the allocation into the address space for the current device.
- hipHostAllocWriteCombined Allocates the memory as write-combined.
◆ hipHostGetDevicePointer()
hipError_t hipHostGetDevicePointer | ( | void ** | devPtr, |
void * | hstPtr, | ||
unsigned int | flags | ||
) |
Get Device pointer from Host Pointer allocated through hipHostMalloc.
- Parameters
-
[out] devPtr Device Pointer mapped to passed host pointer [in] hstPtr Host Pointer allocated through hipHostMalloc [in] flags Flags to be passed for extension
- See also
- hipSetDeviceFlags, hipHostMalloc
◆ hipHostGetFlags()
hipError_t hipHostGetFlags | ( | unsigned int * | flagsPtr, |
void * | hostPtr | ||
) |
Return flags associated with host pointer.
- Parameters
-
[out] flagsPtr Memory location to store flags [in] hostPtr Host Pointer allocated through hipHostMalloc
- Returns
- hipSuccess, hipErrorInvalidValue
- See also
- hipHostMalloc
◆ hipHostMalloc()
hipError_t hipHostMalloc | ( | void ** | ptr, |
size_t | size, | ||
unsigned int | flags | ||
) |
Allocates device accessible page locked (pinned) host memory.
This API allocates pinned host memory which is mapped into the address space of all GPUs in the system, the memory can be accessed directly by the GPU device, and can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc().
Using the pinned host memory, applications can implement faster data transfers for HostToDevice and DeviceToHost. The runtime tracks the hipHostMalloc allocations and can avoid some of the setup required for regular unpinned memory.
When the memory accesses are infrequent, zero-copy memory can be a good choice, for coherent allocation. GPU can directly access the host memory over the CPU/GPU interconnect, without need to copy the data.
Currently the allocation granularity is 4KB for the API.
Developers need to choose proper allocation flag with consideration of synchronization.
- Parameters
-
[out] ptr Pointer to the allocated host pinned memory [in] size Requested memory size in bytes If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. [in] flags Type of host memory allocation. See the description of flags in hipSetDeviceFlags.
If no input for flags, it will be the default pinned memory allocation on the host.
- 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] hostPtr Pointer to host memory to be registered. [in] sizeBytes Size of the host memory [in] flags See below.
Flags:
- hipHostRegisterDefault Memory is Mapped and Portable
- hipHostRegisterPortable Memory is considered registered by all contexts. HIP only supports one context so this is always assumed true.
- hipHostRegisterMapped Map the allocation into the address space for the current device. The device pointer can be obtained with hipHostGetDevicePointer.
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 host 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
◆ hipHostUnregister()
hipError_t hipHostUnregister | ( | void * | hostPtr | ) |
Un-register host pointer.
- Parameters
-
[in] hostPtr Host pointer previously registered with hipHostRegister
- Returns
- Error code
- See also
- hipHostRegister
◆ hipMalloc()
hipError_t hipMalloc | ( | void ** | ptr, |
size_t | size | ||
) |
Allocate memory on the default accelerator.
- Parameters
-
[out] ptr Pointer to the allocated memory [in] size Requested 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)
◆ hipMalloc3D()
hipError_t hipMalloc3D | ( | hipPitchedPtr * | pitchedDevPtr, |
hipExtent | extent | ||
) |
Create a 3D memory pointer on the device.
- Parameters
-
[out] pitchedDevPtr Pointer to the 3D memory [in] extent Requested extent
- See also
- hipMallocPitch, hipMemGetInfo, hipFree
◆ hipMalloc3DArray()
hipError_t hipMalloc3DArray | ( | hipArray_t * | array, |
const struct hipChannelFormatDesc * | desc, | ||
struct hipExtent | extent, | ||
unsigned int | flags | ||
) |
Allocate an array on the device.
- Parameters
-
[out] array Pointer to allocated array in device memory [in] desc Requested channel format [in] extent Requested array allocation width, height and depth [in] flags Requested properties of allocated array
- Returns
- hipSuccess, hipErrorOutOfMemory
- See also
- hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
◆ hipMallocArray()
hipError_t hipMallocArray | ( | hipArray_t * | array, |
const hipChannelFormatDesc * | desc, | ||
size_t | width, | ||
size_t | height, | ||
unsigned int | flags | ||
) |
Allocate an array on the device.
- Parameters
-
[out] array Pointer to allocated array in device memory [in] desc Requested channel format [in] width Requested array allocation width [in] height Requested array allocation height [in] flags Requested properties of allocated array
- Returns
- hipSuccess, hipErrorOutOfMemory
- See also
- hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
◆ 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] ptr Pointer to the allocated device memory [out] pitch Pitch for allocation (in bytes) [in] width Requested pitched allocation width (in bytes) [in] height Requested pitched allocation height
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
- Returns
- Error code
◆ 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] dptr Pointer to the allocated device memory [out] pitch Pitch for allocation (in bytes) [in] widthInBytes Requested pitched allocation width (in bytes) [in] height Requested pitched allocation height [in] elementSizeBytes The size of element bytes, should be 4, 8 or 16
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
◆ 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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] kind Kind of transfer
- 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] dst Destination memory address [in] dpitch Pitch of destination memory [in] src Source memory address [in] spitch Pitch of source memory [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer
◆ hipMemcpy2DArrayToArray()
hipError_t hipMemcpy2DArrayToArray | ( | hipArray_t | dst, |
size_t | wOffsetDst, | ||
size_t | hOffsetDst, | ||
hipArray_const_t | src, | ||
size_t | wOffsetSrc, | ||
size_t | hOffsetSrc, | ||
size_t | width, | ||
size_t | height, | ||
hipMemcpyKind | kind | ||
) |
Copies data between host and device.
- Parameters
-
[in] dst Destination memory address [in] wOffsetDst Destination starting X offset [in] hOffsetDst Destination starting Y offset [in] src Source memory address [in] wOffsetSrc Source starting X offset [in] hOffsetSrc Source starting Y offset (columns in bytes) [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer
◆ 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 | ||
) |
Copies data between host and device.
- Parameters
-
[in] dst Destination memory address [in] dpitch Pitch of destination memory [in] src Source memory address [in] spitch Pitch of source memory [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer [in] stream Stream to use
◆ 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] dst Destination memory address [in] dpitch Pitch of destination memory [in] src Source memory address [in] wOffset Source starting X offset [in] hOffset Source starting Y offset [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer
◆ 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 | ||
) |
Copies data between host and device asynchronously.
- Parameters
-
[in] dst Destination memory address [in] dpitch Pitch of destination memory [in] src Source memory address [in] wOffset Source starting X offset [in] hOffset Source starting Y offset [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer [in] stream Accelerator view which the copy is being enqueued
◆ hipMemcpy2DToArray()
hipError_t hipMemcpy2DToArray | ( | hipArray_t | 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] dst Destination memory address [in] wOffset Destination starting X offset [in] hOffset Destination starting Y offset [in] src Source memory address [in] spitch Pitch of source memory [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer
◆ hipMemcpy2DToArrayAsync()
hipError_t hipMemcpy2DToArrayAsync | ( | hipArray_t | dst, |
size_t | wOffset, | ||
size_t | hOffset, | ||
const void * | src, | ||
size_t | spitch, | ||
size_t | width, | ||
size_t | height, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copies data between host and device.
- Parameters
-
[in] dst Destination memory address [in] wOffset Destination starting X offset [in] hOffset Destination starting Y offset [in] src Source memory address [in] spitch Pitch of source memory [in] width Width of matrix transfer (columns in bytes) [in] height Height of matrix transfer (rows) [in] kind Type of transfer [in] stream Accelerator view which the copy is being enqueued
◆ hipMemcpy3D()
hipError_t hipMemcpy3D | ( | const struct hipMemcpy3DParms * | p | ) |
Copies data between host and device.
- Parameters
-
[in] p 3D memory copy parameters
◆ hipMemcpy3DAsync()
hipError_t hipMemcpy3DAsync | ( | const struct hipMemcpy3DParms * | p, |
hipStream_t | stream | ||
) |
Copies data between host and device asynchronously.
- Parameters
-
[in] p 3D memory copy parameters [in] stream Stream to use
◆ hipMemcpyAsync()
hipError_t hipMemcpyAsync | ( | void * | dst, |
const void * | src, | ||
size_t | sizeBytes, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] kind Type of memory transfer [in] stream Stream identifier
- See also
- hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync
◆ hipMemcpyAtoA()
hipError_t hipMemcpyAtoA | ( | hipArray_t | dstArray, |
size_t | dstOffset, | ||
hipArray_t | srcArray, | ||
size_t | srcOffset, | ||
size_t | ByteCount | ||
) |
Copies from one 1D array to another.
- Parameters
-
[out] dstArray Destination array [in] dstOffset Offset in bytes of destination array [in] srcArray Source array [in] srcOffset Offset in bytes of source array [in] ByteCount Size of memory copy 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
◆ hipMemcpyAtoD()
hipError_t hipMemcpyAtoD | ( | hipDeviceptr_t | dstDevice, |
hipArray_t | srcArray, | ||
size_t | srcOffset, | ||
size_t | ByteCount | ||
) |
Copies from one 1D array to device memory.
- Parameters
-
[out] dstDevice Destination device pointer [in] srcArray Source array [in] srcOffset Offset in bytes of source array [in] ByteCount Size of memory copy 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
◆ hipMemcpyAtoH()
hipError_t hipMemcpyAtoH | ( | void * | dst, |
hipArray_t | srcArray, | ||
size_t | srcOffset, | ||
size_t | count | ||
) |
Copies data between host and device.
- Parameters
-
[in] dst Destination memory address [in] srcArray Source array [in] srcOffset Offset in bytes of source array [in] count Size of memory copy in bytes
◆ hipMemcpyAtoHAsync()
hipError_t hipMemcpyAtoHAsync | ( | void * | dstHost, |
hipArray_t | srcArray, | ||
size_t | srcOffset, | ||
size_t | ByteCount, | ||
hipStream_t | stream | ||
) |
Copies from one 1D array to host memory.
- Parameters
-
[out] dstHost Destination pointer [in] srcArray Source array [in] srcOffset Offset in bytes of source array [in] ByteCount Size of memory copy in bytes [in] stream Stream identifier
- 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
◆ hipMemcpyDtoA()
hipError_t hipMemcpyDtoA | ( | hipArray_t | dstArray, |
size_t | dstOffset, | ||
hipDeviceptr_t | srcDevice, | ||
size_t | ByteCount | ||
) |
Copies from device memory to a 1D array.
- Parameters
-
[out] dstArray Destination array [in] dstOffset Offset in bytes of destination array [in] srcDevice Source device pointer [in] ByteCount Size of memory copy 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
◆ hipMemcpyDtoD()
hipError_t hipMemcpyDtoD | ( | hipDeviceptr_t | dst, |
hipDeviceptr_t | src, | ||
size_t | sizeBytes | ||
) |
Copy data from Device to Device.
- Parameters
-
[out] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data 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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] stream Stream identifier
- 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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data 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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] stream Stream identifier
- 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
◆ hipMemcpyFromSymbol() [1/2]
hipError_t hipMemcpyFromSymbol | ( | void * | dst, |
const T & | symbol, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind | ||
) |
Copies data from the given symbol on the device.
- See also
- hipMemcpyFromSymbol
◆ hipMemcpyFromSymbol() [2/2]
hipError_t hipMemcpyFromSymbol | ( | void * | dst, |
const void * | symbol, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind | ||
) |
Copies data from the given symbol on the device.
- Parameters
-
[out] dst Returns pointer to destinition memory address [in] symbol Pointer to the symbole address on the device [in] sizeBytes Size in bytes to copy [in] offset Offset in bytes from the start of symbole [in] kind Type of memory transfer
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemcpyFromSymbolAsync() [1/2]
hipError_t hipMemcpyFromSymbolAsync | ( | void * | dst, |
const T & | symbol, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copies data from the given symbol on the device asynchronously on the stream.
- See also
- hipMemcpyFromSymbolAsync
◆ hipMemcpyFromSymbolAsync() [2/2]
hipError_t hipMemcpyFromSymbolAsync | ( | void * | dst, |
const void * | symbol, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copies data from the given symbol on the device asynchronously.
- Parameters
-
[out] dst Returns pointer to destinition memory address [in] symbol pointer to the symbole address on the device [in] sizeBytes size in bytes to copy [in] offset offset in bytes from the start of symbole [in] kind type of memory transfer [in] stream stream identifier
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemcpyHtoA()
hipError_t hipMemcpyHtoA | ( | hipArray_t | dstArray, |
size_t | dstOffset, | ||
const void * | srcHost, | ||
size_t | count | ||
) |
Copies data between host and device.
- Parameters
-
[in] dstArray Destination memory address [in] dstOffset Offset in bytes of destination array [in] srcHost Source host pointer [in] count Size of memory copy in bytes
◆ hipMemcpyHtoAAsync()
hipError_t hipMemcpyHtoAAsync | ( | hipArray_t | dstArray, |
size_t | dstOffset, | ||
const void * | srcHost, | ||
size_t | ByteCount, | ||
hipStream_t | stream | ||
) |
Copies from host memory to a 1D array.
- Parameters
-
[out] dstArray Destination array [in] dstOffset Offset in bytes of destination array [in] srcHost Source host pointer [in] ByteCount Size of memory copy in bytes [in] stream Stream identifier
- 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
◆ hipMemcpyHtoD()
hipError_t hipMemcpyHtoD | ( | hipDeviceptr_t | dst, |
void * | src, | ||
size_t | sizeBytes | ||
) |
Copy data from Host to Device.
- Parameters
-
[out] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data 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] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] stream Stream identifier
- 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()
hipError_t hipMemcpyParam2D | ( | const hip_Memcpy2D * | pCopy | ) |
Copies memory for 2D arrays.
- Parameters
-
[in] pCopy Parameters for the memory copy
◆ hipMemcpyParam2DAsync()
hipError_t hipMemcpyParam2DAsync | ( | const hip_Memcpy2D * | pCopy, |
hipStream_t | stream | ||
) |
Copies memory for 2D arrays.
- Parameters
-
[in] pCopy Parameters for the memory copy [in] stream Stream to use
◆ hipMemcpyToSymbol() [1/2]
hipError_t hipMemcpyToSymbol | ( | const T & | symbol, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind | ||
) |
Copies data to the given symbol on the device.
- See also
- hipMemcpyToSymbol
◆ hipMemcpyToSymbol() [2/2]
hipError_t hipMemcpyToSymbol | ( | const void * | symbol, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind | ||
) |
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 detailed usage, see the memcpyToSymbol example in the HIP Porting Guide.
- Parameters
-
[out] symbol pointer to the device symbole [in] src pointer to the source address [in] sizeBytes size in bytes to copy [in] offset offset in bytes from start of symbole [in] kind type of memory transfer
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemcpyToSymbolAsync() [1/2]
hipError_t hipMemcpyToSymbolAsync | ( | const T & | symbol, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copies data to the given symbol on the device asynchronously on the stream.
- See also
- hipMemcpyToSymbolAsync
◆ hipMemcpyToSymbolAsync() [2/2]
hipError_t hipMemcpyToSymbolAsync | ( | const void * | symbol, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copies data to the given symbol on the device asynchronously.
- Parameters
-
[out] symbol pointer to the device symbole [in] src pointer to the source address [in] sizeBytes size in bytes to copy [in] offset offset in bytes from start of symbole [in] kind type of memory transfer [in] stream stream identifier
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemcpyWithStream()
hipError_t hipMemcpyWithStream | ( | void * | dst, |
const void * | src, | ||
size_t | sizeBytes, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Memory copy on the stream. It allows single or multiple devices to do memory copy on single or multiple streams.
- Parameters
-
[out] dst Data being copy to [in] src Data being copy from [in] sizeBytes Data size in bytes [in] kind Kind of transfer [in] stream Valid stream
- See also
- hipMemcpy, hipStreamCreate, hipStreamSynchronize, hipStreamDestroy, hipSetDevice, hipLaunchKernelGGL
◆ hipMemGetInfo()
hipError_t hipMemGetInfo | ( | size_t * | free, |
size_t * | total | ||
) |
Query memory info.
On ROCM, this function gets the actual free memory left on the current device, so supports the cases while running multi-workload (such as multiple processes, multiple threads, and multiple GPUs).
- Warning
- On Windows, the free memory only accounts for memory allocated by this process and may be optimistic.
- Parameters
-
[out] free Returns free memory on the current device in bytes [out] total Returns total allocatable memory on the current device in bytes
◆ hipMemPtrGetInfo()
hipError_t hipMemPtrGetInfo | ( | void * | ptr, |
size_t * | size | ||
) |
Get allocated memory size via memory pointer.
This function gets the allocated shared virtual memory size from memory pointer.
- Parameters
-
[in] ptr Pointer to allocated memory [out] size Returns the allocated memory size in bytes
- 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] dst Data being filled [in] value Value to be set [in] sizeBytes Data size in bytes
◆ 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] dst Pointer to device memory [in] pitch Data size in bytes [in] value Constant value to be set [in] width [in] height
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemset2DAsync()
hipError_t hipMemset2DAsync | ( | void * | dst, |
size_t | pitch, | ||
int | value, | ||
size_t | width, | ||
size_t | height, | ||
hipStream_t | stream | ||
) |
Fills asynchronously the memory area pointed to by dst with the constant value.
- Parameters
-
[in] dst Pointer to 2D device memory [in] pitch Pitch size in bytes [in] value Value to be set for each byte of specified memory [in] width Width of matrix set columns in bytes [in] height Height of matrix set rows in bytes [in] stream Stream identifier
- Returns
- hipSuccess, hipErrorInvalidValue
◆ 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 Pointer to pitched device memory [in] value Value to set for each byte of specified memory [in] extent Size parameters for width field in bytes in device memory
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemset3DAsync()
hipError_t hipMemset3DAsync | ( | hipPitchedPtr | pitchedDevPtr, |
int | value, | ||
hipExtent | extent, | ||
hipStream_t | stream | ||
) |
Fills asynchronously the memory area pointed to by pitchedDevPtr with the constant value.
- Parameters
-
[in] pitchedDevPtr Pointer to pitched device memory [in] value Value to set for each byte of specified memory [in] extent Size parameters for width field in bytes in device memory [in] stream Stream identifier
- Returns
- hipSuccess, hipErrorInvalidValue
◆ hipMemsetAsync()
hipError_t hipMemsetAsync | ( | void * | dst, |
int | value, | ||
size_t | sizeBytes, | ||
hipStream_t | stream | ||
) |
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] dst Pointer 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
◆ 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] dest Data ptr to be filled [in] value Constant value to be set [in] count Number of values to be set
◆ hipMemsetD16Async()
hipError_t hipMemsetD16Async | ( | hipDeviceptr_t | dest, |
unsigned short | value, | ||
size_t | count, | ||
hipStream_t | stream | ||
) |
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] dest Data ptr to be filled [in] value Constant value to be set [in] count Number of values to be set [in] stream Stream identifier
◆ 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] dest Data being filled [in] value Constant value to be set [in] count Number of values to be set
◆ hipMemsetD32Async()
hipError_t hipMemsetD32Async | ( | hipDeviceptr_t | dst, |
int | value, | ||
size_t | count, | ||
hipStream_t | stream | ||
) |
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] dst Pointer 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
◆ 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] dest Data ptr to be filled [in] value Value to be set [in] count Number of values to be set
◆ hipMemsetD8Async()
hipError_t hipMemsetD8Async | ( | hipDeviceptr_t | dest, |
unsigned char | value, | ||
size_t | count, | ||
hipStream_t | stream | ||
) |
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] dest Data ptr to be filled [in] value Constant value to be set [in] count Number of values to be set [in] stream Stream identifier
◆ 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] dptr Returns global device pointer [out] bytes Returns global size in bytes [in] hmod Module to retrieve global from [in] name Name of global to retrieve
◆ hipPointerGetAttribute()
hipError_t hipPointerGetAttribute | ( | void * | data, |
hipPointer_attribute | attribute, | ||
hipDeviceptr_t | ptr | ||
) |
Returns information about the specified pointer.[BETA].
- Parameters
-
[in,out] data Returned pointer attribute value [in] attribute Attribute to query for [in] ptr Pointer to get attributes for
- Warning
- This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.
- See also
- hipPointerGetAttributes
◆ hipPointerGetAttributes()
hipError_t hipPointerGetAttributes | ( | hipPointerAttribute_t * | attributes, |
const void * | ptr | ||
) |
Returns attributes for the specified pointer.
- Parameters
-
[out] attributes attributes for the specified pointer [in] ptr pointer to get attributes for
The output parameter 'attributes' has a member named 'type' that describes what memory the pointer is associated with, such as device memory, host memory, managed memory, and others. Otherwise, the API cannot handle the pointer and returns hipErrorInvalidValue.
- Note
- The unrecognized memory type is unsupported to keep the HIP functionality backward compatibility due to hipMemoryType enum values.
- Note
- The current behavior of this HIP API corresponds to the CUDA API before version 11.0.
- See also
- hipPointerGetAttribute
◆ hipPointerSetAttribute()
hipError_t hipPointerSetAttribute | ( | const void * | value, |
hipPointer_attribute | attribute, | ||
hipDeviceptr_t | ptr | ||
) |
Sets information on the specified pointer.[BETA].
- Parameters
-
[in] value Sets pointer attribute value [in] attribute Attribute to set [in] ptr Pointer to set attributes for
- Warning
- This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.