-
Notifications
You must be signed in to change notification settings - Fork 886
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
Strings batch construction #16727
Draft
sdrp713
wants to merge
12
commits into
rapidsai:branch-24.10
Choose a base branch
from
sdrp713:string_batch_construction
base: branch-24.10
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+365
−11
Draft
Strings batch construction #16727
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5549de6
Implement `valid_if_async`
ttnghia 8b169f5
Change docs
ttnghia 55a56b7
Use `atomic_ref`
ttnghia 0928218
Add `make_strings_column` benchmark
ttnghia 6705012
Implement `strings_column_batch_construction` benchmark
ttnghia df42074
Rename functions
ttnghia d5770a4
Add empty function
ttnghia 4b94981
Revert changes in `valid_if.cuh`
ttnghia a584a34
Draft of Code
sdrp713 928ca4f
Fix Valid if n
sdrp713 d50185c
Update Offsets Function
sdrp713 68fcd37
Cleanup Code
sdrp713 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,116 @@ | ||
/* | ||
* Copyright (c) 2024, 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 <benchmarks/common/generate_input.hpp> | ||
|
||
#include <cudf/column/column_device_view.cuh> | ||
#include <cudf/column/column_factories.hpp> | ||
|
||
#include <rmm/device_uvector.hpp> | ||
#include <rmm/exec_policy.hpp> | ||
|
||
#include <thrust/pair.h> | ||
#include <thrust/tabulate.h> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
#include <vector> | ||
|
||
static void BM_make_strings_column(nvbench::state& state) | ||
{ | ||
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows")); | ||
auto const has_nulls = static_cast<bool>(state.get_int64("has_nulls")); | ||
|
||
constexpr int min_row_width = 0; | ||
constexpr int max_row_width = 50; | ||
data_profile const table_profile = | ||
data_profile_builder() | ||
.distribution(cudf::type_id::STRING, distribution_id::NORMAL, min_row_width, max_row_width) | ||
.null_probability(has_nulls ? std::optional<double>{0.1} : std::nullopt); | ||
auto const data_table = | ||
create_random_table({cudf::type_id::STRING}, row_count{num_rows}, table_profile); | ||
|
||
using string_index_pair = thrust::pair<char const*, cudf::size_type>; | ||
auto const stream = cudf::get_default_stream(); | ||
auto input = rmm::device_uvector<string_index_pair>(data_table->num_rows(), stream); | ||
auto const d_data_ptr = | ||
cudf::column_device_view::create(data_table->get_column(0).view(), stream); | ||
thrust::tabulate(rmm::exec_policy(stream), | ||
input.begin(), | ||
input.end(), | ||
[data_col = *d_data_ptr] __device__(auto const idx) { | ||
auto const row = data_col.element<cudf::string_view>(idx); | ||
return string_index_pair{row.data(), row.size_bytes()}; | ||
}); | ||
|
||
state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value())); | ||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
[[maybe_unused]] auto const output = cudf::make_strings_column(input, stream); | ||
}); | ||
} | ||
|
||
static void BM_make_strings_column_batch(nvbench::state& state) | ||
{ | ||
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows")); | ||
auto const has_nulls = static_cast<bool>(state.get_int64("has_nulls")); | ||
auto const batch_size = static_cast<cudf::size_type>(state.get_int64("batch_size")); | ||
|
||
constexpr int min_row_width = 0; | ||
constexpr int max_row_width = 50; | ||
data_profile const table_profile = | ||
data_profile_builder() | ||
.distribution(cudf::type_id::STRING, distribution_id::NORMAL, min_row_width, max_row_width) | ||
.null_probability(has_nulls ? std::optional<double>{0.1} : std::nullopt); | ||
auto const data_table = create_random_table( | ||
cycle_dtypes({cudf::type_id::STRING}, batch_size), row_count{num_rows}, table_profile); | ||
|
||
using string_index_pair = thrust::pair<char const*, cudf::size_type>; | ||
auto const stream = cudf::get_default_stream(); | ||
auto input_data = std::vector<rmm::device_uvector<string_index_pair>>{}; | ||
auto input = std::vector<cudf::device_span<string_index_pair const>>{}; | ||
input_data.reserve(batch_size); | ||
input.reserve(batch_size); | ||
for (auto i = 0; i < batch_size; ++i) { | ||
auto const d_data_ptr = | ||
cudf::column_device_view::create(data_table->get_column(i).view(), stream); | ||
auto batch_input = rmm::device_uvector<string_index_pair>(data_table->num_rows(), stream); | ||
thrust::tabulate(rmm::exec_policy(stream), | ||
batch_input.begin(), | ||
batch_input.end(), | ||
[data_col = *d_data_ptr] __device__(auto const idx) { | ||
auto const row = data_col.element<cudf::string_view>(idx); | ||
return string_index_pair{row.data(), row.size_bytes()}; | ||
}); | ||
input_data.emplace_back(std::move(batch_input)); | ||
input.emplace_back(input_data.back()); | ||
} | ||
|
||
state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value())); | ||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
[[maybe_unused]] auto const output = cudf::make_strings_column_batch(input, stream); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH(BM_make_strings_column) | ||
.set_name("make_strings_column") | ||
.add_int64_axis("num_rows", {100'000, 1'000'000, 10'000'000, 100'000'000, 200'000'000}) | ||
.add_int64_axis("has_nulls", {0, 1}); | ||
|
||
NVBENCH_BENCH(BM_make_strings_column_batch) | ||
.set_name("make_strings_column_batch") | ||
.add_int64_axis("num_rows", {1'000'000, 10'000'000, 20'000'000}) | ||
.add_int64_axis("has_nulls", {0, 1}) | ||
.add_int64_axis("batch_size", {5, 10, 15, 20}); |
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.
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.
This should also be put in
strings_column_factories.cu
too, because this function is not designed to be used anywhere else except for the column batch construction.