From 4cef1070b285a58c8315fb4f1c4ceb6fa7947409 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Sun, 9 Oct 2016 16:30:46 +0530 Subject: [PATCH] Add back deprecated hipHostAlloc, hipMallocHost, hipFreeHost Change-Id: Ib8494078c852b07e1958c3acc21fa1866542122c [ROCm/clr commit: b59659f0c76ead0359241780799251b40dc740a4] --- .../include/hip/hcc_detail/hip_runtime_api.h | 36 +++++++++++++++++++ .../include/hip/nvcc_detail/hip_runtime_api.h | 15 ++++++++ projects/clr/hipamd/src/hip_memory.cpp | 15 ++++++++ 3 files changed, 66 insertions(+) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h index ee4ff2fd2b..1243934d01 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h @@ -781,6 +781,18 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) */ hipError_t hipMalloc(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 + * + * @return #hipSuccess, #hipErrorMemoryAllocation + * + * @deprecated use hipHostMalloc() instead + */ +hipError_t hipMallocHost(void** ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead"))) ; + /** * @brief Allocate device accessible page locked host memory * @@ -794,6 +806,19 @@ hipError_t hipMalloc(void** ptr, size_t size) ; */ hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags) ; +/** + * @brief Allocate device accessible page locked host memory [Deprecated] + * + * @param[out] ptr Pointer to the allocated host pinned memory + * @param[in] size Requested memory size + * @param[in] flags Type of host memory allocation + * + * @return #hipSuccess, #hipErrorMemoryAllocation + * + * @deprecated use hipHostMalloc() instead + */ +hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags) __attribute__((deprecated("use hipHostMalloc instead"))) ; + /** * @brief Get Device pointer from Host Pointer allocated through hipHostMalloc * @@ -892,6 +917,17 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height */ hipError_t hipFree(void* ptr); +/** + * @brief Free memory allocated by the hcc hip host memory allocation API. [Deprecated] + * + * @param[in] ptr Pointer to memory to be freed + * @return #hipSuccess, + * #hipErrorInvalidValue (if pointer is invalid, including device pointers allocated with hipMalloc) + + * @deprecated use hipHostFree() instead + */ +hipError_t hipFreeHost(void* ptr) __attribute__((deprecated("use hipHostFree instead"))); + /** * @brief Free memory allocated by the hcc hip host memory allocation API * This API performs an implicit hipDeviceSynchronize() call. diff --git a/projects/clr/hipamd/include/hip/nvcc_detail/hip_runtime_api.h b/projects/clr/hipamd/include/hip/nvcc_detail/hip_runtime_api.h index 4088064f87..db9f3a0775 100644 --- a/projects/clr/hipamd/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/nvcc_detail/hip_runtime_api.h @@ -185,6 +185,16 @@ inline static hipError_t hipFree(void* ptr) { return hipCUDAErrorTohipError(cudaFree(ptr)); } +inline static hipError_t hipMallocHost(void** ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead"))); +inline static hipError_t hipMallocHost(void** ptr, size_t size) { + return hipCUDAErrorTohipError(cudaMallocHost(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){ + return hipCUDAErrorTohipError(cudaHostAlloc(ptr, size, flags)); +} + inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags){ return hipCUDAErrorTohipError(cudaHostAlloc(ptr, size, flags)); } @@ -205,6 +215,11 @@ inline static hipError_t hipHostUnregister(void* ptr){ return hipCUDAErrorTohipError(cudaHostUnregister(ptr)); } +inline static hipError_t hipFreeHost(void* ptr) __attribute__((deprecated("use hipHostFree instead"))); +inline static hipError_t hipFreeHost(void* ptr) { + return hipCUDAErrorTohipError(cudaFreeHost(ptr)); +} + inline static hipError_t hipHostFree(void* ptr) { return hipCUDAErrorTohipError(cudaFreeHost(ptr)); } diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 6a869269d3..5443c43344 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -174,6 +174,16 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) return ihipLogStatus(hip_status); } +hipError_t hipMallocHost(void** ptr, size_t sizeBytes) +{ + return hipHostMalloc(ptr, sizeBytes, 0); +} + +hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) +{ + return hipHostMalloc(ptr, sizeBytes, flags); +}; + // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { @@ -930,6 +940,11 @@ hipError_t hipHostFree(void* ptr) return ihipLogStatus(hipStatus); }; +hipError_t hipFreeHost(void* ptr) +{ + return hipHostFree(ptr); +} + hipError_t hipFreeArray(hipArray* array) { HIP_INIT_API(array);