Skip to content

Commit

Permalink
Check -parallel-jobs before use (#1451)
Browse files Browse the repository at this point in the history
`-parallel-jobs` is not always available, such as upstream LLVM.
  • Loading branch information
shiltian authored Dec 11, 2024
1 parent ad4c36d commit 8e9fcf1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ if (HAVE_KERNARG_PRELOAD)
message(STATUS "Kernarg preloading to SGPR enabled")
endif()

check_cxx_compiler_flag("-parallel-jobs=12" HAVE_PARALLEL_JOBS)
if (HAVE_PARALLEL_JOBS)
message(STATUS "Parallel jobs enabled")
endif()

## Disable building MSCCL++ if the build environment is invalid
## Currently MSCCL++ is supported only on gfx942
if (ENABLE_MSCCLPP AND NOT ("gfx942" IN_LIST GPU_TARGETS OR "gfx942:xnack-" IN_LIST GPU_TARGETS OR "gfx942:xnack+" IN_LIST GPU_TARGETS))
Expand Down Expand Up @@ -727,7 +732,9 @@ if(LL128_ENABLED)
endif()

## Set RCCL compile options
target_compile_options(rccl PRIVATE -parallel-jobs=12)
if (HAVE_PARALLEL_JOBS)
target_compile_options(rccl PRIVATE -parallel-jobs=12)
endif()
target_compile_options(rccl PRIVATE -Werror=uninitialized -Werror=sometimes-uninitialized)
target_compile_options(rccl PRIVATE -Wno-format-nonliteral)
target_compile_options(rccl PRIVATE -fgpu-rdc) # Generate relocatable device code (required for extern __shared__)
Expand Down Expand Up @@ -805,12 +812,14 @@ else()
endif()
endif()
## Reserve 16GB for each linker job. Limit max number of linker jobs to 16
math(EXPR num_linker_jobs "(${memory_in_gb} + 15) / 16")
if (${num_linker_jobs} GREATER_EQUAL "16")
set(num_linker_jobs "16")
if (HAVE_PARALLEL_JOBS)
math(EXPR num_linker_jobs "(${memory_in_gb} + 15) / 16")
if (${num_linker_jobs} GREATER_EQUAL "16")
set(num_linker_jobs "16")
endif()
message(STATUS "Use ${num_linker_jobs} jobs for linking")
target_link_options(rccl PRIVATE -parallel-jobs=${num_linker_jobs}) # Use multiple threads to link
endif()
message(STATUS "Use ${num_linker_jobs} jobs for linking")
target_link_options(rccl PRIVATE -parallel-jobs=${num_linker_jobs}) # Use multiple threads to link
if(BUILD_ADDRESS_SANITIZER)
target_link_options(rccl PRIVATE -fuse-ld=lld)
endif()
Expand Down

0 comments on commit 8e9fcf1

Please sign in to comment.