Skip to content

Commit 29d545f

Browse files
committed
[ROCm] Fix CUDA build: guard cub include for C translation units
The ROCm support commit routed all CUDA/HIP includes through internal/cuda_to_hip.h and pulled it into utils.h and internal_types.h, which are included by the C translation units (cli.c, cupdlpx.c, mps_parser.c, presolve.c). On the CUDA path that header included <cub/device/device_reduce.cuh> unconditionally; cub is C++ only, so the C compiler failed with "unknown type name 'namespace'", breaking every CUDA build job (all Linux and Windows toolchains, CUDA 12.4 through 13.1). The HIP path was unaffected because its hipcub include was already guarded with #ifdef __cplusplus. The fix mirrors that guard on the CUDA branch: the cub header is only included for C++ translation units (the .cu device sources that actually use cub::DeviceReduce). The change is entirely within the #else CUDA branch, so the HIP/ROCm device code is unchanged. Authored with assistance from Claude. Test Plan: reproduced and verified the CUDA path locally with the CUDA 12.8 toolkit (gcc 13, ninja), matching the upstream CI configure: ``` cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCUPDLPX_BUILD_TESTS=OFF -DCMAKE_CUDA_ARCHITECTURES=80 cmake --build build --clean-first ``` Before: cc -std=gnu99 -c src/cupdlpx.c fails on cub/device/device_reduce.cuh. After: clean build, links cupdlpx and libcupdlpx.so with 0 errors.
1 parent 9d73c35 commit 29d545f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

internal/cuda_to_hip.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,14 @@ namespace cub = hipcub;
172172
#else // CUDA build
173173

174174
// Standard CUDA headers
175-
#include <cub/device/device_reduce.cuh>
176175
#include <cublas_v2.h>
177176
#include <cuda_runtime.h>
178177
#include <cusparse.h>
179178

179+
// cub is C++ only; C translation units (cli.c, cupdlpx.c, ...) reach this
180+
// header transitively and must not pull it in.
181+
#ifdef __cplusplus
182+
#include <cub/device/device_reduce.cuh>
183+
#endif
184+
180185
#endif // USE_HIP

0 commit comments

Comments
 (0)