-
Notifications
You must be signed in to change notification settings - Fork 902
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
Optimize cudf::make_strings_column for long strings #7576
Merged
rapids-bot
merged 15 commits into
rapidsai:branch-0.19
from
davidwendt:make-strings-column
Mar 18, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f6b8e27
add benchmark for make_strings_column(pair)
davidwendt 1dde5ce
Optimize cudf::make_strings_column for long strings
davidwendt 87cca87
Merge branch 'branch-0.19' into make-strings-column
davidwendt 3b3ba28
Merge branch 'branch-0.19' into make-strings-column
davidwendt 0507559
move include of local file
davidwendt 226b347
cudf/types.hpp include needed for cudf::size_type
davidwendt b9c3d5a
remove unneeded is_signed_iterator
davidwendt 97a63bc
create common gather_chars for make_strings_column and strings::detai…
davidwendt b8dddce
reinstate commented out threshold
davidwendt 6595488
Merge branch 'branch-0.19' into make-strings-column
davidwendt b7f3901
Merge branch 'branch-0.19' into make-strings-column
davidwendt 169a471
Merge branch 'branch-0.19' into make-strings-column
davidwendt 3ea82a4
change comment wording
davidwendt 019fe2d
Merge branch 'branch-0.19' into make-strings-column
davidwendt 6163360
resurrect is_unsigned_iterator
davidwendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 { | ||
davidwendt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"string_pair" should mean a pair of strings, so should we use some other name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most usages of 'pair' indicate two different types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't agree with that statement... but I also don't have a better name suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pair contains data pointer and data size, similar to a span. How about
string_span
?