-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding option to allow spdlog to be compiled. #1232
Adding option to allow spdlog to be compiled. #1232
Conversation
@robertmaynard it's unclear to me whether
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this affect install? Need any changes for that?
Interested to know the impact of setting this when compiling all RAPIDS libraries.
Please add a description with motivation for this change. |
This approach won't work when a consumer of |
@robertmaynard what would an example of the string that we'd use in |
Would like @robertmaynard to approve before merging. |
@harrism, yeah I think the problem with my current change is that the default is going to apply to all the rapids projects, so unless someone manually builds and installs it locally, they won't be able to change the value. Ideally, the consuming libraries would be able to have different settings for this (so, for example, RAFT users could prefer to use the pre-built binary while cudf might still use header-only). At least I think that's what @robertmaynard's previous response is addressing. I've looked at the docs for the |
To defer the selection of the spdlog to consumers we would want the following changes: commit 0bc2a771eb5b009638dd2927166bb4bc52d68b03 (HEAD -> imp-2304-allow_spdlog_compiled)
Author: Robert Maynard <[email protected]>
Date: Wed Mar 29 09:37:36 2023 -0400
Allow consuming project to specify what spdlog to use
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8670576..4fbe8d6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,8 +39,6 @@ rapids_cmake_build_type(Release)
# build options
option(BUILD_TESTS "Configure CMake to build tests" ON)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
-option(RMM_HEADER_ONLY_SPDLOG "Use spdlog header-only library. Compiled version is used otherwise"
- ON)
set(RMM_LOGGING_LEVEL
"INFO"
CACHE STRING "Choose the logging level.")
@@ -82,9 +80,6 @@ endif()
message(STATUS "RMM: Using header-only SPDLOG: ${RMM_HEADER_ONLY_SPDLOG}")
target_link_libraries(rmm INTERFACE rmm::Thrust)
-target_link_libraries(rmm INTERFACE fmt::fmt-header-only)
-target_link_libraries(rmm INTERFACE $<$<BOOL:NOT ${RMM_HEADER_ONLY_SPDLOG}>:spdlog::spdlog>)
-target_link_libraries(rmm INTERFACE $<$<BOOL:${RMM_HEADER_ONLY_SPDLOG}>:spdlog::spdlog_header_only>)
target_link_libraries(rmm INTERFACE dl)
target_compile_features(rmm INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
@@ -142,6 +137,10 @@ set(code_string
if(NOT TARGET rmm::Thrust)
thrust_create_target(rmm::Thrust FROM_OPTIONS)
endif()
+
+option(RMM_HEADER_ONLY_SPDLOG "Use spdlog header-only library. Compiled version is used otherwise" ON)
+mark_as_advanced(RMM_HEADER_ONLY_SPDLOG)
+target_link_libraries(rmm::rmm INTERFACE $<IF:$<BOOL:${RMM_HEADER_ONLY_SPDLOG}>,spdlog::spdlog_header_only,spdlog::spdlog>)
]=])
rapids_export(
diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt
index 9dfb2c53..0d77211b 100644
--- a/benchmarks/CMakeLists.txt
+++ b/benchmarks/CMakeLists.txt
@@ -34,7 +34,7 @@ function(ConfigureBench BENCH_NAME)
RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${RMM_BINARY_DIR}/gbenchmarks>"
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
INSTALL_RPATH "\$ORIGIN/../../../lib")
- target_link_libraries(${BENCH_NAME} benchmark::benchmark pthread rmm)
+ target_link_libraries(${BENCH_NAME} benchmark::benchmark pthread rmm spdlog::spdlog)
target_compile_definitions(${BENCH_NAME}
PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}")
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ecb44a49..4e2e559d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -22,7 +22,7 @@ function(ConfigureTestInternal TEST_NAME)
add_executable(${TEST_NAME} ${ARGN})
target_include_directories(${TEST_NAME} PRIVATE "$<BUILD_INTERFACE:${RMM_SOURCE_DIR}>")
target_link_libraries(${TEST_NAME} GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main
- pthread rmm)
+ pthread rmm spdlog::spdlog)
set_target_properties(
${TEST_NAME}
PROPERTIES POSITION_INDEPENDENT_CODE ON This will allow consumers to do:
I was also curious if rmm tests would benifit from using a pre-compiled spdlog, and in testing on full clean builds with zero cache hits I see using a pre-built spdlog saving me 16sec, so I added those changes to the diff build times:
|
Can this retarget 23.06? I would like to avoid merging changes to spdlog just before rmm’s code freeze. |
Agree. Moving to 23.06 in the project board. |
@bdice I'm certainly not against it |
Related to issue #1222 and also PR #1232. Compared to #1232, this PR might make it able to also have fast builds without precompiling spdlog. I include a table below showing which headers transitively include `rmm/logger.hpp` before and after PR (in debug and release builds). These are the rmm headers used by RAFT. | Header | Before | After | |-----------------------------------------------------|----------------|----------------| | rmm/cuda_device.hpp | debug release | | | rmm/cuda_stream.hpp | debug release | debug | | rmm/cuda_stream_pool.hpp | debug release | debug | | rmm/cuda_stream_view.hpp | debug release | | | rmm/device_buffer.hpp | debug release | | | rmm/device_scalar.hpp | debug release | | | rmm/device_uvector.hpp | debug release | | | rmm/device_vector.hpp | debug release | | | rmm/exec_policy.hpp | debug release | | | rmm/logger.hpp | debug release | debug release | | rmm/mr/device/aligned_resource_adaptor.hpp | debug release | | | rmm/mr/device/arena_memory_resource.hpp | debug release | debug release | | rmm/mr/device/binning_memory_resource.hpp | debug release | debug release | | rmm/mr/device/callback_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_async_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_async_view_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_memory_resource.hpp | debug release | | | rmm/mr/device/device_memory_resource.hpp | debug release | | | rmm/mr/device/failure_callback_resource_adaptor.hpp | debug release | | | rmm/mr/device/fixed_size_memory_resource.hpp | debug release | debug release | | rmm/mr/device/limiting_resource_adaptor.hpp | debug release | | | rmm/mr/device/logging_resource_adaptor.hpp | debug release | debug release | | rmm/mr/device/managed_memory_resource.hpp | debug release | | | rmm/mr/device/owning_wrapper.hpp | debug release | | | rmm/mr/device/per_device_resource.hpp | debug release | | | rmm/mr/device/polymorphic_allocator.hpp | debug release | | | rmm/mr/device/pool_memory_resource.hpp | debug release | debug release | | rmm/mr/device/statistics_resource_adaptor.hpp | debug release | | | rmm/mr/device/thread_safe_resource_adaptor.hpp | debug release | | | rmm/mr/device/thrust_allocator_adaptor.hpp | debug release | | | rmm/mr/device/tracking_resource_adaptor.hpp | debug release | debug release | | rmm/mr/host/host_memory_resource.hpp | | | | rmm/mr/host/new_delete_resource.hpp | | | | rmm/mr/host/pinned_memory_resource.hpp | debug release | | Authors: - Allard Hendriksen (https://github.com/ahendriksen) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: #1241
This change allows the
spdlog
cmake target to be configurable so the user can choose whether it should bespdlog_header_only
or justspdlog
to use the compiled library. Some investigation of RAFT's long compile times showed that we can get a speedup from usingspdlog
's compiled library instead of header-only. We're going to pass this option through RAFT's build as well but would like @robertmaynard's thoughts on whether this is a reasonable approach given RMM is used across RAPIDS.