Skip to content

Fix CUB compilation errors with CUDA 12.x by removing namespace wrapping#237

Open
ZhuYanzhen1 wants to merge 1 commit into
limbo018:masterfrom
ZhuYanzhen1:master
Open

Fix CUB compilation errors with CUDA 12.x by removing namespace wrapping#237
ZhuYanzhen1 wants to merge 1 commit into
limbo018:masterfrom
ZhuYanzhen1:master

Conversation

@ZhuYanzhen1
Copy link
Copy Markdown
Contributor

Problem

When compiling DREAMPlace with CUDA 12.x, the build fails with numerous errors from CUB headers such as agent_three_way_partition.cuh and tuning_three_way_partition.cuh. Example errors include:

error: name followed by "::" must be a class or namespace name
  struct accumulator_pack_base_t<OffsetT, typename cuda::std::enable_if<sizeof(OffsetT) == 4>::type>
                                                         ^

Root Cause

The issue stems from two sources:

  1. Namespace wrapping incompatibility: The project's utils_cub.cuh header wraps CUB includes with CUB_NS_PREFIX/CUB_NS_POSTFIX macros to place CUB inside the DreamPlace namespace. This technique was compatible with older CUB versions but breaks with CUDA 11+ where CUB uses the cuda::std namespace internally, which cannot be wrapped.

  2. Potential version conflict: For CUDA 11+, the system CUB should be used exclusively, but the build configuration did not properly exclude the bundled old CUB (v1.8.0 from 2018) from include paths.

Solution

  1. Modified dreamplace/ops/utility/src/utils_cub.cuh: Added conditional compilation to skip namespace wrapping for CUDA 11+. For CUDA 11+, we include the system CUB directly and create a namespace alias for compatibility. For CUDA 10 and below, we continue using the bundled CUB with namespace wrapping.

  2. Modified CMakeLists.txt: Enhanced the CUB configuration to explicitly exclude the bundled CUB from CMAKE_PREFIX_PATH when using CUDA 11+, preventing accidental inclusion of the old CUB headers.

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

Successfully merging this pull request may close these issues.

1 participant