Skip to content

Commit

Permalink
[CMake] Auto check environment oneCCL. (#104)
Browse files Browse the repository at this point in the history
Signed-off-by: Duyi-Wang <[email protected]>
  • Loading branch information
Duyi-Wang authored Nov 30, 2023
1 parent afdf3de commit 50d980b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ endif()
include("cmake/mklml.cmake")
include("cmake/onednn.cmake")
include("cmake/xdnn.cmake")
include("cmake/oneccl.cmake")
include(GNUInstallDirs)

set(DEPEND_LIST "onednn" "xdnn_lib")

include_directories(${CMAKE_SOURCE_DIR}/3rdparty/)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/build/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/include)
include_directories(${CMAKE_SOURCE_DIR}/3rdparty/xdnn)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src/kernels)
Expand All @@ -73,13 +73,27 @@ include_directories(${CMAKE_SOURCE_DIR}/src/common)

link_directories(${CMAKE_SOURCE_DIR}/src/kernels)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/onednn/build/src)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/lib)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/lib/prov)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/xdnn)

set(3RDPART_LIB_LIST "mpicxx" "mpi" "rt" "dl" "ccl" "dnnl" "numa")
set(DEPEND_LIST "oneccl" "onednn" "xdnn_lib")
find_package(oneCCL REQUIRED)

if(MPI_FOUND AND oneCCL_FOUND)
set(MPI_LIBS MPI::MPI_CXX)

message(STATUS "oneCCL & MPI found. Using found oneCCL instead of building from source.")
else()
message(STATUS "oneCCL or MPI not found. Build oneCCL from source.")

include("cmake/oneccl.cmake")
list(APPEND DEPEND_LIST "oneccl")
set(MPI_LIBS "mpicxx" "mpi" "rt" "dl")

include_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/include)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/lib)
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/oneccl/build/_install/lib/prov)
endif()

set(3RDPART_LIB_LIST ${MPI_LIBS} "ccl" "dnnl" "numa")
option(BUILD_WITH_SHARED_LIBS "Build with shared libraries" OFF)
if(BUILD_WITH_SHARED_LIBS)
message(STATUS "Notice: Building with shared libraries.")
Expand Down
2 changes: 1 addition & 1 deletion cmake/oneccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ExternalProject_Add(oneccl
GIT_TAG 2021.10
SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/oneccl
BINARY_DIR ${CMAKE_SOURCE_DIR}/3rdparty/oneccl
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory "build" && ${CMAKE_COMMAND} -E chdir "build" ${CMAKE_COMMAND} -DONEDNN_LIBRARY_TYPE=STATIC -DONEDNN_BUILD_TESTS=OFF -DONEDNN_BUILD_EXAMPLES=OFF ..
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory "build" && ${CMAKE_COMMAND} -E chdir "build" ${CMAKE_COMMAND} -DBUILD_EXAMPLES=OFF -DBUILD_FT=OFF -DBUILD_REG_TESTS=OFF -DENABLE_MPI_TESTS=OFF ..
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "build" make -j install
INSTALL_COMMAND ""
TEST_COMMAND ""
Expand Down
2 changes: 0 additions & 2 deletions src/pytorch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ add_library(xfastertransformer_pt SHARED ${TORCH_SRCS})

target_include_directories(xfastertransformer_pt PUBLIC ${PyTorch_INCLUDE_DIR})

set(MPI_LIBS "mpicxx" "mpi" "rt" "dl")

# Link against LibTorch and others
target_link_libraries(xfastertransformer_pt
PRIVATE OpenMP::OpenMP_CXX
Expand Down

0 comments on commit 50d980b

Please sign in to comment.