Skip to content

Commit

Permalink
Move stream-related test configuration to CMake (#13513)
Browse files Browse the repository at this point in the history
Instead of configuring test settings with environment variables in the bash script for CI, these changes allow all that configuration to happen directly in CMake, which is more robust and also makes the test configuration portable. With these changes any execution of the tests with `ctest` will use the preload library with all the other necessary environment variables configured as well. Running the test executables directly, on the other hand, will skip stream validation but still run correctly (except for the one test that explicitly tests the stream validation preload lib itself). These changes are now possible because our CI test scripts now run ctest instead of the executables (as of #12451) and due to full support for generator expression propagation even with the parallel testing feature (as of rapidsai/rapids-cmake#410).

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Mike Wilson (https://github.com/hyperbolic2346)

URL: #13513
  • Loading branch information
vyasr authored Jun 9, 2023
1 parent 3e32dc3 commit 7e8d534
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
16 changes: 1 addition & 15 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@ EXITCODE=0
trap "EXITCODE=1" ERR
set +e

# Get library for finding incorrect default stream usage.
STREAM_IDENTIFY_LIB_MODE_CUDF="${CONDA_PREFIX}/lib/libcudf_identify_stream_usage_mode_cudf.so"
STREAM_IDENTIFY_LIB_MODE_TESTING="${CONDA_PREFIX}/lib/libcudf_identify_stream_usage_mode_testing.so"

echo "STREAM_IDENTIFY_LIB=${STREAM_IDENTIFY_LIB_MODE_CUDF}"

# Run libcudf and libcudf_kafka gtests from libcudf-tests package
rapids-logger "Run gtests"

cd $CONDA_PREFIX/bin/gtests/libcudf/
export GTEST_CUDF_STREAM_MODE="new_cudf_default"
export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/
export LD_PRELOAD=${STREAM_IDENTIFY_LIB_MODE_CUDF}

ctest -E SPAN_TEST -j20 --output-on-failure

# This one test is specifically designed to test using a thrust device vector,
# so we expect and allow it to include default stream usage.
_allowlist_filter="SpanTest.CanConstructFromDeviceContainers"
GTEST_FILTER="-${_allowlist_filter}" ctest -R SPAN_TEST -VV
LD_PRELOAD= GTEST_CUDF_STREAM_MODE=default GTEST_FILTER="${_allowlist_filter}" ctest -R SPAN_TEST -VV
ctest -j20 --output-on-failure

SUITEERROR=$?

Expand Down
32 changes: 30 additions & 2 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rapids_test_init()
# properties and linking to build the test
function(ConfigureTest CMAKE_TEST_NAME)
set(options)
set(one_value GPUS PERCENT)
set(one_value GPUS PERCENT STREAM_MODE)
set(multi_value)
cmake_parse_arguments(_CUDF_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN})
if(NOT DEFINED _CUDF_TEST_GPUS AND NOT DEFINED _CUDF_TEST_PERCENT)
Expand All @@ -37,6 +37,9 @@ function(ConfigureTest CMAKE_TEST_NAME)
if(NOT DEFINED _CUDF_TEST_PERCENT)
set(_CUDF_TEST_PERCENT 100)
endif()
if(NOT DEFINED _CUDF_TEST_STREAM_MODE)
set(_CUDF_TEST_STREAM_MODE cudf)
endif()

add_executable(${CMAKE_TEST_NAME} ${_CUDF_TEST_UNPARSED_ARGUMENTS})
set_target_properties(
Expand All @@ -62,6 +65,13 @@ function(ConfigureTest CMAKE_TEST_NAME)
PERCENT ${_CUDF_TEST_PERCENT}
INSTALL_COMPONENT_SET testing
)

set_tests_properties(
${CMAKE_TEST_NAME}
PROPERTIES
ENVIRONMENT
"GTEST_CUDF_STREAM_MODE=new_${_CUDF_TEST_STREAM_MODE}_default;LD_PRELOAD=$<TARGET_FILE:cudf_identify_stream_usage_mode_${_CUDF_TEST_STREAM_MODE}>"
)
endfunction()

# ##################################################################################################
Expand Down Expand Up @@ -349,7 +359,25 @@ ConfigureTest(

# ##################################################################################################
# * span tests -------------------------------------------------------------------------------

# This test must be split into two executables so that one can use the preload library and one does
# not. The one that doesn't includes a thrust::device_vector copy, which is always synchronous on
# the default stream and is out of libcudf's control (but must be tested).
set(_allowlist_filter SpanTest.CanConstructFromDeviceContainers)

ConfigureTest(SPAN_TEST utilities_tests/span_tests.cu)
ConfigureTest(SPAN_TEST_DEVICE_VECTOR utilities_tests/span_tests.cu)

# Overwrite the environments set by ConfigureTest
set_tests_properties(
SPAN_TEST
PROPERTIES
ENVIRONMENT
"GTEST_FILTER=-${_allowlist_filter};GTEST_CUDF_STREAM_MODE=new_cudf_default;LD_PRELOAD=$<TARGET_FILE:cudf_identify_stream_usage_mode_cudf>"
)
set_tests_properties(
SPAN_TEST_DEVICE_VECTOR PROPERTIES ENVIRONMENT "GTEST_FILTER=${_allowlist_filter}"
)

# ##################################################################################################
# * iterator tests --------------------------------------------------------------------------------
Expand Down Expand Up @@ -578,7 +606,7 @@ ConfigureTest(
ConfigureTest(LABEL_BINS_TEST labeling/label_bins_tests.cpp)

# ##################################################################################################
# * stream identification tests -------------------------------------------------------------------
# * stream testing ---------------------------------------------------------------------------------
ConfigureTest(
STREAM_IDENTIFICATION_TEST identify_stream_usage/test_default_stream_identification.cu
)
Expand Down

0 comments on commit 7e8d534

Please sign in to comment.