From ab1dabe61ba903dbae341408cab3ca6bd9c9d1a5 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 2 May 2018 11:56:37 +0530 Subject: [PATCH] Fix texture 3D for HIP/NVCC [ROCm/hip commit: 9de5f23d54fcb2ba528837af057210f775730c12] --- .../include/hip/hcc_detail/hip_runtime_api.h | 4 ++-- .../include/hip/nvcc_detail/hip_runtime_api.h | 19 ++++++++++++++++++- projects/hip/src/hip_memory.cpp | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 0bed1ea239..8becab3c9c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1481,7 +1481,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, si size_t height __dparm(0), unsigned int flags __dparm(hipArrayDefault)); hipError_t hipArrayCreate(hipArray** pHandle, const HIP_ARRAY_DESCRIPTOR* pAllocateArray); -hipError_t hipArray3DCreate(hipArray_t* array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray); +hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray); hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent); @@ -1507,7 +1507,7 @@ hipError_t hipFreeArray(hipArray* array); * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree */ -hipError_t hipMalloc3DArray(hipArray_t* array, const struct hipChannelFormatDesc* desc, +hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* desc, struct hipExtent extent, unsigned int flags); /** * @brief Copies data between host and device. diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index d391c31db8..7f64845fbe 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -150,13 +150,20 @@ typedef CUfunction hipFunction_t; typedef CUdeviceptr hipDeviceptr_t; typedef struct cudaArray hipArray; typedef struct cudaArray* hipArray_const_t; +typedef cudaMemcpy3DParms hipMemcpy3DParms; +//#define hipMemcpy3DParms cudaMemcpy3DParms #define hipArrayDefault cudaArrayDefault typedef cudaTextureObject_t hipTextureObject_t; typedef cudaSurfaceObject_t hipSurfaceObject_t; -#define hipTextureType2D cudaTextureType2D; +#define hipTextureType2D cudaTextureType2D +#define hipTextureType3D cudaTextureType3D #define hipDeviceMapHost cudaDeviceMapHost +#define hipExtent cudaExtent +#define make_hipExtent make_cudaExtent +#define make_hipPos make_cudaPos +#define make_hipPitchedPtr make_cudaPitchedPtr // Flags that can be used with hipStreamCreateWithFlags #define hipStreamDefault cudaStreamDefault #define hipStreamNonBlocking cudaStreamNonBlocking @@ -399,6 +406,11 @@ inline static hipError_t hipMallocArray(hipArray** array, const struct hipChanne return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); } +inline static hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* desc, + struct hipExtent extent, unsigned int flags) { + return hipCUDAErrorTohipError(cudaMalloc3DArray(array, desc, extent, flags)); +} + inline static hipError_t hipFreeArray(hipArray* array) { return hipCUDAErrorTohipError(cudaFreeArray(array)); } @@ -531,6 +543,11 @@ inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, cudaMemcpy2D(dst, dpitch, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); } +inline static hipError_t hipMemcpy3D(const struct hipMemcpy3DParms *p) +{ + return hipCUDAErrorTohipError(cudaMemcpy3D(p)); +} + inline static 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) { diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index fbbba027de..3219dac3db 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -641,7 +641,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, si return ihipLogStatus(hip_status); } -hipError_t hipArray3DCreate(hipArray_t* array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { +hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { HIP_INIT_SPECIAL_API((TRACE_MEM), array, pAllocateArray); hipError_t hip_status = hipSuccess; @@ -764,7 +764,7 @@ hipError_t hipArray3DCreate(hipArray_t* array, const HIP_ARRAY_DESCRIPTOR* pAllo return ihipLogStatus(hip_status); } -hipError_t hipMalloc3DArray(hipArray_t* array, const struct hipChannelFormatDesc* desc, +hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* desc, struct hipExtent extent, unsigned int flags) {