Memory management#
-
hipError_t hipPointerSetAttribute(const void *value, hipPointer_attribute attribute, hipDeviceptr_t ptr)#
Sets information on the specified pointer.[BETA].
Warning
This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.
- Parameters:
value – [in] Sets pointer attribute value
attribute – [in] Attribute to set
ptr – [in] Pointer to set attributes for
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
-
hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void *ptr)#
Returns attributes for the specified pointer.
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.
See also
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.
- Parameters:
attributes – [out] attributes for the specified pointer
ptr – [in] pointer to get attributes for
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
-
hipError_t hipPointerGetAttribute(void *data, hipPointer_attribute attribute, hipDeviceptr_t ptr)#
Returns information about the specified pointer.[BETA].
See also
Warning
This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.
- Parameters:
data – [inout] Returned pointer attribute value
attribute – [in] Attribute to query for
ptr – [in] Pointer to get attributes for
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
-
hipError_t hipDrvPointerGetAttributes(unsigned int numAttributes, hipPointer_attribute *attributes, void **data, hipDeviceptr_t ptr)#
Returns information about the specified pointer.[BETA].
See also
Warning
This API is marked as Beta. While this feature is complete, it can change and might have outstanding issues.
- Parameters:
numAttributes – [in] number of attributes to query for
attributes – [in] attributes to query for
data – [inout] a two-dimensional containing pointers to memory locations where the result of each attribute query will be written to
ptr – [in] pointer to get attributes for
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
-
hipError_t hipMalloc(void **ptr, size_t size)#
Allocate memory on the default accelerator.
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc
- Parameters:
ptr – [out] Pointer to the allocated memory
size – [in] Requested memory size
- Returns:
hipSuccess, hipErrorOutOfMemory, hipErrorInvalidValue (bad context, null *ptr)
-
hipError_t hipExtMallocWithFlags(void **ptr, size_t sizeBytes, unsigned int flags)#
Allocate memory on the default accelerator.
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.
See also
hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc
- Parameters:
ptr – [out] Pointer to the allocated memory
sizeBytes – [in] Requested memory size
flags – [in] Type of memory allocation
- Returns:
hipSuccess, hipErrorOutOfMemory, hipErrorInvalidValue (bad context, null *ptr)
-
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.
If no input for flags, it will be the default pinned memory allocation on the host.
See also
- Parameters:
ptr – [out] Pointer to the allocated host pinned memory
size – [in] Requested memory size in bytes If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
flags – [in] Type of host memory allocation. See the description of flags in hipSetDeviceFlags.
- Returns:
hipSuccess, hipErrorOutOfMemory
-
hipError_t hipHostGetDevicePointer(void **devPtr, void *hstPtr, unsigned int flags)#
Get Device pointer from Host Pointer allocated through hipHostMalloc.
See also
- Parameters:
devPtr – [out] Device Pointer mapped to passed host pointer
hstPtr – [in] Host Pointer allocated through hipHostMalloc
flags – [in] Flags to be passed for extension
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorOutOfMemory
-
hipError_t hipHostGetFlags(unsigned int *flagsPtr, void *hostPtr)#
Return flags associated with host pointer.
See also
- Parameters:
flagsPtr – [out] Memory location to store flags
hostPtr – [in] Host Pointer allocated through hipHostMalloc
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags)#
Register host memory so it can be accessed from the current device.
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.
- Parameters:
hostPtr – [out] Pointer to host memory to be registered.
sizeBytes – [in] Size of the host memory
flags – [in] See below.
- Returns:
hipSuccess, hipErrorOutOfMemory
-
hipError_t hipHostUnregister(void *hostPtr)#
Un-register host pointer.
See also
- Parameters:
hostPtr – [in] Host pointer previously registered with hipHostRegister
- Returns:
Error code
-
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
If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
See also
hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
- Parameters:
ptr – [out] Pointer to the allocated device memory
pitch – [out] Pitch for allocation (in bytes)
width – [in] Requested pitched allocation width (in bytes)
height – [in] Requested pitched allocation height
- Returns:
Error code
-
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
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;
See also
hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
- Parameters:
dptr – [out] Pointer to the allocated device memory
pitch – [out] Pitch for allocation (in bytes)
widthInBytes – [in] Requested pitched allocation width (in bytes)
height – [in] Requested pitched allocation height
elementSizeBytes – [in] The size of element bytes, should be 4, 8 or 16
- Returns:
Error code
-
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.
See also
hipMalloc, hipMallocPitch, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
- Parameters:
ptr – [in] Pointer to memory to be freed
- Returns:
hipSuccess
- Returns:
hipErrorInvalidDevicePointer (if pointer is invalid, including host pointers allocated with hipHostMalloc)
-
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.
See also
hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostMalloc
- Parameters:
ptr – [in] Pointer to memory to be freed
- Returns:
hipSuccess, hipErrorInvalidValue (if pointer is invalid, including device pointers allocated with hipMalloc)
-
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.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
kind – [in] Kind of transfer
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorUnknown
-
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.
See also
hipMemcpy, hipStreamCreate, hipStreamSynchronize, hipStreamDestroy, hipSetDevice, hipLaunchKernelGGL
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
kind – [in] Kind of transfer
stream – [in] Valid stream
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorUnknown, hipErrorContextIsDestroyed
-
hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void *src, size_t sizeBytes)#
Copy data from Host to Device.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyDtoH(void *dst, hipDeviceptr_t src, size_t sizeBytes)#
Copy data from Device to Host.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes)#
Copy data from Device to Device.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyAtoD(hipDeviceptr_t dstDevice, hipArray_t srcArray, size_t srcOffset, size_t ByteCount)#
Copies from one 1D array to device memory.
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
- Parameters:
dstDevice – [out] Destination device pointer
srcArray – [in] Source array
srcOffset – [in] Offset in bytes of source array
ByteCount – [in] Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyDtoA(hipArray_t dstArray, size_t dstOffset, hipDeviceptr_t srcDevice, size_t ByteCount)#
Copies from device memory to a 1D array.
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
- Parameters:
dstArray – [out] Destination array
dstOffset – [in] Offset in bytes of destination array
srcDevice – [in] Source device pointer
ByteCount – [in] Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
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.
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
- Parameters:
dstArray – [out] Destination array
dstOffset – [in] Offset in bytes of destination array
srcArray – [in] Source array
srcOffset – [in] Offset in bytes of source array
ByteCount – [in] Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream)#
Copy data from Host to Device asynchronously.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyDtoHAsync(void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)#
Copy data from Device to Host asynchronously.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)#
Copy data from Device to Device asynchronously.
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
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
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.
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
- Parameters:
dstHost – [out] Destination pointer
srcArray – [in] Source array
srcOffset – [in] Offset in bytes of source array
ByteCount – [in] Size of memory copy in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
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.
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
- Parameters:
dstArray – [out] Destination array
dstOffset – [in] Offset in bytes of destination array
srcHost – [in] Source host pointer
ByteCount – [in] Size of memory copy in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue
-
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:
dptr – [out] Returns global device pointer
bytes – [out] Returns global size in bytes
hmod – [in] Module to retrieve global from
name – [in] Name of global to retrieve
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotFound, hipErrorInvalidContext
-
hipError_t hipGetSymbolAddress(void **devPtr, const void *symbol)#
Gets device pointer associated with symbol on the device.
- Parameters:
devPtr – [out] pointer to the device associated the symbole
symbol – [in] pointer to the symbole of the device
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipGetSymbolSize(size_t *size, const void *symbol)#
Gets the size of the given symbol on the device.
- Parameters:
symbol – [in] pointer to the device symbole
size – [out] pointer to the size
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipGetProcAddress(const char *symbol, void **pfn, int hipVersion, uint64_t flags, hipDriverProcAddressQueryResult *symbolStatus)#
Gets the pointer of requested HIP driver function.
Returns hipSuccess if the returned pfn is addressed to the pointer of found driver function.
- Parameters:
symbol – [in] The Symbol name of the driver function to request.
pfn – [out] Output pointer to the requested driver function.
hipVersion – [in] 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.
flags – [in] Currently only default flag is suppported.
symbolStatus – [out] Optional enumeration for returned status of searching for symbol driver function based on the input hipVersion.
- Returns:
hipSuccess, hipErrorInvalidValue.
-
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:
symbol – [out] pointer to the device symbole
src – [in] pointer to the source address
sizeBytes – [in] size in bytes to copy
offset – [in] offset in bytes from start of symbole
kind – [in] type of memory transfer
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
symbol – [out] pointer to the device symbole
src – [in] pointer to the source address
sizeBytes – [in] size in bytes to copy
offset – [in] offset in bytes from start of symbole
kind – [in] type of memory transfer
stream – [in] stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
dst – [out] Returns pointer to destinition memory address
symbol – [in] Pointer to the symbole address on the device
sizeBytes – [in] Size in bytes to copy
offset – [in] Offset in bytes from the start of symbole
kind – [in] Type of memory transfer
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
dst – [out] Returns pointer to destinition memory address
symbol – [in] pointer to the symbole address on the device
sizeBytes – [in] size in bytes to copy
offset – [in] offset in bytes from the start of symbole
kind – [in] type of memory transfer
stream – [in] stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
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.
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync
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.
Warning
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.
- Parameters:
dst – [out] Data being copy to
src – [in] Data being copy from
sizeBytes – [in] Data size in bytes
kind – [in] Type of memory transfer
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorUnknown
-
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:
dst – [out] Data being filled
value – [in] Value to be set
sizeBytes – [in] Data size in bytes
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dest – [out] Data ptr to be filled
value – [in] Value to be set
count – [in] Number of values to be set
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dest – [out] Data ptr to be filled
value – [in] Constant value to be set
count – [in] Number of values to be set
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dest – [out] Data ptr to be filled
value – [in] Constant value to be set
count – [in] Number of values to be set
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dest – [out] Data ptr to be filled
value – [in] Constant value to be set
count – [in] Number of values to be set
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dest – [out] Data being filled
value – [in] Constant value to be set
count – [in] Number of values to be set
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
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:
dst – [out] Pointer to device memory
value – [in] Value to set for each byte of specified memory
sizeBytes – [in] Size in bytes to set
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
dst – [out] Pointer to device memory
value – [in] Value to set for each byte of specified memory
count – [in] Number of values to be set
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
dst – [out] Pointer to device memory
pitch – [in] Data size in bytes
value – [in] Constant value to be set
width – [in]
height – [in]
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
dst – [in] Pointer to 2D device memory
pitch – [in] Pitch size in bytes
value – [in] Value to be set for each byte of specified memory
width – [in] Width of matrix set columns in bytes
height – [in] Height of matrix set rows in bytes
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent)#
Fills synchronously the memory area pointed to by pitchedDevPtr with the constant value.
- Parameters:
pitchedDevPtr – [in] Pointer to pitched device memory
value – [in] Value to set for each byte of specified memory
extent – [in] Size parameters for width field in bytes in device memory
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
pitchedDevPtr – [in] Pointer to pitched device memory
value – [in] Value to set for each byte of specified memory
extent – [in] Size parameters for width field in bytes in device memory
stream – [in] Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue
-
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:
free – [out] Returns free memory on the current device in bytes
total – [out] Returns total allocatable memory on the current device in bytes
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue
-
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:
ptr – [in] Pointer to allocated memory
size – [out] Returns the allocated memory size in bytes
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipMallocArray(hipArray_t *array, const hipChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags)#
Allocate an array on the device.
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
- Parameters:
array – [out] Pointer to allocated array in device memory
desc – [in] Requested channel format
width – [in] Requested array allocation width
height – [in] Requested array allocation height
flags – [in] Requested properties of allocated array
- Returns:
hipSuccess, hipErrorOutOfMemory
-
hipError_t hipArrayCreate(hipArray_t *pHandle, const HIP_ARRAY_DESCRIPTOR *pAllocateArray)#
Create an array memory pointer on the device.
See also
- Parameters:
pHandle – [out] Pointer to the array memory
pAllocateArray – [in] Requested array desciptor
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotSupported
-
hipError_t hipArrayDestroy(hipArray_t array)#
Destroy an array memory pointer on the device.
See also
- Parameters:
array – [in] Pointer to the array memory
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipArray3DCreate(hipArray_t *array, const HIP_ARRAY3D_DESCRIPTOR *pAllocateArray)#
Create a 3D array memory pointer on the device.
See also
- Parameters:
array – [out] Pointer to the 3D array memory
pAllocateArray – [in] Requested array desciptor
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotSupported
-
hipError_t hipMalloc3D(hipPitchedPtr *pitchedDevPtr, hipExtent extent)#
Create a 3D memory pointer on the device.
See also
- Parameters:
pitchedDevPtr – [out] Pointer to the 3D memory
extent – [in] Requested extent
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotSupported
-
hipError_t hipFreeArray(hipArray_t array)#
Frees an array on the device.
See also
hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree
- Parameters:
array – [in] Pointer to array to free
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized
-
hipError_t hipMalloc3DArray(hipArray_t *array, const struct hipChannelFormatDesc *desc, struct hipExtent extent, unsigned int flags)#
Allocate an array on the device.
See also
hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
- Parameters:
array – [out] Pointer to allocated array in device memory
desc – [in] Requested channel format
extent – [in] Requested array allocation width, height and depth
flags – [in] Requested properties of allocated array
- Returns:
hipSuccess, hipErrorOutOfMemory
-
hipError_t hipArrayGetInfo(hipChannelFormatDesc *desc, hipExtent *extent, unsigned int *flags, hipArray_t array)#
Gets info about the specified array.
See also
- Parameters:
desc – [out] - Returned array type
extent – [out] - Returned array shape. 2D arrays will have depth of zero
flags – [out] - Returned array flags
array – [in] - The HIP array to get info for
- Returns:
hipSuccess, hipErrorInvalidValue hipErrorInvalidHandle
-
hipError_t hipArrayGetDescriptor(HIP_ARRAY_DESCRIPTOR *pArrayDescriptor, hipArray_t array)#
Gets a 1D or 2D array descriptor.
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
- Parameters:
pArrayDescriptor – [out] - Returned array descriptor
array – [in] - Array to get descriptor of
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue hipErrorInvalidHandle
-
hipError_t hipArray3DGetDescriptor(HIP_ARRAY3D_DESCRIPTOR *pArrayDescriptor, hipArray_t array)#
Gets a 3D array descriptor.
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
- Parameters:
pArrayDescriptor – [out] - Returned 3D array descriptor
array – [in] - 3D array to get descriptor of
- Returns:
hipSuccess, hipErrorDeinitialized, hipErrorNotInitialized, hipErrorInvalidContext, hipErrorInvalidValue hipErrorInvalidHandle, hipErrorContextIsDestroyed
-
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.
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
dpitch – [in] Pitch of destination memory
src – [in] Source memory address
spitch – [in] Pitch of source memory
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpyParam2D(const hip_Memcpy2D *pCopy)#
Copies memory for 2D arrays.
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
pCopy – [in] Parameters for the memory copy
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpyParam2DAsync(const hip_Memcpy2D *pCopy, hipStream_t stream)#
Copies memory for 2D arrays.
See also
hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
pCopy – [in] Parameters for the memory copy
stream – [in] Stream to use
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
dpitch – [in] Pitch of destination memory
src – [in] Source memory address
spitch – [in] Pitch of source memory
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
stream – [in] Stream to use
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
wOffset – [in] Destination starting X offset
hOffset – [in] Destination starting Y offset
src – [in] Source memory address
spitch – [in] Pitch of source memory
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
wOffset – [in] Destination starting X offset
hOffset – [in] Destination starting Y offset
src – [in] Source memory address
spitch – [in] Pitch of source memory
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
stream – [in] Accelerator view which the copy is being enqueued
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
wOffsetDst – [in] Destination starting X offset
hOffsetDst – [in] Destination starting Y offset
src – [in] Source memory address
wOffsetSrc – [in] Source starting X offset
hOffsetSrc – [in] Source starting Y offset (columns in bytes)
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
dpitch – [in] Pitch of destination memory
src – [in] Source memory address
wOffset – [in] Source starting X offset
hOffset – [in] Source starting Y offset
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
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.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
dpitch – [in] Pitch of destination memory
src – [in] Source memory address
wOffset – [in] Source starting X offset
hOffset – [in] Source starting Y offset
width – [in] Width of matrix transfer (columns in bytes)
height – [in] Height of matrix transfer (rows)
kind – [in] Type of transfer
stream – [in] Accelerator view which the copy is being enqueued
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpyAtoH(void *dst, hipArray_t srcArray, size_t srcOffset, size_t count)#
Copies data between host and device.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dst – [in] Destination memory address
srcArray – [in] Source array
srcOffset – [in] Offset in bytes of source array
count – [in] Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpyHtoA(hipArray_t dstArray, size_t dstOffset, const void *srcHost, size_t count)#
Copies data between host and device.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
dstArray – [in] Destination memory address
dstOffset – [in] Offset in bytes of destination array
srcHost – [in] Source host pointer
count – [in] Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpy3D(const struct hipMemcpy3DParms *p)#
Copies data between host and device.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
p – [in] 3D memory copy parameters
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipMemcpy3DAsync(const struct hipMemcpy3DParms *p, hipStream_t stream)#
Copies data between host and device asynchronously.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
p – [in] 3D memory copy parameters
stream – [in] Stream to use
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipDrvMemcpy3D(const HIP_MEMCPY3D *pCopy)#
Copies data between host and device.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
pCopy – [in] 3D memory copy parameters
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
hipError_t hipDrvMemcpy3DAsync(const HIP_MEMCPY3D *pCopy, hipStream_t stream)#
Copies data between host and device asynchronously.
See also
hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync
- Parameters:
pCopy – [in] 3D memory copy parameters
stream – [in] Stream to use
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidPitchValue, hipErrorInvalidDevicePointer, hipErrorInvalidMemcpyDirection
-
template<typename T>
hipError_t hipGetSymbolAddress(void **devPtr, const T &symbol)# Gets the address of a symbol.
- Parameters:
devPtr – [out] - Returns device pointer associated with symbol.
symbol – [in] - Device symbol.
- Returns:
hipSuccess, hipErrorInvalidValue
-
template<typename T>
hipError_t hipGetSymbolSize(size_t *size, const T &symbol)# Gets the size of a symbol.
- Parameters:
size – [out] - Returns the size of a symbol.
symbol – [in] - Device symbol address.
- Returns:
hipSuccess, hipErrorInvalidValue
-
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.
See also
- Returns:
hipSuccess, hipErrorInvalidMemcpyDirection, hipErrorInvalidValue
-
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.
See also
- Returns:
hipSuccess, hipErrorInvalidMemcpyDirection, hipErrorInvalidValue
-
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.
See also
- Returns:
hipSuccess, hipErrorInvalidMemcpyDirection, hipErrorInvalidValue
-
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.
See also
- Returns:
hipSuccess, hipErrorInvalidMemcpyDirection, hipErrorInvalidValue
-
template<class T>
static inline hipError_t hipMalloc(T **devPtr, size_t size)# : C++ wrapper for hipMalloc
Perform automatic type conversion to eliminate need for excessive typecasting (ie void**)
HIP_DISABLE_CPP_FUNCTIONS macro can be defined to suppress these wrappers. It is useful for applications which need to obtain decltypes of HIP runtime APIs.
See also
-
template<class T>
static inline hipError_t hipHostMalloc(T **ptr, size_t size, unsigned int flags = hipHostMallocDefault)# : C++ wrapper for hipHostMalloc
Provide an override to automatically typecast the pointer type from void**, and also provide a default for the flags.
HIP_DISABLE_CPP_FUNCTIONS macro can be defined to suppress these wrappers. It is useful for applications which need to obtain decltypes of HIP runtime APIs.
See also