Skip to content

Commit af67bf0

Browse files
feat: register ENABLE_MULTI_DEVICE and ENABLE_UCX as CMake options (#3343)
No change of default value (still ON). These were hidden cmake vars before that patch. Fix issue #3289 Signed-off-by: William Tambellini <[email protected]> Co-authored-by: Yuan Tong <[email protected]>
1 parent 75e13f4 commit af67bf0

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

cpp/CMakeLists.txt

+18-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ option(FAST_BUILD "Skip compiling some kernels to accelerate compiling" OFF)
3939
option(FAST_MATH "Compiling in fast math mode" OFF)
4040
option(INDEX_RANGE_CHECK "Compiling with index range checks" OFF)
4141
option(COMPRESS_FATBIN "Compress everything in fatbin" ON)
42+
option(ENABLE_MULTI_DEVICE
43+
"Enable building with multi device support (requires NCCL, MPI,...)" ON)
44+
option(ENABLE_UCX "Enable building with UCX (Uniform Communication X) support"
45+
ON)
4246

4347
# Always use static NVRTC for IP protection reasons.
4448
set(USE_SHARED_NVRTC OFF)
@@ -347,7 +351,6 @@ set(CMAKE_CUDA_RUNTIME_LIBRARY Static)
347351

348352
find_library(RT_LIB rt)
349353

350-
set_ifndef(ENABLE_MULTI_DEVICE 1)
351354
if(ENABLE_MULTI_DEVICE)
352355
# NCCL dependencies
353356
set_ifndef(NCCL_LIB_DIR /usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/)
@@ -438,9 +441,15 @@ endif()
438441

439442
# set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -G")
440443

441-
set(CMAKE_CXX_FLAGS
442-
"${CMAKE_CXX_FLAGS} -DBUILD_SYSTEM=cmake_oss -DENABLE_MULTI_DEVICE=${ENABLE_MULTI_DEVICE}"
443-
)
444+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_SYSTEM=cmake_oss ")
445+
446+
# note: cmake expr generation $<BOOL:${ENABLE_MULTI_DEVICE}> is a build time
447+
# evaluation so hard to debug at cmake time
448+
if(ENABLE_MULTI_DEVICE)
449+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTI_DEVICE=1")
450+
else()
451+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTI_DEVICE=0")
452+
endif()
444453

445454
# Fix linking issue with TRT 10, the detailed description about `--mcmodel` can
446455
# be found in
@@ -653,7 +662,6 @@ endif()
653662

654663
# Defer UCX/UCXX setup until after USE_CXX11_ABI is well defined, as UCXX will
655664
# need to be built to have aligned symbols
656-
set_ifndef(ENABLE_UCX 1)
657665
if(ENABLE_UCX)
658666
# Only enable UCX related features if the system has UCX library
659667
find_package(ucx)
@@ -680,7 +688,11 @@ if(ENABLE_UCX)
680688
NO_DEFAULT_PATH)
681689
endif()
682690
endif()
683-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_UCX=${ENABLE_UCX}")
691+
if(ENABLE_UCX)
692+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_UCX=1")
693+
else()
694+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_UCX=0")
695+
endif()
684696

685697
file(STRINGS "${TRT_INCLUDE_DIR}/NvInferVersion.h" VERSION_STRINGS
686698
REGEX "#define NV_TENSORRT_.*")

cpp/tensorrt_llm/kernels/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function(filter_cuda_archs ARCH SOURCES_VAR)
5959
endif()
6060
endfunction()
6161

62-
if(ENABLE_MULTI_DEVICE EQUAL 0)
62+
if(NOT ENABLE_MULTI_DEVICE)
6363
list(FILTER SRC_CU EXCLUDE REGEX "customAllReduceKernels*.*cu$")
6464
endif()
6565

cpp/tensorrt_llm/kernels/cutlass_kernels/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ function(process_target target_name enable_hopper enable_blackwell)
166166
${target_name} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-psabi>)
167167
endif()
168168

169-
target_compile_options(${target_name}
170-
PRIVATE "-DENABLE_MULTI_DEVICE=${ENABLE_MULTI_DEVICE}")
171169
if(ENABLE_MULTI_DEVICE)
170+
target_compile_options(${target_name} PRIVATE "-DENABLE_MULTI_DEVICE=1")
172171
target_link_libraries(${target_name} PRIVATE ${MPI_C_LIBRARIES})
173172
endif()
174173

cpp/tensorrt_llm/kernels/userbuffers/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# License for the specific language governing permissions and limitations under
1515
# the License.
1616
#
17-
if(ENABLE_MULTI_DEVICE EQUAL 0)
17+
if(NOT ENABLE_MULTI_DEVICE)
1818
add_library(userbuffers_src OBJECT ub_interface.cpp userbuffersManager.cpp)
1919
else()
2020
file(GLOB_RECURSE SRC_CPP *.cpp)

0 commit comments

Comments
 (0)