Skip to content

Commit

Permalink
[CI] Make oneapi_plugin a CMake target
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Jul 21, 2020
1 parent aa0c55f commit 28af682
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ if (USE_OPENMP)
find_package(OpenMP REQUIRED)
endif (USE_OPENMP)

add_library(objxgboost OBJECT)

# core xgboost
add_subdirectory(${xgboost_SOURCE_DIR}/src)

Expand Down Expand Up @@ -174,12 +172,6 @@ endif (R_LIB)
# Plugin
add_subdirectory(${xgboost_SOURCE_DIR}/plugin)

#-- DPC++ support
if (PLUGIN_UPDATER_ONEAPI)
set_source_files_properties(${PLUGINS_SOURCES_ONEAPI} PROPERTIES COMPILE_FLAGS -fsycl)
endif (PLUGIN_UPDATER_ONEAPI)
#-- End of DPC++ support

#-- library
if (BUILD_STATIC_LIB)
add_library(xgboost STATIC)
Expand Down
29 changes: 21 additions & 8 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ if (PLUGIN_DENSE_PARSER)
endif (PLUGIN_DENSE_PARSER)

if (PLUGIN_UPDATER_ONEAPI)

set(PLUGINS_SOURCES_ONEAPI
add_library(oneapi_plugin OBJECT
${xgboost_SOURCE_DIR}/plugin/updater_oneapi/regression_obj_oneapi.cc
${xgboost_SOURCE_DIR}/plugin/updater_oneapi/predictor_oneapi.cc)

set(PLUGINS_SOURCES_ONEAPI ${PLUGINS_SOURCES_ONEAPI} PARENT_SCOPE)

target_sources(objxgboost PRIVATE ${PLUGINS_SOURCES_ONEAPI})
target_compile_definitions(objxgboost PRIVATE -DXGBOOST_USE_ONEAPI=1)
target_link_libraries(objxgboost PUBLIC -fsycl)
target_include_directories(oneapi_plugin
PRIVATE
${xgboost_SOURCE_DIR}/include
${xgboost_SOURCE_DIR}/dmlc-core/include
${xgboost_SOURCE_DIR}/rabit/include)
target_compile_definitions(oneapi_plugin PUBLIC -DXGBOOST_USE_ONEAPI=1)
target_link_libraries(oneapi_plugin PUBLIC -fsycl)
set_target_properties(oneapi_plugin PROPERTIES
COMPILE_FLAGS -fsycl
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON)
if (USE_OPENMP)
find_package(OpenMP REQUIRED)
target_link_libraries(oneapi_plugin PUBLIC OpenMP::OpenMP_CXX)
endif (USE_OPENMP)
# Get compilation and link flags of oneapi_plugin and propagate to objxgboost
target_link_libraries(objxgboost PUBLIC oneapi_plugin)
# Add all objects of oneapi_plugin to objxgboost
target_sources(objxgboost INTERFACE $<TARGET_OBJECTS:oneapi_plugin>)
endif (PLUGIN_UPDATER_ONEAPI)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ list(REMOVE_ITEM CPU_SOURCES ${xgboost_SOURCE_DIR}/src/cli_main.cc)

#-- Object library
# Object library is necessary for jvm-package, which creates its own shared library.
add_library(objxgboost OBJECT)
target_sources(objxgboost PRIVATE ${CPU_SOURCES})
if (USE_CUDA)
file(GLOB_RECURSE CUDA_SOURCES *.cu *.cuh)
Expand Down

0 comments on commit 28af682

Please sign in to comment.