Added new Memory API's (#1399)
Added new memory API's hipMemAllocPitch, hipMemAllocHost, hipMemsetD16, hipMemsetD16Async, hipMemsetD8Async Modified to support all scenarios hipMemcpyParam2DAsync, hipMemcpyParam2D.
This commit is contained in:
@@ -1115,6 +1115,21 @@ hipError_t hipExtMallocWithFlags(void** ptr, size_t sizeBytes, unsigned int flag
|
||||
DEPRECATED("use hipHostMalloc instead")
|
||||
hipError_t hipMallocHost(void** ptr, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocate pinned host memory [Deprecated]
|
||||
*
|
||||
* @param[out] ptr Pointer to the allocated host pinned memory
|
||||
* @param[in] size Requested memory size
|
||||
*
|
||||
* If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
|
||||
*
|
||||
* @return #hipSuccess, #hipErrorMemoryAllocation
|
||||
*
|
||||
* @deprecated use hipHostMalloc() instead
|
||||
*/
|
||||
DEPRECATED("use hipHostMalloc instead")
|
||||
hipError_t hipMemAllocHost(void** ptr, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocate device accessible page locked host memory
|
||||
*
|
||||
@@ -1250,6 +1265,30 @@ hipError_t hipHostUnregister(void* hostPtr);
|
||||
|
||||
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
|
||||
*
|
||||
* @param[out] dptr Pointer to the allocated device memory
|
||||
* @param[out] pitch Pitch for allocation (in bytes)
|
||||
* @param[in] width Requested pitched allocation width (in bytes)
|
||||
* @param[in] height Requested pitched allocation height
|
||||
*
|
||||
* If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned.
|
||||
* The intended usage of pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array.
|
||||
* Given the row and column of an array element of type T, the address is computed as:
|
||||
* T* pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column;
|
||||
*
|
||||
* @return Error code
|
||||
*
|
||||
* @see hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D,
|
||||
* hipMalloc3DArray, hipHostMalloc
|
||||
*/
|
||||
|
||||
hipError_t hipMemAllocPitch(hipDeviceptr_t* dptr, size_t* pitch, size_t widthInBytes, size_t height, unsigned int elementSizeBytes);
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated by the hcc hip memory allocation API.
|
||||
* This API performs an implicit hipDeviceSynchronize() call.
|
||||
@@ -1708,6 +1747,51 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes);
|
||||
*/
|
||||
hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes);
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param[out] dst Data ptr to be filled
|
||||
* @param[in] constant value to be set
|
||||
* @param[in] sizeBytes Data size in bytes
|
||||
* @param[in] stream - Stream identifier
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
|
||||
*/
|
||||
hipError_t hipMemsetD8Async(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes, hipStream_t stream __dparm(0));
|
||||
|
||||
/**
|
||||
* @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant
|
||||
* short value value.
|
||||
*
|
||||
* @param[out] dst Data ptr to be filled
|
||||
* @param[in] constant value to be set
|
||||
* @param[in] sizeBytes Data size in bytes
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
|
||||
*/
|
||||
hipError_t hipMemsetD16(hipDeviceptr_t dest, unsigned short value, size_t sizeBytes);
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
* @param[out] dst Data ptr to be filled
|
||||
* @param[in] constant value to be set
|
||||
* @param[in] sizeBytes Data size in bytes
|
||||
* @param[in] stream - Stream identifier
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized
|
||||
*/
|
||||
hipError_t hipMemsetD16Async(hipDeviceptr_t dest, unsigned short value, size_t sizeBytes, hipStream_t stream __dparm(0));
|
||||
|
||||
/**
|
||||
* @brief Fills the memory area pointed to by dest with the constant integer
|
||||
* value for specified number of times.
|
||||
|
||||
@@ -459,6 +459,10 @@ inline static hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width,
|
||||
return hipCUDAErrorTohipError(cudaMallocPitch(ptr, pitch, width, height));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemAllocPitch(hipDeviceptr_t* dptr,size_t* pitch,size_t widthInBytes,size_t height,unsigned int elementSizeBytes){
|
||||
return hipCUResultTohipError(cuMemAllocPitch(dptr,pitch,widthInBytes,height,elementSizeBytes));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent) {
|
||||
return hipCUDAErrorTohipError(cudaMalloc3D(pitchedDevPtr, extent));
|
||||
}
|
||||
@@ -471,6 +475,12 @@ inline static hipError_t hipMallocHost(void** ptr, size_t size) {
|
||||
return hipCUDAErrorTohipError(cudaMallocHost(ptr, size));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemAllocHost(void** ptr, size_t size)
|
||||
__attribute__((deprecated("use hipHostMalloc instead")));
|
||||
inline static hipError_t hipMemAllocHost(void** ptr, size_t size) {
|
||||
return hipCUResultTohipError(cuMemAllocHost(ptr, size));
|
||||
}
|
||||
|
||||
inline static hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags)
|
||||
__attribute__((deprecated("use hipHostMalloc instead")));
|
||||
inline static hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags) {
|
||||
@@ -761,6 +771,20 @@ inline static hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, s
|
||||
return hipCUResultTohipError(cuMemsetD8(dest, value, sizeBytes));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemsetD8Async(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes,
|
||||
hipStream_t stream __dparm(0)) {
|
||||
return hipCUResultTohipError(cuMemsetD8Async(dest, value, sizeBytes, stream));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemsetD16(hipDeviceptr_t dest, unsigned short value, size_t sizeBytes) {
|
||||
return hipCUResultTohipError(cuMemsetD16(dest, value, sizeBytes));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemsetD16Async(hipDeviceptr_t dest, unsigned short value, size_t sizeBytes,
|
||||
hipStream_t stream __dparm(0)) {
|
||||
return hipCUResultTohipError(cuMemsetD16Async(dest, value, sizeBytes, stream));
|
||||
}
|
||||
|
||||
inline static hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height) {
|
||||
return hipCUDAErrorTohipError(cudaMemset2D(dst, pitch, value, width, height));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user