提交 e435ee1b 编写于 作者: M Megvii Engine Team 提交者: liuqingyi

fix(build): generate nccl.h before calling make src.build

src/Makefile of nccl does not specify dependency between %.cc and
include/nccl.h, leads to a subtle race condition.

We workaround that by explicitly calling make on the nccl.h target
before running the build.

GitOrigin-RevId: d062aa9db02dc48604053a388a6f4f4f91f3e182
上级 d06c215d
...@@ -2,6 +2,7 @@ set(NCCL_DIR ${PROJECT_SOURCE_DIR}/third_party/nccl CACHE STRING "nccl directory ...@@ -2,6 +2,7 @@ set(NCCL_DIR ${PROJECT_SOURCE_DIR}/third_party/nccl CACHE STRING "nccl directory
set(NCCL_BUILD_DIR ${PROJECT_BINARY_DIR}/third_party/nccl/build) set(NCCL_BUILD_DIR ${PROJECT_BINARY_DIR}/third_party/nccl/build)
set(NCCL_LIBS ${NCCL_BUILD_DIR}/lib/libnccl_static.a) set(NCCL_LIBS ${NCCL_BUILD_DIR}/lib/libnccl_static.a)
get_filename_component(NCCL_BUILD_DIR ${NCCL_BUILD_DIR} ABSOLUTE)
get_filename_component(CUDA_HOME ${CMAKE_CUDA_COMPILER} DIRECTORY) get_filename_component(CUDA_HOME ${CMAKE_CUDA_COMPILER} DIRECTORY)
get_filename_component(CUDA_HOME ${CUDA_HOME} DIRECTORY) get_filename_component(CUDA_HOME ${CUDA_HOME} DIRECTORY)
...@@ -13,6 +14,7 @@ endif() ...@@ -13,6 +14,7 @@ endif()
add_custom_command( add_custom_command(
OUTPUT ${NCCL_LIBS} OUTPUT ${NCCL_LIBS}
COMMAND ${MAKE_COMMAND} -C src ${NCCL_BUILD_DIR}/include/nccl.h BUILDDIR=${NCCL_BUILD_DIR}
COMMAND ${MAKE_COMMAND} src.build NVCC_GENCODE=${MEGRAY_CUDA_GENCODE} BUILDDIR=${NCCL_BUILD_DIR} CUDA_HOME=${CUDA_HOME} COMMAND ${MAKE_COMMAND} src.build NVCC_GENCODE=${MEGRAY_CUDA_GENCODE} BUILDDIR=${NCCL_BUILD_DIR} CUDA_HOME=${CUDA_HOME}
WORKING_DIRECTORY ${NCCL_DIR} WORKING_DIRECTORY ${NCCL_DIR}
VERBATIM VERBATIM
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册