-
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
Create logger wrapper around spdlog that can be easily reused in other libraries #1722
Changes from 86 commits
27b6cab
aa92779
812b2bc
956fa3f
3a6d49b
c9ec22c
2573e02
9173108
d89bb82
07dfcc5
8194997
8589c53
f4f8350
7da8d70
54abd70
627d369
39fe1b2
4a6cc9d
91fab68
2f58cc5
2c021ec
eb93bf2
7b449bc
9f85459
946573a
19556a6
4a0dd6b
bec1a9f
0be4979
0d6b118
adae837
b422af6
f7ae2be
6a3028c
afc4dcf
4714322
08cb91b
aaf4b7c
7c9134c
8fd9036
e6ec9f4
62efe44
0c08a3f
ee33b25
28e7c21
55b3926
56ab836
a690620
19c82ef
9faf1b3
b9b14f5
39b3da8
f299fd2
15cdb0c
3e8e286
440d7c1
704c8e2
5d11768
ebdd741
b8f22ec
1fdee97
b372c69
6f6603a
b102d62
1b3add3
6379a72
4ef279d
eb6ef9f
00f5577
cd71f30
073e179
853b8a1
92d5e21
1ca5e8d
7bd2086
7928515
6d6a4e4
cc2c1f9
0985006
3ca0f10
46e650b
b450cfb
dd906e0
aed8320
f5830c7
7020b9b
e068335
4520ccb
0abd94c
fe19b2b
2ffc827
2731a53
0a7b337
4f6b98c
02212f1
4e7eba7
2fcfc70
49368cf
46786c6
8f6d03c
f88e65a
82443bd
483bdfc
316b1f9
a6bc3a7
3cf1074
155c934
b175d68
9619e51
fa3b95e
e1fc36a
c5f56fd
15697c7
d12bb93
2d84f2d
e7b2d92
b6af231
82f925a
6dfc38a
cae6784
6bbc174
a21dedc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,16 +34,21 @@ 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} PRIVATE benchmark::benchmark pthread rmm) | ||
target_compile_definitions(${BENCH_NAME} | ||
PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") | ||
PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since each logger produced by rapids-logger gets its own set of logger macros controls, rmm's logging level is now decoupled from spdlog's. |
||
|
||
if(PER_THREAD_DEFAULT_STREAM) | ||
target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) | ||
endif() | ||
|
||
target_compile_options(${BENCH_NAME} PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wall -Werror | ||
-Wno-unknown-pragmas>) | ||
|
||
if(TARGET rmm_bench_logger) | ||
target_link_libraries(${BENCH_NAME} PRIVATE rmm_bench_logger) | ||
endif() | ||
|
||
if(DISABLE_DEPRECATION_WARNING) | ||
target_compile_options( | ||
${BENCH_NAME} PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-deprecated-declarations>) | ||
|
@@ -58,6 +63,13 @@ function(ConfigureBench BENCH_NAME) | |
EXCLUDE_FROM_ALL) | ||
endfunction(ConfigureBench) | ||
|
||
# Create an object library for the logger so that we don't have to recompile it. This is not | ||
# necessary if logging is unsupported since then the header-only implementation is sufficient. | ||
if(RMM_SUPPORTS_LOGGING) | ||
add_library(rmm_bench_logger OBJECT) | ||
target_link_libraries(rmm_bench_logger PRIVATE rmm_logger_impl) | ||
endif() | ||
|
||
# random allocations benchmark | ||
ConfigureBench(RANDOM_ALLOCATIONS_BENCH random_allocations/random_allocations.cpp) | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,15 +12,39 @@ | |||||
# the License. | ||||||
# ============================================================================= | ||||||
|
||||||
# Use CPM to find or clone speedlog | ||||||
# Use CPM to find or clone speedlog TODO: The logic here should be upstreamed into rapids-logger and | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
# probably removed from rapids-cmake. Note that it is not possible to build with two different modes | ||||||
# for different projects in the same build environment, so this functionality must be kept | ||||||
# independent of the rapids_make_logger function. Alternatively, we could update the cpm calls for | ||||||
# spdlog to not promote targets to global scope and instead allow each project to find and configure | ||||||
# spdlog independently. | ||||||
vyasr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
function(find_and_configure_spdlog) | ||||||
|
||||||
include(${rapids-cmake-dir}/cpm/spdlog.cmake) | ||||||
rapids_cpm_spdlog( | ||||||
FMT_OPTION "EXTERNAL_FMT_HO" | ||||||
INSTALL_EXPORT_SET rmm-exports | ||||||
BUILD_EXPORT_SET rmm-exports) | ||||||
|
||||||
if(RMM_SPDLOG_DYNAMIC) | ||||||
rapids_cpm_spdlog( | ||||||
FMT_OPTION "BUNDLED" | ||||||
INSTALL_EXPORT_SET rmm-exports | ||||||
BUILD_EXPORT_SET rmm-exports OPTIONS "SPDLOG_BUILD_SHARED ON" "BUILD_SHARED_LIBS ON") | ||||||
else() | ||||||
# For static spdlog usage assume that we want to hide as many symbols as possible, so do not use | ||||||
# pre-built libraries. It's quick enough to build that there is no real benefit to supporting | ||||||
vyasr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# the alternative. | ||||||
set(CPM_DOWNLOAD_spdlog ON) | ||||||
rapids_cpm_spdlog( | ||||||
# TODO: Is this safe to set up for all projects? Do we have to worry about the fmt patch | ||||||
vyasr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
# currently in rapids-cmake? We should never be compiling files using spdlog under nvcc | ||||||
# anymore. | ||||||
FMT_OPTION "BUNDLED" | ||||||
INSTALL_EXPORT_SET rmm-exports | ||||||
BUILD_EXPORT_SET rmm-exports OPTIONS "SPDLOG_BUILD_SHARED OFF" "BUILD_SHARED_LIBS OFF" | ||||||
EXCLUDE_FROM_ALL) | ||||||
# Can't make both cmake-format and cmake-lint happy here. | ||||||
# cmake-format: off | ||||||
set_target_properties(spdlog PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON) | ||||||
# cmake-format: on | ||||||
endif() | ||||||
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||||||
endfunction() | ||||||
|
||||||
find_and_configure_spdlog() |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The functions removed here are now embedded directly in the logger's log method. |
This file was deleted.
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.
This allows local builds to choose to use a dynamic spdlog and also use one that already exists on the system. If this is off, we currently always download for static linking under the assumption that we prioritize symbol hiding.