From 9bbe482710883a718702d46d57b07766093d81b7 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Mon, 11 Oct 2021 23:17:34 +0530 Subject: [PATCH 1/4] use cuda-sanitizer in ctest -T memcheck --- cpp/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 2841352fc18..bb4eb0ac7cb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -97,6 +97,10 @@ rapids_find_package(CUDAToolkit REQUIRED INSTALL_EXPORT_SET cudf-exports) include(cmake/Modules/ConfigureCUDA.cmake) # set other CUDA compilation flags +# ctest cuda memcheck +set(MEMORYCHECK_COMMAND /usr/local/cuda-11.2/bin/compute-sanitizer) +set(MEMORYCHECK_TYPE CudaSanitizer) +set(CUDA_SANITIZER_COMMAND_OPTIONS "--tool memcheck") ################################################################################################### # - dependencies ---------------------------------------------------------------------------------- From 3716aec59b86de193c57610283e3ab93c7620392 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Mon, 11 Oct 2021 23:18:27 +0530 Subject: [PATCH 2/4] add environment variable GTEST_CUDF_RMM_MODE to gtest rmm mode export GTEST_CUDF_RMM_MODE=cuda ninja rebuild_cache ctest [-T memcheck] --- cpp/tests/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 5d104dec8dd..945285753e6 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -17,12 +17,16 @@ ################################################################################################### # - compiler function ----------------------------------------------------------------------------- +if(DEFINED ENV{GTEST_CUDF_RMM_MODE}) + set(GTEST_CUDF_RMM_MODE "--rmm_mode=$ENV{GTEST_CUDF_RMM_MODE}") +endif() + function(ConfigureTest CMAKE_TEST_NAME ) add_executable(${CMAKE_TEST_NAME} ${ARGN}) set_target_properties(${CMAKE_TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$") target_link_libraries(${CMAKE_TEST_NAME} PRIVATE cudftestutil GTest::gmock_main GTest::gtest_main) - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) + add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME} ${GTEST_CUDF_RMM_MODE} COMMAND_EXPAND_LISTS) endfunction() ################################################################################################### @@ -385,7 +389,7 @@ ConfigureTest(STRINGS_TEST ################################################################################################### # - structs test ---------------------------------------------------------------------------------- -ConfigureTest(STRUCTS_TEST +ConfigureTest(STRUCTS_TEST structs/structs_column_tests.cpp structs/utilities_tests.cpp ) From c9120a925914d5b4b95e8e3698966b925453fc01 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Mon, 11 Oct 2021 23:29:05 +0530 Subject: [PATCH 3/4] find path of compute-sanitizer --- cpp/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index bb4eb0ac7cb..250ee226ef9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -98,7 +98,8 @@ rapids_find_package(CUDAToolkit REQUIRED include(cmake/Modules/ConfigureCUDA.cmake) # set other CUDA compilation flags # ctest cuda memcheck -set(MEMORYCHECK_COMMAND /usr/local/cuda-11.2/bin/compute-sanitizer) +find_program(CUDA_SANITIZER compute-sanitizer) +set(MEMORYCHECK_COMMAND ${CUDA_SANITIZER}) set(MEMORYCHECK_TYPE CudaSanitizer) set(CUDA_SANITIZER_COMMAND_OPTIONS "--tool memcheck") From 2e46e85d1631324e870f490b866a71127deb5ba5 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Wed, 13 Oct 2021 10:31:47 +0530 Subject: [PATCH 4/4] move env GTEST_CUDF_RMM_MODE to gtest fixture --- cpp/include/cudf_test/base_fixture.hpp | 10 ++++++++-- cpp/tests/CMakeLists.txt | 6 +----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index 6f69dc19cfd..eee2d396d9f 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -266,6 +266,9 @@ inline std::shared_ptr create_memory_resource( * * Currently only supports 'rmm_mode' string parameter, which set the rmm * allocation mode. The default value of the parameter is 'pool'. + * Environment variable 'CUDF_TEST_RMM_MODE' can also be used to set the rmm + * allocation mode. If both are set, the value of 'rmm_mode' string parameter + * takes precedence. * * @return Parsing results in the form of unordered map */ @@ -273,9 +276,12 @@ inline auto parse_cudf_test_opts(int argc, char** argv) { try { cxxopts::Options options(argv[0], " - cuDF tests command line options"); + const char* env_rmm_mode = std::getenv("GTEST_CUDF_RMM_MODE"); // Overridden by CLI options + auto default_rmm_mode = env_rmm_mode ? env_rmm_mode : "pool"; options.allow_unrecognised_options().add_options()( - "rmm_mode", "RMM allocation mode", cxxopts::value()->default_value("pool")); - + "rmm_mode", + "RMM allocation mode", + cxxopts::value()->default_value(default_rmm_mode)); return options.parse(argc, argv); } catch (const cxxopts::OptionException& e) { CUDF_FAIL("Error parsing command line options"); diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 945285753e6..5d7e66f976d 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -17,16 +17,12 @@ ################################################################################################### # - compiler function ----------------------------------------------------------------------------- -if(DEFINED ENV{GTEST_CUDF_RMM_MODE}) - set(GTEST_CUDF_RMM_MODE "--rmm_mode=$ENV{GTEST_CUDF_RMM_MODE}") -endif() - function(ConfigureTest CMAKE_TEST_NAME ) add_executable(${CMAKE_TEST_NAME} ${ARGN}) set_target_properties(${CMAKE_TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$") target_link_libraries(${CMAKE_TEST_NAME} PRIVATE cudftestutil GTest::gmock_main GTest::gtest_main) - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME} ${GTEST_CUDF_RMM_MODE} COMMAND_EXPAND_LISTS) + add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) endfunction() ###################################################################################################