-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unneeded temporary device vector for strings scatter specializ…
…ation (#7409) The specialization logic for scatter on strings column includes building a temporary `device_vector` of `string_view` objects for the source column. The builtin iterators for an input `column_view` will work for `string_view` and so this extra `device_vector` is not required. The utilities for creating a `device_vector` for `string_view`s is also changed to use `device_uvector` instead. This also removed an unnecessary parameter as well as other minor changes. I also added a gbenchmark for scatter that includes strings. Removing the extra `device_vector` showed a small 10-15% performance improvement. Authors: - David (@davidwendt) Approvers: - Paul Taylor (@trxcllnt) - Keith Kraus (@kkraus14) - Mark Harris (@harrism) URL: #7409
- Loading branch information
1 parent
b887e58
commit 43b44e1
Showing
7 changed files
with
112 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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 <benchmark/benchmark.h> | ||
#include <benchmarks/common/generate_benchmark_input.hpp> | ||
#include <benchmarks/fixture/benchmark_fixture.hpp> | ||
#include <benchmarks/synchronization/synchronization.hpp> | ||
|
||
#include <cudf/copying.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
#include <algorithm> | ||
#include <random> | ||
|
||
class StringCopy : public cudf::benchmark { | ||
}; | ||
|
||
static void BM_copy(benchmark::State& state) | ||
{ | ||
cudf::size_type const n_rows{(cudf::size_type)state.range(0)}; | ||
auto const source = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); | ||
auto const target = create_random_table({cudf::type_id::STRING}, 1, row_count{n_rows}); | ||
|
||
// scatter indices | ||
std::vector<cudf::size_type> host_map_data(n_rows); | ||
std::iota(host_map_data.begin(), host_map_data.end(), 0); | ||
std::random_shuffle(host_map_data.begin(), host_map_data.end()); | ||
cudf::test::fixed_width_column_wrapper<cudf::size_type> scatter_map(host_map_data.begin(), | ||
host_map_data.end()); | ||
|
||
for (auto _ : state) { | ||
cuda_event_timer raii(state, true, 0); | ||
cudf::scatter(source->view(), scatter_map, target->view()); | ||
} | ||
|
||
state.SetBytesProcessed(state.iterations() * | ||
cudf::strings_column_view(source->view().column(0)).chars_size()); | ||
} | ||
|
||
#define SORT_BENCHMARK_DEFINE(name) \ | ||
BENCHMARK_DEFINE_F(StringCopy, name) \ | ||
(::benchmark::State & st) { BM_copy(st); } \ | ||
BENCHMARK_REGISTER_F(StringCopy, name) \ | ||
->RangeMultiplier(8) \ | ||
->Ranges({{1 << 12, 1 << 24}}) \ | ||
->UseManualTime() \ | ||
->Unit(benchmark::kMillisecond); | ||
|
||
SORT_BENCHMARK_DEFINE(scatter) |
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
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