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

Replace defaulted stream value for libcudf APIs that use NVCOMP #10877

Merged
merged 13 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function buildLibCudfJniInDocker {
-DCUDF_USE_ARROW_STATIC=ON \
-DCUDF_ENABLE_ARROW_S3=OFF \
-DBUILD_TESTS=OFF \
-DPER_THREAD_DEFAULT_STREAM=ON \
-DCUDF_USE_PER_THREAD_DEFAULT_STREAM=ON \
-DRMM_LOGGING_LEVEL=OFF \
-DBUILD_SHARED_LIBS=OFF && \
cmake --build . --parallel ${PARALLEL_LEVEL} && \
Expand Down Expand Up @@ -274,7 +274,7 @@ if buildAll || hasArg libcudf; then
-DBUILD_TESTS=${BUILD_TESTS} \
-DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DPER_THREAD_DEFAULT_STREAM=${BUILD_PER_THREAD_DEFAULT_STREAM} \
-DCUDF_USE_PER_THREAD_DEFAULT_STREAM=${BUILD_PER_THREAD_DEFAULT_STREAM} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_ARGS}

Expand Down
16 changes: 14 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ option(CUDF_ENABLE_ARROW_ORC "Build the Arrow ORC adapter" OFF)
option(CUDF_ENABLE_ARROW_PYTHON "Find (or build) Arrow with Python support" OFF)
option(CUDF_ENABLE_ARROW_PARQUET "Find (or build) Arrow with Parquet support" OFF)
option(CUDF_ENABLE_ARROW_S3 "Build/Enable AWS S3 Arrow filesystem support" ON)
option(CUDF_USE_PER_THREAD_DEFAULT_STREAM "Build cuDF with per-thread default stream" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
option(CUDF_USE_PER_THREAD_DEFAULT_STREAM "Build cuDF with per-thread default stream" OFF)
option(CUDF_USE_PER_THREAD_DEFAULT_STREAM "Build cuDF with per-thread default stream, including passing the per-thread default stream to external libraries." OFF)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I will update this.

option(PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF)
# Option to enable line info in CUDA device compilation to allow introspection when profiling /
Expand All @@ -57,6 +58,15 @@ option(CUDA_ENABLE_LINEINFO
# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)

# PER_THREAD_DEFAULT_STREAM will be replaced with CUDF_USE_PER_THREAD_DEFAULT_STREAM
if(PER_THREAD_DEFAULT_STREAM)
set(CUDF_USE_PER_THREAD_DEFAULT_STREAM ON)
message(
DEPRECATION
"CUDF: PER_THREAD_DEFAULT_STREAM is deprecated, and will be removed in a future release,
please use CUDF_USE_PER_THREAD_DEFAULT_STREAM instead.")
endif()

message(VERBOSE "CUDF: Build with NVTX support: ${USE_NVTX}")
message(VERBOSE "CUDF: Configure CMake to build tests: ${BUILD_TESTS}")
message(VERBOSE "CUDF: Configure CMake to build (google & nvbench) benchmarks: ${BUILD_BENCHMARKS}")
Expand All @@ -65,6 +75,7 @@ message(VERBOSE "CUDF: Use a file cache for JIT compiled kernels: ${JITIFY_USE_C
message(VERBOSE "CUDF: Build and statically link Arrow libraries: ${CUDF_USE_ARROW_STATIC}")
message(VERBOSE "CUDF: Build and enable S3 filesystem support for Arrow: ${CUDF_ENABLE_ARROW_S3}")
message(VERBOSE "CUDF: Build with per-thread default stream: ${PER_THREAD_DEFAULT_STREAM}")
message(VERBOSE "CUDF: Build cuDF with per-thread default stream: ${CUDF_PER_THREAD_DEFAULT_STREAM}")
message(
VERBOSE
"CUDF: Disable warnings generated from deprecated declarations: ${DISABLE_DEPRECATION_WARNING}"
Expand Down Expand Up @@ -580,8 +591,9 @@ if(JITIFY_USE_CACHE)
endif()

# Per-thread default stream
if(PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(cudf PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
if(CUDF_USE_PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(
cudf PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM CUDF_USE_PER_THREAD_DEFAULT_STREAM)
endif()

# Disable NVTX if necessary
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_nvcomp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function(find_and_configure_nvcomp VERSION_MIN VERSION_MAX)
endif()

# Per-thread default stream
if(TARGET nvcomp AND PER_THREAD_DEFAULT_STREAM)
if(TARGET nvcomp AND CUDF_USE_PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(nvcomp PRIVATE CUDA_API_PER_THREAD_DEFAULT_STREAM)
endif()
endfunction()
Expand Down
5 changes: 3 additions & 2 deletions cpp/include/cudf/io/detail/avro.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 All @@ -17,6 +17,7 @@
#pragma once

#include <cudf/io/avro.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <rmm/cuda_stream_view.hpp>

Expand All @@ -38,7 +39,7 @@ namespace avro {
table_with_metadata read_avro(
std::unique_ptr<cudf::io::datasource>&& source,
avro_reader_options const& options,
rmm::cuda_stream_view stream = rmm::cuda_stream_default,
rmm::cuda_stream_view stream = cudf::default_stream_value,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

} // namespace avro
Expand Down
5 changes: 3 additions & 2 deletions cpp/include/cudf/io/detail/parquet.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 All @@ -23,6 +23,7 @@
#include <cudf/io/detail/utils.hpp>
#include <cudf/io/types.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/mr/device/per_device_resource.hpp>

Expand Down Expand Up @@ -74,7 +75,7 @@ class reader {
* @return The set of columns along with table metadata
*/
table_with_metadata read(parquet_reader_options const& options,
rmm::cuda_stream_view stream = rmm::cuda_stream_default);
rmm::cuda_stream_view stream = cudf::default_stream_value);
};

/**
Expand Down
16 changes: 15 additions & 1 deletion cpp/include/cudf/utilities/default_stream.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 All @@ -16,8 +16,22 @@

#pragma once

#include <rmm/cuda_stream_view.hpp>

namespace cudf {

/**
* @brief Default stream for cudf
*
* Use this value to ensure the correct stream is used when compiled with per
* thread default stream.
*/
#if defined(CUDF_USE_PER_THREAD_DEFAULT_STREAM)
static const rmm::cuda_stream_view default_stream_value{rmm::cuda_stream_per_thread};
#else
static constexpr rmm::cuda_stream_view default_stream_value{};
#endif

/**
* @brief Check if per-thread default stream is enabled.
*
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/utilities/default_stream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 All @@ -25,7 +25,7 @@ namespace cudf {
*/
bool is_ptds_enabled()
{
#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
#ifdef CUDF_USE_PER_THREAD_DEFAULT_STREAM
return true;
#else
return false;
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/utilities_tests/default_stream_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 All @@ -18,7 +18,7 @@

#include <cudf_test/cudf_gtest.hpp>

#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
#ifdef CUDF_USE_PER_THREAD_DEFAULT_STREAM
TEST(DefaultStreamTest, PtdsIsEnabled) { EXPECT_TRUE(cudf::is_ptds_enabled()); }
#else
TEST(DefaultStreamTest, PtdsIsNotEnabled) { EXPECT_FALSE(cudf::is_ptds_enabled()); }
Expand Down
2 changes: 1 addition & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Since the PTDS option is for each compilation unit, it should be done at the sam
whole codebase. To enable PTDS, first build cuDF:
```shell script
cd src/cudf/cpp/build
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DPER_THREAD_DEFAULT_STREAM=ON
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCUDF_USE_PER_THREAD_DEFAULT_STREAM=ON
make -j`nproc`
make install
```
Expand Down
2 changes: 1 addition & 1 deletion java/ci/build-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cmake .. -G"${CMAKE_GENERATOR}" \
-DCUDF_USE_ARROW_STATIC=ON \
-DCUDF_ENABLE_ARROW_S3=OFF \
-DBUILD_TESTS=$BUILD_CPP_TESTS \
-DPER_THREAD_DEFAULT_STREAM=$ENABLE_PTDS \
-DCUDF_USE_PER_THREAD_DEFAULT_STREAM=$ENABLE_PTDS \
-DRMM_LOGGING_LEVEL=$RMM_LOGGING_LEVEL \
-DBUILD_SHARED_LIBS=OFF

Expand Down