diff --git a/CHANGELOG.md b/CHANGELOG.md index 5073eee03..9934a740e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - PR #546 Remove CUDA driver linking and correct NVTX macro. - PR #569 Correct `device_scalar::set_value` to pass host value by reference to avoid copying from invalid value - PR #559 Fix `align_down` to only change unaligned values. +- PR #577 Fix CMake `LOGGING_LEVEL` issue which caused verbose logging / performance regression. # RMM 0.15.0 (26 Aug 2020) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8266ec9c..faad6dd00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,21 +87,6 @@ if(PER_THREAD_DEFAULT_STREAM) add_compile_definitions(CUDA_API_PER_THREAD_DEFAULT_STREAM) endif(PER_THREAD_DEFAULT_STREAM) -################################################################################################### -# add gtest - -if(BUILD_TESTS) - include(CTest) - add_subdirectory(tests) -endif(BUILD_TESTS) - -################################################################################################### -# add google benchmark - -if(BUILD_BENCHMARKS) - add_subdirectory(benchmarks) -endif(BUILD_BENCHMARKS) - ################################################################################################### # library targets @@ -129,20 +114,28 @@ endif(CUDA_STATIC_RUNTIME) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) ################################################################################################### -# Set a default logging level if none was specified +# Set logging level. Must go before including gtests and benchmarks. -set(DEFAULT_LOGGING_LEVEL "INFO") +set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.") +# Set the possible values of build type for cmake-gui +set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS + "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") +message(STATUS "RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.") -if(NOT LOGGING_LEVEL) - message(STATUS "Setting logging level to '${DEFAULT_LOGGING_LEVEL}' since none specified.") - set(LOGGING_LEVEL "${DEFAULT_LOGGING_LEVEL}" CACHE - STRING "Choose the logging level." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE LOGGING_LEVEL PROPERTY STRINGS - "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") -else() - message(STATUS "Setting logging level to '${LOGGING_LEVEL}'") -endif(NOT LOGGING_LEVEL) +################################################################################################### +# add gtest + +if(BUILD_TESTS) + include(CTest) + add_subdirectory(tests) +endif(BUILD_TESTS) + +################################################################################################### +# add google benchmark + +if(BUILD_BENCHMARKS) + add_subdirectory(benchmarks) +endif(BUILD_BENCHMARKS) ################################################################################################### # install targets diff --git a/README.md b/README.md index fd68fd21e..4b0d494e0 100644 --- a/README.md +++ b/README.md @@ -407,15 +407,15 @@ information can show when errors occur, when additional memory is allocated from etc. The default log file is `rmm_log.txt` in the current working directory, but the environment variable `RMM_DEBUG_LOG_FILE` can be set to specify the path and file name. -There is a CMake configuration variable `LOGGING_LEVEL`, which can be set to enable compilation of -more detailed logging. The default is `INFO`. Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, -`ERROR`, `CRITICAL`. +There is a CMake configuration variable `RMM_LOGGING_LEVEL`, which can be set to enable compilation +of more detailed logging. The default is `INFO`. Available levels are `TRACE`, `DEBUG`, `INFO`, +`WARN`, `ERROR`, `CRITICAL` and `OFF`. The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library. Note that to see logging below the `INFO` level, the C++ application must also call `rmm::logger().set_level()`, e.g. to enable all levels of logging down to `TRACE`, call -`rmm::logger().set_level(spdlog::level::trace)`. +`rmm::logger().set_level(spdlog::level::trace)` (and compile with `-DRMM_LOGGING_LEVEL=TRACE`). Note that debug logging is different from the CSV memory allocation logging provided by `rmm::mr::logging_resource_adapter`. The latter is for logging a history of allocation / diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 1a91b6dd2..01ee5f1ed 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -33,7 +33,7 @@ function(ConfigureBench CMAKE_BENCH_NAME CMAKE_BENCH_SRC) RUNTIME_OUTPUT_DIRECTORY "${RMM_BINARY_DIR}/gbenchmarks") target_compile_definitions(${CMAKE_BENCH_NAME} PUBLIC - SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${LOGGING_LEVEL}) + "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") endfunction(ConfigureBench) ################################################################################################### diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 3e6629a89..433b5fb96 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -58,12 +58,14 @@ struct logger_wrapper { { logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); logger_.flush_on(spdlog::level::warn); +#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM logger_.info("----- RMM LOG BEGIN [PTDS ENABLED] -----"); #else logger_.info("----- RMM LOG BEGIN [PTDS DISABLED] -----"); #endif logger_.flush(); +#endif } }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e8fb9c918..fb02ae0cb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,7 +38,7 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC) RUNTIME_OUTPUT_DIRECTORY "${RMM_BINARY_DIR}/gtests") target_compile_definitions(${CMAKE_TEST_NAME} PUBLIC - SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${LOGGING_LEVEL}) + "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) endfunction(ConfigureTest)