enable ROCm on latest XGBoost
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
function (run_doxygen)
|
||||
function(run_doxygen)
|
||||
find_package(Doxygen REQUIRED)
|
||||
|
||||
if (NOT DOXYGEN_DOT_FOUND)
|
||||
if(NOT DOXYGEN_DOT_FOUND)
|
||||
message(FATAL_ERROR "Command `dot` not found. Please install graphviz.")
|
||||
endif (NOT DOXYGEN_DOT_FOUND)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${xgboost_SOURCE_DIR}/doc/Doxyfile.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target( doc_doxygen ALL
|
||||
add_custom_target(
|
||||
doc_doxygen ALL
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generate C APIs documentation."
|
||||
VERBATIM)
|
||||
endfunction (run_doxygen)
|
||||
endfunction()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function (find_prefetch_intrinsics)
|
||||
function(find_prefetch_intrinsics)
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("
|
||||
#include <xmmintrin.h>
|
||||
@@ -19,4 +19,4 @@ function (find_prefetch_intrinsics)
|
||||
" XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
set(XGBOOST_MM_PREFETCH_PRESENT ${XGBOOST_MM_PREFETCH_PRESENT} PARENT_SCOPE)
|
||||
set(XGBOOST_BUILTIN_PREFETCH_PRESENT ${XGBOOST_BUILTIN_PREFETCH_PRESENT} PARENT_SCOPE)
|
||||
endfunction (find_prefetch_intrinsics)
|
||||
endfunction()
|
||||
|
||||
@@ -12,9 +12,9 @@ macro(enable_sanitizer sanitizer)
|
||||
elseif(${sanitizer} MATCHES "thread")
|
||||
find_package(TSan)
|
||||
set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=thread")
|
||||
if (TSan_FOUND)
|
||||
if(TSan_FOUND)
|
||||
link_libraries(${TSan_LIBRARY})
|
||||
endif (TSan_FOUND)
|
||||
endif()
|
||||
|
||||
elseif(${sanitizer} MATCHES "leak")
|
||||
find_package(LSan)
|
||||
@@ -33,16 +33,16 @@ macro(enable_sanitizers SANITIZERS)
|
||||
# Check sanitizers compatibility.
|
||||
# Idealy, we should use if(san IN_LIST SANITIZERS) ... endif()
|
||||
# But I haven't figure out how to make it work.
|
||||
foreach ( _san ${SANITIZERS} )
|
||||
foreach( _san ${SANITIZERS} )
|
||||
string(TOLOWER ${_san} _san)
|
||||
if (_san MATCHES "thread")
|
||||
if (${_use_other_sanitizers})
|
||||
if(_san MATCHES "thread")
|
||||
if(${_use_other_sanitizers})
|
||||
message(FATAL_ERROR
|
||||
"thread sanitizer is not compatible with ${_san} sanitizer.")
|
||||
endif()
|
||||
set(_use_thread_sanitizer 1)
|
||||
else ()
|
||||
if (${_use_thread_sanitizer})
|
||||
else()
|
||||
if(${_use_thread_sanitizer})
|
||||
message(FATAL_ERROR
|
||||
"${_san} sanitizer is not compatible with thread sanitizer.")
|
||||
endif()
|
||||
|
||||
@@ -11,7 +11,7 @@ function(auto_source_group SOURCES)
|
||||
|
||||
source_group("${GROUP}" FILES "${FILE}")
|
||||
endforeach()
|
||||
endfunction(auto_source_group)
|
||||
endfunction()
|
||||
|
||||
# Force static runtime for MSVC
|
||||
function(msvc_use_static_runtime)
|
||||
@@ -50,7 +50,7 @@ function(msvc_use_static_runtime)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction(msvc_use_static_runtime)
|
||||
endfunction()
|
||||
|
||||
# Set output directory of target, ignoring debug or release
|
||||
function(set_output_directory target dir)
|
||||
@@ -70,17 +70,17 @@ function(set_output_directory target dir)
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${dir}
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${dir}
|
||||
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${dir})
|
||||
endfunction(set_output_directory)
|
||||
endfunction()
|
||||
|
||||
# Set a default build type to release if none was specified
|
||||
function(set_default_configuration_release)
|
||||
if(CMAKE_CONFIGURATION_TYPES STREQUAL "Debug;Release;MinSizeRel;RelWithDebInfo") # multiconfig generator?
|
||||
set(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "" FORCE)
|
||||
elseif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
|
||||
endif()
|
||||
endfunction(set_default_configuration_release)
|
||||
elseif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Generate nvcc compiler flags given a list of architectures
|
||||
# Also generates PTX for the most recent architecture for forwards compatibility
|
||||
@@ -90,9 +90,9 @@ function(format_gencode_flags flags out)
|
||||
endif()
|
||||
# Set up architecture flags
|
||||
if(NOT flags)
|
||||
if (CUDA_VERSION VERSION_GREATER_EQUAL "11.8")
|
||||
if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8")
|
||||
set(flags "50;60;70;80;90")
|
||||
elseif (CUDA_VERSION VERSION_GREATER_EQUAL "11.0")
|
||||
elseif(CUDA_VERSION VERSION_GREATER_EQUAL "11.0")
|
||||
set(flags "50;60;70;80")
|
||||
elseif(CUDA_VERSION VERSION_GREATER_EQUAL "10.0")
|
||||
set(flags "35;50;60;70")
|
||||
@@ -103,7 +103,7 @@ function(format_gencode_flags flags out)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
cmake_policy(SET CMP0104 NEW)
|
||||
list(GET flags -1 latest_arch)
|
||||
list(TRANSFORM flags APPEND "-real")
|
||||
@@ -121,8 +121,8 @@ function(format_gencode_flags flags out)
|
||||
set(${out} "${${out}}--generate-code=arch=compute_${ver},code=compute_${ver};")
|
||||
set(${out} "${${out}}" PARENT_SCOPE)
|
||||
message(STATUS "CUDA GEN_CODE: ${GEN_CODE}")
|
||||
endif (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
endfunction(format_gencode_flags flags)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Set CUDA related flags to target. Must be used after code `format_gencode_flags`.
|
||||
function(xgboost_set_cuda_flags target)
|
||||
@@ -133,35 +133,35 @@ function(xgboost_set_cuda_flags target)
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${OpenMP_CXX_FLAGS}>
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-Xfatbin=-compress-all>)
|
||||
|
||||
if (USE_PER_THREAD_DEFAULT_STREAM)
|
||||
if(USE_PER_THREAD_DEFAULT_STREAM)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:--default-stream per-thread>)
|
||||
endif (USE_PER_THREAD_DEFAULT_STREAM)
|
||||
endif()
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
set_property(TARGET ${target} PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES})
|
||||
endif (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
endif()
|
||||
|
||||
if (FORCE_COLORED_OUTPUT)
|
||||
if (FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND
|
||||
if(FORCE_COLORED_OUTPUT)
|
||||
if(FORCE_COLORED_OUTPUT AND (CMAKE_GENERATOR STREQUAL "Ninja") AND
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-fdiagnostics-color=always>)
|
||||
endif()
|
||||
endif (FORCE_COLORED_OUTPUT)
|
||||
endif()
|
||||
|
||||
if (USE_DEVICE_DEBUG)
|
||||
if(USE_DEVICE_DEBUG)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<AND:$<CONFIG:DEBUG>,$<COMPILE_LANGUAGE:CUDA>>:-G;-src-in-ptx>)
|
||||
else (USE_DEVICE_DEBUG)
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-lineinfo>)
|
||||
endif (USE_DEVICE_DEBUG)
|
||||
endif()
|
||||
|
||||
if (USE_NVTX)
|
||||
if(USE_NVTX)
|
||||
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NVTX=1)
|
||||
endif (USE_NVTX)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_CUDA=1)
|
||||
target_include_directories(
|
||||
@@ -169,17 +169,17 @@ function(xgboost_set_cuda_flags target)
|
||||
${xgboost_SOURCE_DIR}/gputreeshap
|
||||
${CUDAToolkit_INCLUDE_DIRS})
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/utf-8>)
|
||||
endif (MSVC)
|
||||
endif()
|
||||
|
||||
set_target_properties(${target} PROPERTIES
|
||||
CUDA_STANDARD 17
|
||||
CUDA_STANDARD_REQUIRED ON
|
||||
CUDA_SEPARABLE_COMPILATION OFF
|
||||
CUDA_RUNTIME_LIBRARY Static)
|
||||
endfunction(xgboost_set_cuda_flags)
|
||||
endfunction()
|
||||
|
||||
# Set HIP related flags to target.
|
||||
function(xgboost_set_hip_flags target)
|
||||
@@ -199,16 +199,16 @@ function(xgboost_set_hip_flags target)
|
||||
endfunction(xgboost_set_hip_flags)
|
||||
|
||||
macro(xgboost_link_nccl target)
|
||||
if (BUILD_STATIC_LIB)
|
||||
if(BUILD_STATIC_LIB)
|
||||
target_include_directories(${target} PUBLIC ${NCCL_INCLUDE_DIR})
|
||||
target_compile_definitions(${target} PUBLIC -DXGBOOST_USE_NCCL=1)
|
||||
target_link_libraries(${target} PUBLIC ${NCCL_LIBRARY})
|
||||
else ()
|
||||
else()
|
||||
target_include_directories(${target} PRIVATE ${NCCL_INCLUDE_DIR})
|
||||
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_NCCL=1)
|
||||
target_link_libraries(${target} PRIVATE ${NCCL_LIBRARY})
|
||||
endif (BUILD_STATIC_LIB)
|
||||
endmacro(xgboost_link_nccl)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# compile options
|
||||
macro(xgboost_target_properties target)
|
||||
@@ -217,110 +217,106 @@ macro(xgboost_target_properties target)
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if (HIDE_CXX_SYMBOLS)
|
||||
if(HIDE_CXX_SYMBOLS)
|
||||
#-- Hide all C++ symbols
|
||||
set_target_properties(${target} PROPERTIES
|
||||
C_VISIBILITY_PRESET hidden
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
CUDA_VISIBILITY_PRESET hidden
|
||||
)
|
||||
endif (HIDE_CXX_SYMBOLS)
|
||||
endif()
|
||||
|
||||
if (ENABLE_ALL_WARNINGS)
|
||||
if(ENABLE_ALL_WARNINGS)
|
||||
target_compile_options(${target} PUBLIC
|
||||
$<IF:$<COMPILE_LANGUAGE:CUDA>,
|
||||
-Xcompiler=-Wall -Xcompiler=-Wextra -Xcompiler=-Wno-expansion-to-defined,
|
||||
-Wall -Wextra -Wno-expansion-to-defined>
|
||||
)
|
||||
target_compile_options(${target} PUBLIC
|
||||
$<IF:$<COMPILE_LANGUAGE:HIP>,
|
||||
-Wall -Wextra >
|
||||
)
|
||||
endif(ENABLE_ALL_WARNINGS)
|
||||
endif()
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:CXX>>:/MP>
|
||||
$<$<AND:$<NOT:$<CXX_COMPILER_ID:MSVC>>,$<COMPILE_LANGUAGE:CXX>>:-funroll-loops>)
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
)
|
||||
endif (MSVC)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND MINGW)
|
||||
if(WIN32 AND MINGW)
|
||||
target_compile_options(${target} PUBLIC -static-libstdc++)
|
||||
endif (WIN32 AND MINGW)
|
||||
endmacro(xgboost_target_properties)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Custom definitions used in xgboost.
|
||||
macro(xgboost_target_defs target)
|
||||
if (NOT ${target} STREQUAL "dmlc") # skip dmlc core for custom logging.
|
||||
if(NOT ${target} STREQUAL "dmlc") # skip dmlc core for custom logging.
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
-DDMLC_LOG_CUSTOMIZE=1
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:_MWAITXINTRIN_H_INCLUDED>)
|
||||
endif ()
|
||||
if (USE_DEBUG_OUTPUT)
|
||||
endif()
|
||||
if(USE_DEBUG_OUTPUT)
|
||||
target_compile_definitions(${target} PRIVATE -DXGBOOST_USE_DEBUG_OUTPUT=1)
|
||||
endif (USE_DEBUG_OUTPUT)
|
||||
if (XGBOOST_MM_PREFETCH_PRESENT)
|
||||
endif()
|
||||
if(XGBOOST_MM_PREFETCH_PRESENT)
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
-DXGBOOST_MM_PREFETCH_PRESENT=1)
|
||||
endif(XGBOOST_MM_PREFETCH_PRESENT)
|
||||
if (XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
endif()
|
||||
if(XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
-DXGBOOST_BUILTIN_PREFETCH_PRESENT=1)
|
||||
endif (XGBOOST_BUILTIN_PREFETCH_PRESENT)
|
||||
endif()
|
||||
|
||||
if (PLUGIN_RMM)
|
||||
if(PLUGIN_RMM)
|
||||
target_compile_definitions(objxgboost PUBLIC -DXGBOOST_USE_RMM=1)
|
||||
endif (PLUGIN_RMM)
|
||||
endmacro(xgboost_target_defs)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# handles dependencies
|
||||
macro(xgboost_target_link_libraries target)
|
||||
if (BUILD_STATIC_LIB)
|
||||
if(BUILD_STATIC_LIB)
|
||||
target_link_libraries(${target} PUBLIC Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
|
||||
else()
|
||||
target_link_libraries(${target} PRIVATE Threads::Threads ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif (BUILD_STATIC_LIB)
|
||||
endif()
|
||||
|
||||
if (USE_OPENMP)
|
||||
if (BUILD_STATIC_LIB)
|
||||
if(USE_OPENMP)
|
||||
if(BUILD_STATIC_LIB)
|
||||
target_link_libraries(${target} PUBLIC OpenMP::OpenMP_CXX)
|
||||
else()
|
||||
target_link_libraries(${target} PRIVATE OpenMP::OpenMP_CXX)
|
||||
endif (BUILD_STATIC_LIB)
|
||||
endif (USE_OPENMP)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
xgboost_set_cuda_flags(${target})
|
||||
target_link_libraries(${target} PUBLIC CUDA::cudart_static)
|
||||
endif (USE_CUDA)
|
||||
endif()
|
||||
|
||||
if (USE_HIP)
|
||||
xgboost_set_hip_flags(${target})
|
||||
endif (USE_HIP)
|
||||
|
||||
if (PLUGIN_RMM)
|
||||
if(PLUGIN_RMM)
|
||||
target_link_libraries(${target} PRIVATE rmm::rmm)
|
||||
endif (PLUGIN_RMM)
|
||||
endif()
|
||||
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
xgboost_link_nccl(${target})
|
||||
endif (USE_NCCL)
|
||||
endif()
|
||||
|
||||
if (USE_NVTX)
|
||||
if(USE_NVTX)
|
||||
target_link_libraries(${target} PRIVATE CUDA::nvToolsExt)
|
||||
endif (USE_NVTX)
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
if(MINGW)
|
||||
target_link_libraries(${target} PRIVATE wsock32 ws2_32)
|
||||
endif (MINGW)
|
||||
endmacro(xgboost_target_link_libraries)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function (write_version)
|
||||
function(write_version)
|
||||
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
|
||||
configure_file(
|
||||
${xgboost_SOURCE_DIR}/cmake/version_config.h.in
|
||||
${xgboost_SOURCE_DIR}/include/xgboost/version_config.h @ONLY)
|
||||
endfunction (write_version)
|
||||
endfunction()
|
||||
|
||||
@@ -66,7 +66,7 @@ function(create_rlib_for_msvc)
|
||||
execute_process(COMMAND ${DLLTOOL_EXE}
|
||||
"--input-def" "${CMAKE_CURRENT_BINARY_DIR}/R.def"
|
||||
"--output-lib" "${CMAKE_CURRENT_BINARY_DIR}/R.lib")
|
||||
endfunction(create_rlib_for_msvc)
|
||||
endfunction()
|
||||
|
||||
|
||||
# detection for OSX
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if (NVML_LIBRARY)
|
||||
if(NVML_LIBRARY)
|
||||
unset(NVML_LIBRARY CACHE)
|
||||
endif(NVML_LIBRARY)
|
||||
endif()
|
||||
|
||||
set(NVML_LIB_NAME nvml)
|
||||
|
||||
|
||||
@@ -35,20 +35,20 @@
|
||||
#
|
||||
# This module assumes that the user has already called find_package(CUDA)
|
||||
|
||||
if (NCCL_LIBRARY)
|
||||
if(NCCL_LIBRARY)
|
||||
if(NOT USE_NCCL_LIB_PATH)
|
||||
# Don't cache NCCL_LIBRARY to enable switching between static and shared.
|
||||
unset(NCCL_LIBRARY CACHE)
|
||||
endif(NOT USE_NCCL_LIB_PATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_SHARED_NCCL)
|
||||
if(BUILD_WITH_SHARED_NCCL)
|
||||
# libnccl.so
|
||||
set(NCCL_LIB_NAME nccl)
|
||||
else ()
|
||||
else()
|
||||
# libnccl_static.a
|
||||
set(NCCL_LIB_NAME nccl_static)
|
||||
endif (BUILD_WITH_SHARED_NCCL)
|
||||
endif()
|
||||
|
||||
find_path(NCCL_INCLUDE_DIR
|
||||
NAMES nccl.h
|
||||
|
||||
Reference in New Issue
Block a user