Skip to content
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

Reenable stream identification library in CI #12714

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ nvidia-smi

set +e

# TODO: Disabling stream identification for now.
# Set up library for finding incorrect default stream usage.
#pushd "cpp/tests/utilities/identify_stream_usage/"
#mkdir build && cd build && cmake .. -GNinja && ninja && ninja test
#STREAM_IDENTIFY_LIB="$(realpath build/libidentify_stream_usage.so)"
#echo "STREAM_IDENTIFY_LIB=${STREAM_IDENTIFY_LIB}"
#popd
# Get library for finding incorrect default stream usage.
STREAM_IDENTIFY_LIB=$(conda info | grep "active env location" | awk 'BEGIN { FS = " : " } ; {print $2}')/lib/libcudf_identify_stream_usage.so
vyasr marked this conversation as resolved.
Show resolved Hide resolved

echo "STREAM_IDENTIFY_LIB=${STREAM_IDENTIFY_LIB}"

# Run libcudf and libcudf_kafka gtests from libcudf-tests package
rapids-logger "Run gtests"
Expand All @@ -50,17 +47,22 @@ rapids-logger "Run gtests"
for gt in "$CONDA_PREFIX"/bin/gtests/{libcudf,libcudf_kafka}/* ; do
test_name=$(basename ${gt})
echo "Running gtest $test_name"
${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}
# TODO: Disabling stream identification for now.
#if [[ ${test_name} == "SPAN_TEST" ]]; then
# # This one test is specifically designed to test using a thrust device
# # vector, so we expect and allow it to include default stream usage.
# gtest_filter="SpanTest.CanConstructFromDeviceContainers"
# GTEST_CUDF_STREAM_MODE="custom" LD_PRELOAD=${STREAM_IDENTIFY_LIB} ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR} --gtest_filter="-${gtest_filter}" && \
# ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR} --gtest_filter="${gtest_filter}"
#else
# GTEST_CUDF_STREAM_MODE="custom" LD_PRELOAD=${STREAM_IDENTIFY_LIB} ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}
#fi

# TODO: This strategy for using the stream lib will need to change when we
# switch to invoking ctest. For one, we will want to set the test
# properties to use the lib (which means that the decision will be made at
# CMake-configure time instead of runtime). We may also need to leverage
# something like gtest_discover_tests to be able to filter on the
# underlying test names.
if [[ ${test_name} == "SPAN_TEST" ]]; then
# This one test is specifically designed to test using a thrust device
# vector, so we expect and allow it to include default stream usage.
gtest_filter="SpanTest.CanConstructFromDeviceContainers"
GTEST_CUDF_STREAM_MODE="custom" LD_PRELOAD=${STREAM_IDENTIFY_LIB} ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR} --gtest_filter="-${gtest_filter}" && \
${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR} --gtest_filter="${gtest_filter}"
else
GTEST_CUDF_STREAM_MODE="custom" LD_PRELOAD=${STREAM_IDENTIFY_LIB} ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}
fi

exitcode=$?
if (( ${exitcode} != 0 )); then
Expand Down
42 changes: 41 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ option(CUDA_ENABLE_LINEINFO
option(CUDA_WARNINGS_AS_ERRORS "Enable -Werror=all-warnings for all CUDA compilation" ON)
# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)

set(DEFAULT_CUDF_BUILD_STREAMS_TEST_UTIL ON)
if(${CUDA_STATIC_RUNTIME})
set(DEFAULT_CUDF_BUILD_STREAMS_TEST_UTIL OFF)
endif()
option(
CUDF_BUILD_STREAMS_TEST_UTIL
"Whether to build the utilities for stream testing contained in libcudf"
${DEFAULT_CUDF_BUILD_STREAMS_TEST_UTIL}
)
mark_as_advanced(CUDF_BUILD_STREAMS_TEST_UTIL)

option(USE_LIBARROW_FROM_PYARROW "Use the libarrow contained within pyarrow." OFF)
mark_as_advanced(USE_LIBARROW_FROM_PYARROW)

Expand Down Expand Up @@ -754,10 +766,34 @@ if(CUDF_BUILD_TESTUTIL)
cudftestutil PUBLIC "$<BUILD_INTERFACE:${CUDF_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUDF_SOURCE_DIR}/src>"
)

add_library(cudf::cudftestutil ALIAS cudftestutil)

endif()

# * build cudf_identify_stream_usage --------------------------------------------------------------

if(CUDF_BUILD_STREAMS_TEST_UTIL)
if(CUDA_STATIC_RUNTIME)
message(
FATAL_ERROR
"Stream identification cannot be used with a static CUDA runtime. Please set CUDA_STATIC_RUNTIME=OFF or CUDF_BUILD_STREAMS_TEST_UTIL=OFF."
)
endif()

# Libraries for stream-related testing.
add_library(cudf_identify_stream_usage SHARED tests/utilities/identify_stream_usage.cpp)

set_target_properties(
cudf_identify_stream_usage
PROPERTIES # set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(cudf_identify_stream_usage PUBLIC CUDA::cudart rmm::rmm)
add_library(cudf::cudf_identify_stream_usage ALIAS cudf_identify_stream_usage)
endif()

# ##################################################################################################
# * add tests -------------------------------------------------------------------------------------

Expand Down Expand Up @@ -833,6 +869,10 @@ if(CUDF_BUILD_TESTUTIL)
)
endif()

if(CUDF_BUILD_STREAMS_TEST_UTIL)
install(TARGETS cudf_identify_stream_usage DESTINATION ${lib_dir})
endif()

set(doc_string
[=[
Provide targets for the cudf library.
Expand Down
13 changes: 13 additions & 0 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,19 @@ ConfigureTest(
# * bin tests ----------------------------------------------------------------------------------
ConfigureTest(LABEL_BINS_TEST labeling/label_bins_tests.cpp)

# ##################################################################################################
# * stream identification tests -------------------------------------------------------------------
ConfigureTest(
STREAM_IDENTIFICATION_TEST identify_stream_usage/test_default_stream_identification.cu
)
# Note that this only works when the test is invoked via ctest. At the moment CI is running all
# tests by manually invoking the executable, so we'll have to manually pass this environment
# variable in that setup.
set_tests_properties(
STREAM_IDENTIFICATION_TEST PROPERTIES ENVIRONMENT
LD_PRELOAD=$<TARGET_FILE:cudf_identify_stream_usage>
)

# ##################################################################################################
# enable testing ################################################################################
# ##################################################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@ void test_cudaLaunchKernel()

try {
kernel<<<1, 1>>>();
} catch (std::runtime_error) {
} catch (std::runtime_error&) {
return;
}
throw std::runtime_error("No exception raised for kernel on default stream!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
60 changes: 0 additions & 60 deletions cpp/tests/utilities/identify_stream_usage/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions python/cudf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ if(NOT cudf_FOUND)
# We don't build C++ tests when building wheels, so we can also omit the test util and shrink
# the wheel by avoiding embedding GTest.
set(CUDF_BUILD_TESTUTIL OFF)
set(CUDF_BUILD_STREAMS_TEST_UTIL OFF)

# Statically link cudart if building wheels
set(CUDA_STATIC_RUNTIME ON)
Expand Down