Skip to content

Commit

Permalink
Clean up literal zero cuda_stream_view arguments (#7774)
Browse files Browse the repository at this point in the history
Eliminates literal zero arguments to `cuda_stream_view` parameters in libcudf, replacing them with `rmm::cuda_stream_default`

Followup to rapidsai/rmm#740

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

Approvers:
  - Mike Wilson (https://github.com/hyperbolic2346)
  - Jake Hemstad (https://github.com/jrhemstad)
  - MithunR (https://github.com/mythrocks)

URL: #7774
  • Loading branch information
harrism authored Apr 8, 2021
1 parent 321009f commit 1cd2624
Show file tree
Hide file tree
Showing 33 changed files with 71 additions and 59 deletions.
8 changes: 4 additions & 4 deletions cpp/benchmarks/column/concatenate_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, 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 @@ -62,7 +62,7 @@ static void BM_concatenate(benchmark::State& state)
CHECK_CUDA(0);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
auto result = cudf::concatenate(column_views);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ static void BM_concatenate_tables(benchmark::State& state)
CHECK_CUDA(0);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
auto result = cudf::concatenate(table_views);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ static void BM_concatenate_strings(benchmark::State& state)
CHECK_CUDA(0);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
auto result = cudf::concatenate(column_views);
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/join/join_benchmark.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION.
* Copyright (c) 2019-2021, 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 @@ -103,7 +103,7 @@ static void BM_join(benchmark::State &state)
// Benchmark the inner join operation

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);

auto result = cudf::inner_join(
probe_table, build_table, columns_to_join, columns_to_join, cudf::null_equality::UNEQUAL);
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/sort/sort_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void BM_sort(benchmark::State& state, bool nulls)
auto input = cudf::table_view(column_views);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);

auto result = (stable) ? cudf::stable_sorted_order(input) : cudf::sorted_order(input);
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/sort/sort_strings_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, 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 @@ -32,7 +32,7 @@ static void BM_sort(benchmark::State& state)
auto const table = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
cudf::sort(table->view());
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/case_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void BM_case(benchmark::State& state)
cudf::strings_column_view input(table->view().column(0));

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
cudf::strings::to_lower(input);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/combine_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void BM_combine(benchmark::State& state)
cudf::string_scalar separator("+");

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
cudf::strings::concatenate(table->view(), separator);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/contains_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void BM_contains(benchmark::State& state, contains_type ct)
cudf::strings_column_view input(table->view().column(0));

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
// contains_re(), matches_re(), and count_re() all have similar functions
// with count_re() being the most regex intensive
switch (ct) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/copy_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void BM_copy(benchmark::State& state, copy_type ct)
host_map_data.end());

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (ct) {
case gather: cudf::gather(source->view(), index_map); break;
case scatter: cudf::scatter(source->view(), index_map, target->view()); break;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/extract_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void BM_extract(benchmark::State& state, int re_instructions)
std::string const pattern = "(" + raw_pattern.substr(0, re_instructions) + ")";

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
auto results = cudf::strings::extract(input, pattern);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/factory_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void BM_factory(benchmark::State& state)
string_view_to_pair{});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
cudf::make_strings_column(pairs);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/filter_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void BM_filter_chars(benchmark::State& state, FilterAPI api)
{cudf::char_utf8{'a'}, cudf::char_utf8{'c'}}};

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (api) {
case filter: cudf::strings::filter_characters_of_type(input, types); break;
case filter_chars: cudf::strings::filter_characters(input, filter_table); break;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/find_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void BM_find_scalar(benchmark::State& state, FindAPI find_api)
cudf::test::strings_column_wrapper targets({"+", "-"});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (find_api) {
case find: cudf::strings::find(input, target); break;
case find_multi:
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/replace_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void BM_replace(benchmark::State& state, replace_type rt)
cudf::test::strings_column_wrapper repls({"", ""});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (rt) {
case scalar: cudf::strings::replace(input, target, repl); break;
case slice: cudf::strings::replace_slice(input, repl, 1, 10); break;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/replace_re_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void BM_replace(benchmark::State& state, replace_type rt)
cudf::test::strings_column_wrapper repls({"#", ""});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (rt) {
case replace_type::replace_re: // contains_re and matches_re use the same main logic
cudf::strings::replace_re(input, "\\d+");
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/split_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void BM_split(benchmark::State& state, split_type rt)
cudf::string_scalar target("+");

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (rt) {
case split: cudf::strings::split(input, target); break;
case split_ws: cudf::strings::split(input); break;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/substring_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void BM_substring(benchmark::State& state, substring_type rt)
cudf::test::strings_column_wrapper delimiters(delim_itr, delim_itr + n_rows);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (rt) {
case position: cudf::strings::slice_strings(input, 1, max_str_length / 2); break;
case multi_position: cudf::strings::slice_strings(input, starts, stops); break;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/translate_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void BM_translate(benchmark::State& state, int entry_count)
});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
cudf::strings::translate(input, entries);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/string/url_decode_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void BM_url_decode(benchmark::State& state)
auto strings_view = cudf::strings_column_view(column);

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
auto result = cudf::strings::url_decode(strings_view);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/text/normalize_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void BM_normalize(benchmark::State& state, bool to_lower)
cudf::strings_column_view input(table->view().column(0));

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
nvtext::normalize_characters(input, to_lower);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/text/normalize_spaces_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void BM_normalize(benchmark::State& state)
cudf::strings_column_view input(table->view().column(0));

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
nvtext::normalize_spaces(input);
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/text/tokenize_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void BM_tokenize(benchmark::State& state, tokenize_type tt)
cudf::test::strings_column_wrapper delimiters({" ", "+", "-"});

for (auto _ : state) {
cuda_event_timer raii(state, true, 0);
cuda_event_timer raii(state, true, rmm::cuda_stream_default);
switch (tt) {
case tokenize_type::single: nvtext::tokenize(input); break;
case tokenize_type::multi:
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cudf/scalar/scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class fixed_width_scalar : public scalar {
/**
* @brief Implicit conversion operator to get the value of the scalar on the host
*/
explicit operator value_type() const { return this->value(0); }
explicit operator value_type() const { return this->value(rmm::cuda_stream_default); }

/**
* @brief Get the value of the scalar
Expand Down Expand Up @@ -449,7 +449,7 @@ class string_scalar : public scalar {
/**
* @brief Implicit conversion operator to get the value of the scalar in a host std::string
*/
explicit operator std::string() const { return this->to_string(0); }
explicit operator std::string() const { return this->to_string(rmm::cuda_stream_default); }

/**
* @brief Get the value of the scalar in a host std::string
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cudf/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class list_scalar;
class string_scalar;
template <typename T> class numeric_scalar;
template <typename T> class fixed_point_scalar;
template <typename T> class timestamp_scalar;
template <typename T> class duration_scalar;
template <typename T> struct timestamp_scalar;
template <typename T> struct duration_scalar;

class string_scalar_device_view;
template <typename T> class numeric_scalar_device_view;
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/copying/concatenate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ rmm::device_buffer concatenate_masks(host_span<column_view const> views,
rmm::device_buffer null_mask =
create_null_mask(total_element_count, mask_state::UNINITIALIZED, mr);

detail::concatenate_masks(views, static_cast<bitmask_type*>(null_mask.data()), 0);
detail::concatenate_masks(
views, static_cast<bitmask_type*>(null_mask.data()), rmm::cuda_stream_default);

return null_mask;
}
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/copying/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <cudf/detail/copy.hpp>
#include <cudf/detail/nvtx/ranges.hpp>

#include <rmm/cuda_stream_view.hpp>

namespace cudf {
namespace detail {

Expand Down Expand Up @@ -216,7 +218,7 @@ table_view unpack(uint8_t const* metadata, uint8_t const* gpu_data)
packed_columns pack(cudf::table_view const& input, rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::pack(input, 0, mr);
return detail::pack(input, rmm::cuda_stream_default, mr);
}

/**
Expand Down
14 changes: 8 additions & 6 deletions cpp/src/io/csv/writer_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/per_device_resource.hpp>

#include <thrust/count.h>
#include <thrust/execution_policy.h>
Expand Down Expand Up @@ -211,10 +212,11 @@ struct column_to_strings_fn {
(cudf::is_timestamp<column_type>()) || (cudf::is_duration<column_type>()));
}

explicit column_to_strings_fn(csv_writer_options const& options,
rmm::mr::device_memory_resource* mr = nullptr,
rmm::cuda_stream_view stream = nullptr)
: options_(options), mr_(mr), stream_(stream)
explicit column_to_strings_fn(
csv_writer_options const& options,
rmm::cuda_stream_view stream = rmm::cuda_stream_default,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
: options_(options), stream_(stream), mr_(mr)
{
}

Expand Down Expand Up @@ -345,8 +347,8 @@ struct column_to_strings_fn {

private:
csv_writer_options const& options_;
rmm::mr::device_memory_resource* mr_;
rmm::cuda_stream_view stream_;
rmm::mr::device_memory_resource* mr_;
};
} // unnamed namespace

Expand Down Expand Up @@ -495,7 +497,7 @@ void writer::impl::write(table_view const& table,

// convert each chunk to CSV:
//
column_to_strings_fn converter{options_, mr_};
column_to_strings_fn converter{options_, stream, mr_};
for (auto&& sub_view : vector_views) {
// Skip if the table has no rows
if (sub_view.num_rows() == 0) continue;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/replace/nans.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
* Copyright (c) 2020-2021, 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 @@ -146,7 +146,7 @@ std::unique_ptr<column> replace_nans(column_view const& input,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nans(input, replacement, 0, mr);
return detail::replace_nans(input, replacement, rmm::cuda_stream_default, mr);
}

std::unique_ptr<column> replace_nans(column_view const& input,
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/strings/substring.cu
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ std::unique_ptr<column> slice_strings(strings_column_view const& strings,
"Strings and delimiters column sizes do not match");

CUDF_FUNC_RANGE();
auto delimiters_dev_view_ptr = cudf::column_device_view::create(delimiters.parent(), 0);
auto delimiters_dev_view = *delimiters_dev_view_ptr;
auto delimiters_dev_view_ptr =
cudf::column_device_view::create(delimiters.parent(), rmm::cuda_stream_default);
auto delimiters_dev_view = *delimiters_dev_view_ptr;
return (delimiters_dev_view.nullable())
? detail::slice_strings(
strings,
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/text/subword/subword_tokenize.cu
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ tokenizer_result subword_tokenize(cudf::strings_column_view const& strings,
do_lower_case,
do_truncate,
max_rows_tensor,
0,
rmm::cuda_stream_default,
mr);
}

Expand All @@ -286,7 +286,7 @@ tokenizer_result subword_tokenize(cudf::strings_column_view const& strings,
do_lower_case,
do_truncate,
max_rows_tensor,
0,
rmm::cuda_stream_default,
mr);
}

Expand Down
6 changes: 4 additions & 2 deletions cpp/tests/copying/gather_struct_tests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ TYPED_TEST(TypedStructGatherTest, TestGatherStructOfLists)
cudf::detail::make_counting_transform_iterator(0, [](auto i) { return !(i % 3); })};
};

auto lists_column = std::make_unique<cudf::column>(cudf::column(lists_column_exemplar(), 0));
auto lists_column =
std::make_unique<cudf::column>(cudf::column(lists_column_exemplar(), rmm::cuda_stream_default));

// Assemble struct column.
std::vector<std::unique_ptr<cudf::column>> vector_of_columns;
Expand Down Expand Up @@ -242,7 +243,8 @@ TYPED_TEST(TypedStructGatherTest, TestGatherStructOfListsOfLists)
cudf::detail::make_counting_transform_iterator(0, [](auto i) { return !(i % 3); })};
};

auto lists_column = std::make_unique<cudf::column>(cudf::column(lists_column_exemplar(), 0));
auto lists_column =
std::make_unique<cudf::column>(cudf::column(lists_column_exemplar(), rmm::cuda_stream_default));

// Assemble struct column.
std::vector<std::unique_ptr<cudf::column>> vector_of_columns;
Expand Down
Loading

0 comments on commit 1cd2624

Please sign in to comment.