Skip to content

Commit

Permalink
Merge branch 'branch-22.06' into fea/use_rapids_cpm_nvcomp
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed May 24, 2022
2 parents 4827a64 + e096345 commit 7758d88
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 30 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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 @@ -281,7 +281,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
27 changes: 23 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ 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(PER_THREAD_DEFAULT_STREAM "Build 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
)
option(PER_THREAD_DEFAULT_STREAM "[DEPRECATED] Build with per-thread default stream" OFF)
mark_as_advanced(FORCE, PER_THREAD_DEFAULT_STREAM)
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 /
# memchecking
Expand All @@ -58,14 +65,24 @@ 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}")
message(VERBOSE "CUDF: Build cuDF shared libraries: ${BUILD_SHARED_LIBS}")
message(VERBOSE "CUDF: Use a file cache for JIT compiled kernels: ${JITIFY_USE_CACHE}")
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 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 @@ -581,8 +598,10 @@ 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
4 changes: 2 additions & 2 deletions cpp/cmake/thirdparty/get_nvcomp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function(find_and_configure_nvcomp)
USE_PROPRIETARY_BINARY ${CUDF_USE_PROPRIETARY_NVCOMP}
)

# If we are building nvcomp use enable per-thread default stream
if(TARGET nvcomp AND PER_THREAD_DEFAULT_STREAM)
# 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/orc.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 @@ -20,6 +20,7 @@
#include <cudf/io/types.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>

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

/**
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
13 changes: 7 additions & 6 deletions cpp/src/io/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <cudf/io/orc_metadata.hpp>
#include <cudf/io/parquet.hpp>
#include <cudf/table/table.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <io/orc/orc.hpp>

Expand Down Expand Up @@ -155,7 +156,7 @@ table_with_metadata read_avro(avro_reader_options const& options,

CUDF_EXPECTS(datasources.size() == 1, "Only a single source is currently supported.");

return avro::read_avro(std::move(datasources[0]), options, rmm::cuda_stream_default, mr);
return avro::read_avro(std::move(datasources[0]), options, cudf::default_stream_value, mr);
}

compression_type infer_compression_type(compression_type compression, source_info const& info)
Expand Down Expand Up @@ -345,7 +346,7 @@ table_with_metadata read_orc(orc_reader_options const& options, rmm::mr::device_

auto datasources = make_datasources(options.get_source());
auto reader = std::make_unique<detail_orc::reader>(
std::move(datasources), options, rmm::cuda_stream_default, mr);
std::move(datasources), options, cudf::default_stream_value, mr);

return reader->read(options);
}
Expand All @@ -363,7 +364,7 @@ void write_orc(orc_writer_options const& options, rmm::mr::device_memory_resourc
CUDF_EXPECTS(sinks.size() == 1, "Multiple sinks not supported for ORC writing");

auto writer = std::make_unique<detail_orc::writer>(
std::move(sinks[0]), options, io_detail::SingleWriteMode::YES, rmm::cuda_stream_default, mr);
std::move(sinks[0]), options, io_detail::SingleWriteMode::YES, cudf::default_stream_value, mr);

writer->write(options.get_table());
}
Expand All @@ -380,7 +381,7 @@ orc_chunked_writer::orc_chunked_writer(chunked_orc_writer_options const& options
CUDF_EXPECTS(sinks.size() == 1, "Multiple sinks not supported for ORC writing");

writer = std::make_unique<detail_orc::writer>(
std::move(sinks[0]), options, io_detail::SingleWriteMode::NO, rmm::cuda_stream_default, mr);
std::move(sinks[0]), options, io_detail::SingleWriteMode::NO, cudf::default_stream_value, mr);
}

/**
Expand Down Expand Up @@ -455,7 +456,7 @@ std::unique_ptr<std::vector<uint8_t>> write_parquet(parquet_writer_options const

auto sinks = make_datasinks(options.get_sink());
auto writer = std::make_unique<detail_parquet::writer>(
std::move(sinks), options, io_detail::SingleWriteMode::YES, rmm::cuda_stream_default, mr);
std::move(sinks), options, io_detail::SingleWriteMode::YES, cudf::default_stream_value, mr);

writer->write(options.get_table(), options.get_partitions());

Expand All @@ -473,7 +474,7 @@ parquet_chunked_writer::parquet_chunked_writer(chunked_parquet_writer_options co
auto sinks = make_datasinks(options.get_sink());

writer = std::make_unique<detail_parquet::writer>(
std::move(sinks), options, io_detail::SingleWriteMode::NO, rmm::cuda_stream_default, mr);
std::move(sinks), options, io_detail::SingleWriteMode::NO, cudf::default_stream_value, mr);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ 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
```

then build the jar:
```shell script
cd src/cudf/java
mvn clean install -DPER_THREAD_DEFAULT_STREAM=ON
mvn clean install -DCUDF_USE_PER_THREAD_DEFAULT_STREAM=ON
```

## GPUDirect Storage (GDS)
Expand Down
4 changes: 2 additions & 2 deletions 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 All @@ -75,7 +75,7 @@ cmake --install .
###### Build cudf jar ######
BUILD_ARG="-Dmaven.repo.local=\"$WORKSPACE/.m2\"\
-DskipTests=$SKIP_JAVA_TESTS\
-DPER_THREAD_DEFAULT_STREAM=$ENABLE_PTDS\
-DCUDF_USE_PER_THREAD_DEFAULT_STREAM=$ENABLE_PTDS\
-DCUDA_STATIC_RUNTIME=$ENABLE_CUDA_STATIC_RUNTIME\
-DCUDF_JNI_LIBCUDF_STATIC=ON\
-DUSE_GDS=$ENABLE_GDS -Dtest=*,!CuFileTest"
Expand Down
3 changes: 2 additions & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
<CMAKE_EXPORT_COMPILE_COMMANDS>OFF</CMAKE_EXPORT_COMPILE_COMMANDS>
<CUDA_STATIC_RUNTIME>OFF</CUDA_STATIC_RUNTIME>
<PER_THREAD_DEFAULT_STREAM>OFF</PER_THREAD_DEFAULT_STREAM>
<CUDF_USE_PER_THREAD_DEFAULT_STREAM>${PER_THREAD_DEFAULT_STREAM}</CUDF_USE_PER_THREAD_DEFAULT_STREAM>
<USE_GDS>OFF</USE_GDS>
<GPU_ARCHS>ALL</GPU_ARCHS>
<CUDF_JNI_LIBCUDF_STATIC>OFF</CUDF_JNI_LIBCUDF_STATIC>
Expand Down Expand Up @@ -385,7 +386,7 @@
<arg value="${basedir}/src/main/native"/>
<arg line="${cmake.ccache.opts}"/>
<arg value="-DCUDA_STATIC_RUNTIME=${CUDA_STATIC_RUNTIME}" />
<arg value="-DPER_THREAD_DEFAULT_STREAM=${PER_THREAD_DEFAULT_STREAM}" />
<arg value="-DCUDF_USE_PER_THREAD_DEFAULT_STREAM=${CUDF_USE_PER_THREAD_DEFAULT_STREAM}" />
<arg value="-DUSE_GDS=${USE_GDS}" />
<arg value="-DCMAKE_CXX_FLAGS=${cxx.flags}"/>
<arg value="-DCMAKE_EXPORT_COMPILE_COMMANDS=${CMAKE_EXPORT_COMPILE_COMMANDS}"/>
Expand Down
22 changes: 18 additions & 4 deletions java/src/main/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,29 @@ project(
option(USE_NVTX "Build with NVTX support" ON)
option(BUILD_SHARED_LIBS "Build cuDF JNI shared libraries" ON)
option(BUILD_TESTS "Configure CMake to build tests" ON)
option(PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(PER_THREAD_DEFAULT_STREAM "[DEPRECATED] Build with per-thread default stream" OFF)
mark_as_advanced(FORCE, PER_THREAD_DEFAULT_STREAM)
option(CUDF_USE_PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)
option(USE_GDS "Build with GPUDirect Storage (GDS)/cuFile support" OFF)
option(CUDF_JNI_LIBCUDF_STATIC "Link with libcudf.a" 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_JNI: Build with NVTX support: ${USE_NVTX}")
message(VERBOSE "CUDF_JNI: Build cuDF JNI shared libraries: ${BUILD_SHARED_LIBS}")
message(VERBOSE "CUDF_JNI: Configure CMake to build tests: ${BUILD_TESTS}")
message(VERBOSE "CUDF_JNI: Build with per-thread default stream: ${PER_THREAD_DEFAULT_STREAM}")
message(VERBOSE
"CUDF_JNI: Build with per-thread default stream: ${CUDF_USE_PER_THREAD_DEFAULT_STREAM}"
)
message(VERBOSE "CUDF_JNI: Statically link the CUDA runtime: ${CUDA_STATIC_RUNTIME}")
message(VERBOSE "CUDF_JNI: Build with GPUDirect Storage support: ${USE_GDS}")
message(VERBOSE "CUDF_JNI: Link with libcudf statically: ${CUDF_JNI_LIBCUDF_STATIC}")
Expand Down Expand Up @@ -80,9 +94,9 @@ if(NOT USE_NVTX)
target_compile_definitions(cudfjni PUBLIC NVTX_DISABLE)
endif()

if(PER_THREAD_DEFAULT_STREAM)
if(CUDF_USE_PER_THREAD_DEFAULT_STREAM)
message(STATUS "Using per-thread default stream")
add_compile_definitions(CUDA_API_PER_THREAD_DEFAULT_STREAM)
add_compile_definitions(CUDA_API_PER_THREAD_DEFAULT_STREAM CUDF_USE_PER_THREAD_DEFAULT_STREAM)
endif()

# ##################################################################################################
Expand Down

0 comments on commit 7758d88

Please sign in to comment.