HIP: Heterogenous-computing Interface for Portability
|
Functions | |
hipError_t | hipPointerGetAttributes (hipPointerAttribute_t *attributes, const void *ptr) |
Return attributes for the specified pointer. More... | |
hipError_t | hipMalloc (void **ptr, size_t size) |
Allocate memory on the default accelerator. More... | |
hipError_t | hipMallocHost (void **ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead"))) |
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 | hipHostAlloc (void **ptr, size_t size, unsigned int flags) __attribute__((deprecated("use hipHostMalloc instead"))) |
Allocate device accessible page locked host memory [Deprecated]. More... | |
hipError_t | hipHostGetDevicePointer (void **devPtr, void *hstPtr, unsigned int flags) |
Get Device pointer from Host Pointer allocated through hipHostMalloc. More... | |
hipError_t | hipHostGetFlags (unsigned int *flagsPtr, void *hostPtr) |
Return flags associated with host pointer. More... | |
hipError_t | hipHostRegister (void *hostPtr, size_t sizeBytes, unsigned int flags) |
Register host memory so it can be accessed from the current device. More... | |
hipError_t | hipHostUnregister (void *hostPtr) |
Un-register host pointer. More... | |
hipError_t | hipMallocPitch (void **ptr, size_t *pitch, size_t width, size_t height) |
hipError_t | hipFree (void *ptr) |
Free memory allocated by the hcc hip memory allocation API. This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More... | |
hipError_t | hipFreeHost (void *ptr) __attribute__((deprecated("use hipHostFree instead"))) |
Free memory allocated by the hcc hip host memory allocation API. [Deprecated]. More... | |
hipError_t | hipHostFree (void *ptr) |
Free memory allocated by the hcc hip host memory allocation API This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More... | |
hipError_t | hipMemcpy (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind) |
Copy data from src to dst. More... | |
hipError_t | hipMemcpyHtoD (hipDeviceptr_t dst, void *src, size_t sizeBytes) |
Copy data from Host to Device. More... | |
hipError_t | hipMemcpyDtoH (void *dst, hipDeviceptr_t src, size_t sizeBytes) |
Copy data from Device to Host. More... | |
hipError_t | hipMemcpyDtoD (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) |
Copy data from Device to Device. More... | |
hipError_t | hipMemcpyHtoDAsync (hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream) |
Copy data from Host to Device asynchronously. More... | |
hipError_t | hipMemcpyDtoHAsync (void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) |
Copy data from Device to Host asynchronously. More... | |
hipError_t | hipMemcpyDtoDAsync (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) |
Copy data from Device to Device asynchronously. More... | |
hipError_t | hipMemcpyToSymbol (const void *symbolName, const void *src, size_t sizeBytes, size_t offset=0, hipMemcpyKind kind=hipMemcpyHostToDevice) |
Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol . More... | |
hipError_t | hipMemcpyToSymbolAsync (const void *symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream=0) |
Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol . More... | |
hipError_t | hipMemcpyFromSymbol (void *dst, const void *symbolName, size_t sizeBytes, size_t offset=0, hipMemcpyKind kind=hipMemcpyDeviceToHost) |
hipError_t | hipMemcpyFromSymbolAsync (void *dst, const void *symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream=0) |
hipError_t | hipMemcpyAsync (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) |
Copy data from src to dst asynchronously. More... | |
hipError_t | hipMemset (void *dst, int value, size_t sizeBytes) |
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More... | |
hipError_t | hipMemsetD8 (hipDeviceptr_t dest, unsigned char value, size_t sizeBytes) |
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. More... | |
hipError_t | 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. 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 struct hipChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags) |
Allocate an array on the device. More... | |
hipError_t | hipFreeArray (hipArray *array) |
Frees an array on the device. More... | |
hipError_t | hipMemcpy2D (void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) |
Copies data between host and device. More... | |
hipError_t | 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. More... | |
hipError_t | hipMemcpy2DToArray (hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) |
Copies data between host and device. More... | |
hipError_t | hipMemcpyToArray (hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t count, hipMemcpyKind kind) |
Copies data between host and device. More... | |
The following CUDA APIs are not currently supported:
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.
[in] | ptr | Pointer to memory to be freed |
hipError_t hipFreeArray | ( | hipArray * | array | ) |
Frees an array on the device.
[in] | array | Pointer to array to free |
hipError_t hipFreeHost | ( | void * | ptr | ) |
Free memory allocated by the hcc hip host memory allocation API. [Deprecated].
[in] | ptr | Pointer to memory to be freed |
hipError_t hipHostAlloc | ( | void ** | ptr, |
size_t | size, | ||
unsigned int | flags | ||
) |
Allocate device accessible page locked host memory [Deprecated].
[out] | ptr | Pointer to the allocated host pinned memory |
[in] | size | Requested memory size |
[in] | flags | Type of host memory allocation |
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
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.
[in] | ptr | Pointer to memory to be freed |
hipError_t hipHostGetDevicePointer | ( | void ** | devPtr, |
void * | hstPtr, | ||
unsigned int | flags | ||
) |
Get Device pointer from Host Pointer allocated through hipHostMalloc.
[out] | dstPtr | Device Pointer mapped to passed host pointer |
[in] | hstPtr | Host Pointer allocated through hipHostMalloc |
[in] | flags | Flags to be passed for extension |
hipError_t hipHostGetFlags | ( | unsigned int * | flagsPtr, |
void * | hostPtr | ||
) |
Return flags associated with host pointer.
[out] | flagsPtr | Memory location to store flags |
[in] | hostPtr | Host Pointer allocated through hipHostMalloc |
hipError_t hipHostMalloc | ( | void ** | ptr, |
size_t | size, | ||
unsigned int | flags | ||
) |
Allocate device accessible page locked host memory.
[out] | ptr | Pointer to the allocated host pinned memory |
[in] | size | Requested memory size |
[in] | flags | Type of host memory allocation |
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
hipError_t hipHostRegister | ( | void * | hostPtr, |
size_t | sizeBytes, | ||
unsigned int | flags | ||
) |
Register host memory so it can be accessed from the current device.
[out] | hostPtr | Pointer to host memory to be registered. |
[in] | sizeBytes | size 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.
hipError_t hipHostUnregister | ( | void * | hostPtr | ) |
Un-register host pointer.
[in] | hostPtr | Host pointer previously registered with hipHostRegister |
hipError_t hipMalloc | ( | void ** | ptr, |
size_t | size | ||
) |
Allocate memory on the default accelerator.
[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.
hipError_t hipMallocArray | ( | hipArray ** | array, |
const struct hipChannelFormatDesc * | desc, | ||
size_t | width, | ||
size_t | height, | ||
unsigned int | flags | ||
) |
Allocate an array on the device.
[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 |
hipError_t hipMallocHost | ( | void ** | ptr, |
size_t | size | ||
) |
Allocate pinned host memory [Deprecated].
[out] | ptr | Pointer to the allocated host pinned memory |
[in] | size | Requested memory size |
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
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
[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.
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.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
[in] | copyType | Memory copy type |
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.
[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 |
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.
[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 |
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.
[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 |
hipError_t hipMemcpyAsync | ( | void * | dst, |
const void * | src, | ||
size_t | sizeBytes, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream | ||
) |
Copy data from src to dst asynchronously.
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.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
[in] | accelerator_view | Accelerator view which the copy is being enqueued |
hipError_t hipMemcpyDtoD | ( | hipDeviceptr_t | dst, |
hipDeviceptr_t | src, | ||
size_t | sizeBytes | ||
) |
Copy data from Device to Device.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
hipError_t hipMemcpyDtoDAsync | ( | hipDeviceptr_t | dst, |
hipDeviceptr_t | src, | ||
size_t | sizeBytes, | ||
hipStream_t | stream | ||
) |
Copy data from Device to Device asynchronously.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
hipError_t hipMemcpyDtoH | ( | void * | dst, |
hipDeviceptr_t | src, | ||
size_t | sizeBytes | ||
) |
Copy data from Device to Host.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
hipError_t hipMemcpyDtoHAsync | ( | void * | dst, |
hipDeviceptr_t | src, | ||
size_t | sizeBytes, | ||
hipStream_t | stream | ||
) |
Copy data from Device to Host asynchronously.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
hipError_t hipMemcpyHtoD | ( | hipDeviceptr_t | dst, |
void * | src, | ||
size_t | sizeBytes | ||
) |
Copy data from Host to Device.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
hipError_t hipMemcpyHtoDAsync | ( | hipDeviceptr_t | dst, |
void * | src, | ||
size_t | sizeBytes, | ||
hipStream_t | stream | ||
) |
Copy data from Host to Device asynchronously.
[out] | dst | Data being copy to |
[in] | src | Data being copy from |
[in] | sizeBytes | Data size in bytes |
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.
[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 |
hipError_t hipMemcpyToSymbol | ( | const void * | symbolName, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset = 0 , |
||
hipMemcpyKind | kind = hipMemcpyHostToDevice |
||
) |
Copies sizeBytes
bytes from the memory area pointed to by src
to the memory area pointed to by offset
bytes from the start of symbol symbol
.
The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.
[in] | symbolName | - Symbol destination on device |
[in] | src | - Data being copy from |
[in] | sizeBytes | - Data size in bytes |
[in] | offset | - Offset from start of symbol in bytes |
[in] | kind | - Type of transfer |
hipError_t hipMemcpyToSymbolAsync | ( | const void * | symbolName, |
const void * | src, | ||
size_t | sizeBytes, | ||
size_t | offset, | ||
hipMemcpyKind | kind, | ||
hipStream_t | stream = 0 |
||
) |
Copies sizeBytes
bytes from the memory area pointed to by src
to the memory area pointed to by offset
bytes from the start of symbol symbol
.
The memory areas may not overlap. Symbol can either be a variable that resides in global or constant memory space, or it can be a character string, naming a variable that resides in global or constant memory space. Kind can be either hipMemcpyHostToDevice or hipMemcpyDeviceToDevice hipMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before copy is complete. TODO: cudaErrorInvalidSymbol and cudaErrorInvalidMemcpyDirection is not supported, use hipErrorUnknown for now.
[in] | symbolName | - Symbol destination on device |
[in] | src | - Data being copy from |
[in] | sizeBytes | - Data size in bytes |
[in] | offset | - Offset from start of symbol in bytes |
[in] | kind | - Type of transfer |
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.
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.
[out] | dst | Data being filled |
[in] | constant | value to be set |
[in] | sizeBytes | Data size in bytes |
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.
[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 |
hipError_t hipMemsetD8 | ( | hipDeviceptr_t | dest, |
unsigned char | value, | ||
size_t | sizeBytes | ||
) |
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value.
[out] | dst | Data ptr to be filled |
[in] | constant | value to be set |
[in] | sizeBytes | Data size in bytes |
hipError_t hipPointerGetAttributes | ( | hipPointerAttribute_t * | attributes, |
const void * | ptr | ||
) |
Return attributes for the specified pointer.
[out] | attributes | for the specified pointer |
[in] | pointer | to get attributes for |