[fed] Split up federated test CMake file. (#10566)
- Collect all federated test files into the same directory. - Independently list the files.
This commit is contained in:
parent
5f910cd4ff
commit
89da9f9741
@ -1,3 +1,6 @@
|
||||
# The testxgboost executable is created in the top level CMakeLists. Most of the
|
||||
# properties and compilation flags are already set. We just need to add source files and
|
||||
# link gtest here.
|
||||
if(USE_DMLC_GTEST)
|
||||
if(NOT TARGET gtest)
|
||||
message(FATAL_ERROR "USE_DMLC_GTEST=ON but dmlc-core didn't bundle gtest")
|
||||
@ -6,6 +9,7 @@ if(USE_DMLC_GTEST)
|
||||
else()
|
||||
find_package(GTest REQUIRED)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE TEST_SOURCES "*.cc")
|
||||
|
||||
if(USE_CUDA)
|
||||
@ -13,6 +17,10 @@ if(USE_CUDA)
|
||||
list(APPEND TEST_SOURCES ${CUDA_TEST_SOURCES})
|
||||
endif()
|
||||
|
||||
# We will add them back later to separate the definition.
|
||||
file(GLOB_RECURSE FEDERATED_TEST_SOURCES "plugin/federated/*.*")
|
||||
list(REMOVE_ITEM TEST_SOURCES ${FEDERATED_TEST_SOURCES})
|
||||
|
||||
file(GLOB_RECURSE SYCL_TEST_SOURCES "plugin/test_sycl_*.cc")
|
||||
list(REMOVE_ITEM TEST_SOURCES ${SYCL_TEST_SOURCES})
|
||||
|
||||
@ -48,14 +56,14 @@ if(PLUGIN_SYCL)
|
||||
endif()
|
||||
|
||||
if(PLUGIN_FEDERATED)
|
||||
target_include_directories(testxgboost PRIVATE ${xgboost_SOURCE_DIR}/plugin/federated)
|
||||
target_link_libraries(testxgboost PRIVATE federated_client)
|
||||
else()
|
||||
file(GLOB_RECURSE FEDERATED_TEST_SOURCES "plugin/*_federated_*.*")
|
||||
list(REMOVE_ITEM TEST_SOURCES ${FEDERATED_TEST_SOURCES})
|
||||
add_subdirectory(${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated)
|
||||
endif()
|
||||
|
||||
target_sources(testxgboost PRIVATE ${TEST_SOURCES} ${xgboost_SOURCE_DIR}/plugin/example/custom_obj.cc)
|
||||
target_sources(
|
||||
testxgboost PRIVATE
|
||||
${TEST_SOURCES}
|
||||
${xgboost_SOURCE_DIR}/plugin/example/custom_obj.cc
|
||||
)
|
||||
|
||||
if(USE_CUDA AND PLUGIN_RMM)
|
||||
target_include_directories(testxgboost PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
@ -63,7 +71,6 @@ endif()
|
||||
|
||||
target_include_directories(testxgboost
|
||||
PRIVATE
|
||||
${GTEST_INCLUDE_DIRS}
|
||||
${xgboost_SOURCE_DIR}/include
|
||||
${xgboost_SOURCE_DIR}/dmlc-core/include)
|
||||
target_link_libraries(testxgboost
|
||||
|
||||
20
tests/cpp/plugin/federated/CMakeLists.txt
Normal file
20
tests/cpp/plugin/federated/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
target_sources(
|
||||
testxgboost PRIVATE
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_coll.cc
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_comm.cc
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_comm_group.cc
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_tracker.cc
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_learner.cc
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_data.cc
|
||||
)
|
||||
|
||||
if(USE_CUDA)
|
||||
target_sources(
|
||||
testxgboost PRIVATE
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_coll.cu
|
||||
${xgboost_SOURCE_DIR}/tests/cpp/plugin/federated/test_federated_comm_group.cu
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(testxgboost PRIVATE ${xgboost_SOURCE_DIR}/plugin/federated)
|
||||
target_link_libraries(testxgboost PRIVATE federated_client)
|
||||
@ -1,15 +1,13 @@
|
||||
/*!
|
||||
* Copyright 2023 XGBoost contributors
|
||||
/**
|
||||
* Copyright 2023-2024, XGBoost contributors
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/data.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "../../../src/collective/communicator-inl.h"
|
||||
#include "../filesystem.h"
|
||||
#include "../helpers.h"
|
||||
#include "federated/test_worker.h"
|
||||
#include "../../../../src/collective/communicator-inl.h"
|
||||
#include "../../filesystem.h"
|
||||
#include "../../helpers.h"
|
||||
#include "test_worker.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
/**
|
||||
* Copyright 2023-2024, XGBoost contributors
|
||||
*
|
||||
* Some other tests for federated learning are in the main test suite (test_learner.cc),
|
||||
* gaurded by the `XGBOOST_USE_FEDERATED`.
|
||||
* Some other tests for federated learning are in the main test suite (test_learner.cc).
|
||||
*/
|
||||
#include <dmlc/parameter.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/data.h>
|
||||
#include <xgboost/objective.h>
|
||||
|
||||
#include "../../../src/collective/communicator-inl.h"
|
||||
#include "../../../src/common/linalg_op.h" // for begin, end
|
||||
#include "../helpers.h"
|
||||
#include "../objective_helpers.h" // for MakeObjNamesForTest, ObjTestNameGenerator
|
||||
#include "federated/test_worker.h"
|
||||
#include "../../../../src/collective/communicator-inl.h"
|
||||
#include "../../../../src/common/linalg_op.h" // for begin, end
|
||||
#include "../../helpers.h"
|
||||
#include "../../objective_helpers.h" // for MakeObjNamesForTest, ObjTestNameGenerator
|
||||
#include "test_worker.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace {
|
||||
Loading…
x
Reference in New Issue
Block a user