From 4e15dc142cd46e4ab30c189f8970e0fad4d8c7d6 Mon Sep 17 00:00:00 2001 From: Dingming Wu Date: Fri, 9 Jan 2026 06:45:47 -0800 Subject: [PATCH] Update device.h for hip_bfloat16 inclusion guard (#2107) * Update device.h for hip_bfloat16 inclusion guard Prevents other files in rocm include the old hip/hip_bfloat16.h, which is guarded by _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BFLOAT16_H_ and _HIP_BFLOAT16_H_ * Update device.h to handle old hip_bfloat16.h Added a workaround for old hip_bfloat16.h header usage. [ROCm/rccl commit: 8e4dbfdf37de787c16b65fb2512b090354bce2d8] --- projects/rccl/src/include/device.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/projects/rccl/src/include/device.h b/projects/rccl/src/include/device.h index 6944f3921b..f722f1fe21 100644 --- a/projects/rccl/src/include/device.h +++ b/projects/rccl/src/include/device.h @@ -12,9 +12,16 @@ #include "nccl.h" #include "rccl_float8.h" #if ROCM_VERSION >= 60000 - // hip_bf16.h should be used from ROCm 6.0 - #include - typedef __hip_bfloat16 hip_bfloat16; + // This is a workaround for the fact that the old hip_bfloat16.h header file may still be used by some rocm files. + // The _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BFLOAT16_H_ and _HIP_BFLOAT16_H_ macros are defined in the old hip_bfloat16.h header + #if !defined(_HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BFLOAT16_H_) && !defined(_HIP_BFLOAT16_H_) + #define _HIP_INCLUDE_HIP_AMD_DETAIL_HIP_BFLOAT16_H_ + #define _HIP_BFLOAT16_H_ + #include + typedef __hip_bfloat16 hip_bfloat16; + #else + #error "RCCL is not using the correct hip_bf16.h file. Please make sure that the correct header is included!" + #endif #else #include #endif