Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling hip code on CUDA 12.1 fails #3222

Closed
torrance opened this issue May 4, 2023 · 3 comments
Closed

Compiling hip code on CUDA 12.1 fails #3222

torrance opened this issue May 4, 2023 · 3 comments

Comments

@torrance
Copy link

torrance commented May 4, 2023

CUDA's Texture Reference Management has been deprecated for some time, and it appears in CUDA 12.1 (.0?) it has been removed.

However, nvidia_hip_runtime_api.h still contains references to types and functions such as cudaBindTexture and cudaGetTextureAlignmentOffset. These functions are present in hip-5.5, and whilst they are marked as deprecated, their presence stops compilation.

For the meantime I have manually deleted the offending lines from my own hip installation (!) but I'd like to know the correct way to compile hip on a system using CUDA 12.1.

@mikaelkuisma1
Copy link

I had exactly the same problem, and I can also confirm that removing incompatible methods from nvidia_hip_runtime_api.h helped.

@torrance
Copy link
Author

Spreading some love for the CUDA backend - the following patch will allow CUDA 12+ to compile.

diff --git a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h
index 0c492b7c..7dbfedd5 100644
--- a/include/hip/nvidia_detail/nvidia_hip_runtime_api.h
+++ b/include/hip/nvidia_detail/nvidia_hip_runtime_api.h
@@ -2773,6 +2773,7 @@ inline static hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t
     return hipCUDAErrorTohipError(cudaFuncSetCacheConfig(func, cacheConfig));
 }

+#if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ < 12)
 __HIP_DEPRECATED inline static hipError_t hipBindTexture(size_t* offset,
                                                          struct textureReference* tex,
                                                          const void* devPtr,
@@ -2780,12 +2781,15 @@ __HIP_DEPRECATED inline static hipError_t hipBindTexture(size_t* offset,
                                                          size_t size __dparm(UINT_MAX)) {
     return hipCUDAErrorTohipError(cudaBindTexture(offset, tex, devPtr, desc, size));
 }
+#endif

+#if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ < 12)
 __HIP_DEPRECATED inline static hipError_t hipBindTexture2D(
     size_t* offset, struct textureReference* tex, const void* devPtr,
     const hipChannelFormatDesc* desc, size_t width, size_t height, size_t pitch) {
     return hipCUDAErrorTohipError(cudaBindTexture2D(offset, tex, devPtr, desc, width, height, pitch));
 }
+#endif

 inline static hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w,
                                                         hipChannelFormatKind f) {
@@ -2818,10 +2822,12 @@ inline static hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDe
     return hipCUDAErrorTohipError(cudaGetTextureObjectResourceDesc( pResDesc, textureObject));
 }

+#if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ < 12)
 __HIP_DEPRECATED inline static hipError_t hipGetTextureAlignmentOffset(
     size_t* offset, const struct textureReference* texref) {
     return hipCUDAErrorTohipError(cudaGetTextureAlignmentOffset(offset,texref));
 }
+#endif

 inline static hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array)
 {
@@ -3067,6 +3073,7 @@ inline static hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
                                                                  blockSize, dynamicSMemSize, flags));
 }

+#if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ < 12)
 template <class T, int dim, enum cudaTextureReadMode readMode>
 inline static hipError_t hipBindTexture(size_t* offset, const struct texture<T, dim, readMode>& tex,
                                         const void* devPtr, size_t size = UINT_MAX) {
@@ -3109,6 +3116,7 @@ __HIP_DEPRECATED inline static hipError_t hipBindTextureToArray(
     struct texture<T, dim, readMode>& tex, hipArray_const_t array) {
     return hipCUDAErrorTohipError(cudaBindTextureToArray(tex, array));
 }
+#endif

 template <class T>
 inline static hipChannelFormatDesc hipCreateChannelDesc() {

@satyanveshd
Copy link
Contributor

Closing this as the fix is already present in the develop branch in github here. Thanks.
https://github.com/ROCm-Developer-Tools/clr/blob/develop/hipamd/include/hip/nvidia_detail/nvidia_hip_runtime_api.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants