HIP icon indicating copy to clipboard operation
HIP copied to clipboard

conflicting types with cuda_runtime.h

Open sthibaul opened this issue 2 years ago • 7 comments

Hello,

I'd like to use HIP to drive an AMD GPU, while using CUDA to drive a CUDA GPU. But the headers conflict

Samuel

$ cat test.c
#include <cuda_runtime.h>
#include <hip/hip_runtime.h>
int main(void) {
}
$ hipconfig -C
 -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I/opt/rocm-5.1.0/hip/include -I/opt/rocm-5.1.0/llvm/bin/../lib/clang/14.0.0 -I/opt/rocm-5.1.0/hsa/include
$ gcc test.c -o test $(hipconfig -C)
In file included from /opt/rocm-5.1.0/hip/include/hip/amd_detail/amd_channel_descriptor.h:28,
                 from /opt/rocm-5.1.0/hip/include/hip/channel_descriptor.h:32,
                 from /opt/rocm-5.1.0/hip/include/hip/texture_types.h:38,
                 from /opt/rocm-5.1.0/hip/include/hip/hip_runtime_api.h:474,
                 from /opt/rocm-5.1.0/hip/include/hip/hip_runtime.h:113,
                 from test.c:2:
/opt/rocm-5.1.0/hip/include/hip/amd_detail/amd_hip_vector_types.h:1388:22: error: conflicting types for ‘uchar1’
 1388 | __MAKE_VECTOR_TYPE__(uchar, unsigned char);
      |                      ^~~~~
/opt/rocm-5.1.0/hip/include/hip/amd_detail/amd_hip_vector_types.h:1370:11: note: in definition of macro ‘__MAKE_VECTOR_TYPE__’
 1370 |         } CUDA_name##1;\
      |           ^~~~~~~~~
In file included from /usr/include/driver_types.h:59,
                 from /usr/include/builtin_types.h:59,
                 from /usr/include/cuda_runtime.h:91,
                 from test.c:1:
/usr/include/vector_types.h:362:42: note: previous declaration of ‘uchar1’ was here
  362 | typedef __device_builtin__ struct uchar1 uchar1;
      |                                          ^~~~~~
In file included from /opt/rocm-5.1.0/hip/include/hip/amd_detail/amd_channel_descriptor.h:28,
                 from /opt/rocm-5.1.0/hip/include/hip/channel_descriptor.h:32,
                 from /opt/rocm-5.1.0/hip/include/hip/texture_types.h:38,
                 from /opt/rocm-5.1.0/hip/include/hip/hip_runtime_api.h:474,
                 from /opt/rocm-5.1.0/hip/include/hip/hip_runtime.h:113,
                 from test.c:2:
[... same for uchar2, uchar3, ..., ‘struct textureReference’, ‘struct surfaceReference’, ‘struct dim3’, dim3]

sthibaul avatar Jun 01 '22 07:06 sthibaul

for information, the reason why we need to include both cuda_runtime.h and hip_runtime.h is that in our runtime layer we have a data transfer manager and it wants to manage both cudaStream_t and hipStream_t in the same list of transfers to be performed

sthibaul avatar Jun 02 '22 14:06 sthibaul

@sthibaul, I would like to understand your development environment a little more.

Are you trying to run some tasks on AMD GPU and some on Nvidia GPU simultaneously? Hence you need both header files to be present?

SarbojitAMD avatar Jun 24 '22 06:06 SarbojitAMD

Yes, that is it.

sthibaul avatar Jun 24 '22 06:06 sthibaul

@sthibaul Apologies for the lack of response. Can you please test with latest ROCm 6.0.2 (HIP 6.0.32831)? If resolved, please close ticket. Thanks!

ppanchad-amd avatar Apr 04 '24 19:04 ppanchad-amd

I don't have 6.0.2 readily available, but 6.0.0 (1.0.0.60000-91~20.04 from https://repo.radeon.com/rocm/apt/debian) still has the issue.

sthibaul avatar Apr 04 '24 21:04 sthibaul

Hi, I'm also interested in this issue, for the same reason: building an application that can offload operations to both NVIDIA and AMD GPUs.

The only way we found to do this is to split the CUDA-related and HIP/ROCm-related code in different source files, compile them separately, and link (statically or dynamically) the object files.

If there were a way to include both runtimes in the same source file I would also be very interested to use it!

fwyzard avatar Apr 04 '24 21:04 fwyzard