-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'branch-0.19' of https://github.com/rapidsai/cudf into o…
…rc_empty_dataframe
- Loading branch information
Showing
100 changed files
with
4,773 additions
and
1,862 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "string_bench_args.hpp" | ||
|
||
#include <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/scalar/scalar.hpp> | ||
#include <cudf/strings/combine.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
class StringCombine : public cudf::benchmark { | ||
}; | ||
|
||
static void BM_combine(benchmark::State& state) | ||
{ | ||
cudf::size_type const n_rows{static_cast<cudf::size_type>(state.range(0))}; | ||
cudf::size_type const max_str_length{static_cast<cudf::size_type>(state.range(1))}; | ||
data_profile table_profile; | ||
table_profile.set_distribution_params( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, 2, row_count{n_rows}, table_profile); | ||
cudf::strings_column_view input1(table->view().column(0)); | ||
cudf::strings_column_view input2(table->view().column(1)); | ||
cudf::string_scalar separator("+"); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
cudf::strings::concatenate(table->view(), separator); | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * (input1.chars_size() + input2.chars_size())); | ||
} | ||
|
||
static void generate_bench_args(benchmark::internal::Benchmark* b) | ||
{ | ||
int const min_rows = 1 << 12; | ||
int const max_rows = 1 << 24; | ||
int const row_mult = 8; | ||
int const min_rowlen = 1 << 4; | ||
int const max_rowlen = 1 << 11; | ||
int const len_mult = 4; | ||
generate_string_bench_args(b, min_rows, max_rows, row_mult, min_rowlen, max_rowlen, len_mult); | ||
} | ||
|
||
#define STRINGS_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringCombine, name) \ | ||
(::benchmark::State & st) { BM_combine(st); } \ | ||
BENCHMARK_REGISTER_F(StringCombine, name) \ | ||
->Apply(generate_bench_args) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
STRINGS_BENCHMARK_DEFINE(concat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "string_bench_args.hpp" | ||
|
||
#include <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/strings/string_view.cuh> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
#include <rmm/device_uvector.hpp> | ||
|
||
#include <thrust/execution_policy.h> | ||
#include <thrust/transform.h> | ||
|
||
#include <limits> | ||
|
||
namespace { | ||
using string_pair = thrust::pair<char const*, cudf::size_type>; | ||
struct string_view_to_pair { | ||
__device__ string_pair operator()(thrust::pair<cudf::string_view, bool> const& p) | ||
{ | ||
return (p.second) ? string_pair{p.first.data(), p.first.size_bytes()} : string_pair{nullptr, 0}; | ||
} | ||
}; | ||
} // namespace | ||
|
||
class StringsFactory : public cudf::benchmark { | ||
}; | ||
|
||
static void BM_factory(benchmark::State& state) | ||
{ | ||
cudf::size_type const n_rows{static_cast<cudf::size_type>(state.range(0))}; | ||
cudf::size_type const max_str_length{static_cast<cudf::size_type>(state.range(1))}; | ||
data_profile table_profile; | ||
table_profile.set_distribution_params( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); | ||
auto d_column = cudf::column_device_view::create(table->view().column(0)); | ||
rmm::device_vector<string_pair> pairs(d_column->size()); | ||
thrust::transform(thrust::device, | ||
d_column->pair_begin<cudf::string_view, true>(), | ||
d_column->pair_end<cudf::string_view, true>(), | ||
pairs.data(), | ||
string_view_to_pair{}); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
cudf::make_strings_column(pairs); | ||
} | ||
|
||
cudf::strings_column_view input(table->view().column(0)); | ||
state.SetBytesProcessed(state.iterations() * input.chars_size()); | ||
} | ||
|
||
static void generate_bench_args(benchmark::internal::Benchmark* b) | ||
{ | ||
int const min_rows = 1 << 12; | ||
int const max_rows = 1 << 24; | ||
int const row_mult = 8; | ||
int const min_rowlen = 1 << 5; | ||
int const max_rowlen = 1 << 13; | ||
int const len_mult = 4; | ||
generate_string_bench_args(b, min_rows, max_rows, row_mult, min_rowlen, max_rowlen, len_mult); | ||
} | ||
|
||
#define STRINGS_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringsFactory, name) \ | ||
(::benchmark::State & st) { BM_factory(st); } \ | ||
BENCHMARK_REGISTER_F(StringsFactory, name) \ | ||
->Apply(generate_bench_args) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
STRINGS_BENCHMARK_DEFINE(factory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "string_bench_args.hpp" | ||
|
||
#include <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/scalar/scalar.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf/strings/substring.hpp> | ||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
#include <limits> | ||
|
||
#include <thrust/iterator/constant_iterator.h> | ||
|
||
class StringSubstring : public cudf::benchmark { | ||
}; | ||
|
||
enum substring_type { position, multi_position, delimiter, multi_delimiter }; | ||
|
||
static void BM_substring(benchmark::State& state, substring_type rt) | ||
{ | ||
cudf::size_type const n_rows{static_cast<cudf::size_type>(state.range(0))}; | ||
cudf::size_type const max_str_length{static_cast<cudf::size_type>(state.range(1))}; | ||
data_profile table_profile; | ||
table_profile.set_distribution_params( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, max_str_length); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}, table_profile); | ||
cudf::strings_column_view input(table->view().column(0)); | ||
auto starts_itr = thrust::constant_iterator<cudf::size_type>(1); | ||
auto stops_itr = thrust::constant_iterator<cudf::size_type>(max_str_length / 2); | ||
cudf::test::fixed_width_column_wrapper<int32_t> starts(starts_itr, starts_itr + n_rows); | ||
cudf::test::fixed_width_column_wrapper<int32_t> stops(stops_itr, stops_itr + n_rows); | ||
auto delim_itr = thrust::constant_iterator<std::string>(" "); | ||
cudf::test::strings_column_wrapper delimiters(delim_itr, delim_itr + n_rows); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
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; | ||
case delimiter: cudf::strings::slice_strings(input, std::string{" "}, 1); break; | ||
case multi_delimiter: | ||
cudf::strings::slice_strings(input, cudf::strings_column_view(delimiters), 1); | ||
break; | ||
} | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * input.chars_size()); | ||
} | ||
|
||
static void generate_bench_args(benchmark::internal::Benchmark* b) | ||
{ | ||
int const min_rows = 1 << 12; | ||
int const max_rows = 1 << 24; | ||
int const row_mult = 8; | ||
int const min_rowlen = 1 << 5; | ||
int const max_rowlen = 1 << 13; | ||
int const len_mult = 4; | ||
generate_string_bench_args(b, min_rows, max_rows, row_mult, min_rowlen, max_rowlen, len_mult); | ||
} | ||
|
||
#define STRINGS_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringSubstring, name) \ | ||
(::benchmark::State & st) { BM_substring(st, substring_type::name); } \ | ||
BENCHMARK_REGISTER_F(StringSubstring, name) \ | ||
->Apply(generate_bench_args) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
STRINGS_BENCHMARK_DEFINE(position) | ||
STRINGS_BENCHMARK_DEFINE(multi_position) | ||
STRINGS_BENCHMARK_DEFINE(delimiter) | ||
STRINGS_BENCHMARK_DEFINE(multi_delimiter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.