Skip to content
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

Refactor scatter for list columns #8255

Merged
merged 23 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d858787
Fixed width refactor
isVoid May 14, 2021
b271ea4
remove debug header
isVoid May 14, 2021
a112573
Merge branch 'branch-21.06' of https://github.com/rapidsai/cudf into …
isVoid May 20, 2021
f39965a
.
isVoid May 20, 2021
dd50750
Move detailed implementations into scatter_helper
isVoid May 21, 2021
96de835
Strings spec working
isVoid May 21, 2021
309299f
make lists spec work
isVoid May 21, 2021
4847b52
Add benchmark scatter lists
isVoid May 22, 2021
ff36c9d
Merge branch 'list_scatter' of github.com:isVoid/cudf into list_scatter
isVoid May 22, 2021
d8c96ed
Merge branch 'branch-21.06' of https://github.com/rapidsai/cudf into…
isVoid May 25, 2021
a5fdd98
Fixing bad merges and applying #8314 fix
isVoid May 25, 2021
0720714
structs refactor
isVoid May 25, 2021
e1b82e9
cleanups
isVoid May 25, 2021
b293cb0
Merge branch 'list_scatter' of github.com:isVoid/cudf into list_scatter
isVoid May 25, 2021
a8d6678
remove debug_printer
isVoid May 25, 2021
262ad60
Merge branch 'branch-21.08' of https://github.com/rapidsai/cudf into …
isVoid May 25, 2021
2840347
Rename function
isVoid May 25, 2021
976a522
style and conda scripts cleanup
isVoid May 25, 2021
a497394
Fixes bad rename
isVoid May 26, 2021
0b3bfb8
removing anonymous np, license
isVoid May 26, 2021
f27c670
Merge branch 'branch-21.08' of https://github.com/rapidsai/cudf into …
isVoid Jun 1, 2021
bf666c5
address reviews
isVoid Jun 5, 2021
3c8cb01
null_mask move semantics
isVoid Jun 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conda/recipes/libcudf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ test:
- test -f $PREFIX/include/cudf/lists/detail/drop_list_duplicates.hpp
- test -f $PREFIX/include/cudf/lists/detail/interleave_columns.hpp
- test -f $PREFIX/include/cudf/lists/detail/sorting.hpp
- test -f $PREFIX/include/cudf/lists/detail/scatter_helper.cuh
- test -f $PREFIX/include/cudf/lists/combine.hpp
- test -f $PREFIX/include/cudf/lists/count_elements.hpp
- test -f $PREFIX/include/cudf/lists/explode.hpp
Expand Down
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ add_library(cudf
src/lists/copying/copying.cu
src/lists/copying/gather.cu
src/lists/copying/segmented_gather.cu
src/lists/copying/scatter_helper.cu
src/lists/count_elements.cu
src/lists/drop_list_duplicates.cu
src/lists/explode.cu
Expand Down
4 changes: 4 additions & 0 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ ConfigureBench(GATHER_BENCH copying/gather_benchmark.cu)
# - scatter benchmark -----------------------------------------------------------------------------
ConfigureBench(SCATTER_BENCH copying/scatter_benchmark.cu)

###################################################################################################
# - lists scatter benchmark -----------------------------------------------------------------------
ConfigureBench(SCATTER_LISTS_BENCH lists/copying/scatter_lists_benchmark.cu)

###################################################################################################
# - contiguous_split benchmark -------------------------------------------------------------------
ConfigureBench(CONTIGUOUS_SPLIT_BENCH copying/contiguous_split_benchmark.cu)
Expand Down
131 changes: 131 additions & 0 deletions cpp/benchmarks/lists/copying/scatter_lists_benchmark.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* 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 <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/synchronization/synchronization.hpp>

#include <cudf/column/column_factories.hpp>
#include <cudf/copying.hpp>
#include <cudf/null_mask.hpp>
#include <cudf/types.hpp>

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

#include <thrust/random.h>
#include <thrust/sequence.h>
#include <thrust/shuffle.h>

#include <cmath>

namespace cudf {

class ScatterLists : public cudf::benchmark {
};

template <class TypeParam, bool coalesce>
void BM_lists_scatter(::benchmark::State& state)
{
auto stream = rmm::cuda_stream_default;
auto mr = rmm::mr::get_current_device_resource();

const size_type base_size{(size_type)state.range(0)};
const size_type num_elements_per_row{(size_type)state.range(1)};
const size_type num_rows = (size_type)ceil(double(base_size) / num_elements_per_row);

auto source_base_col = make_fixed_width_column(
data_type{type_to_id<TypeParam>()}, base_size, mask_state::UNALLOCATED, stream, mr);
auto target_base_col = make_fixed_width_column(
data_type{type_to_id<TypeParam>()}, base_size, mask_state::UNALLOCATED, stream, mr);
thrust::sequence(rmm::exec_policy(stream),
source_base_col->mutable_view().begin<TypeParam>(),
source_base_col->mutable_view().end<TypeParam>());
thrust::sequence(rmm::exec_policy(stream),
target_base_col->mutable_view().begin<TypeParam>(),
target_base_col->mutable_view().end<TypeParam>());

auto source_offsets = make_fixed_width_column(
data_type{type_to_id<offset_type>()}, num_rows + 1, mask_state::UNALLOCATED, stream, mr);
auto target_offsets = make_fixed_width_column(
data_type{type_to_id<offset_type>()}, num_rows + 1, mask_state::UNALLOCATED, stream, mr);

thrust::sequence(rmm::exec_policy(stream),
source_offsets->mutable_view().begin<offset_type>(),
source_offsets->mutable_view().end<offset_type>(),
0,
num_elements_per_row);
thrust::sequence(rmm::exec_policy(stream),
target_offsets->mutable_view().begin<offset_type>(),
target_offsets->mutable_view().end<offset_type>(),
0,
num_elements_per_row);

auto source = make_lists_column(num_rows,
std::move(source_offsets),
std::move(source_base_col),
0,
cudf::create_null_mask(num_rows, mask_state::UNALLOCATED),
stream,
mr);
auto target = make_lists_column(num_rows,
std::move(target_offsets),
std::move(target_base_col),
0,
cudf::create_null_mask(num_rows, mask_state::UNALLOCATED),
stream,
mr);

auto scatter_map = make_fixed_width_column(
data_type{type_to_id<size_type>()}, num_rows, mask_state::UNALLOCATED, stream, mr);
auto m_scatter_map = scatter_map->mutable_view();
thrust::sequence(rmm::exec_policy(stream),
m_scatter_map.begin<size_type>(),
m_scatter_map.end<size_type>(),
num_rows - 1,
-1);

if (not coalesce) {
thrust::default_random_engine g;
thrust::shuffle(rmm::exec_policy(stream),
m_scatter_map.begin<size_type>(),
m_scatter_map.begin<size_type>(),
g);
}

for (auto _ : state) {
cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0
scatter(table_view{{*source}}, *scatter_map, table_view{{*target}}, false, mr);
}

state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) * state.range(0) * 2 *
sizeof(TypeParam));
}

#define SBM_BENCHMARK_DEFINE(name, type, coalesce) \
BENCHMARK_DEFINE_F(ScatterLists, name)(::benchmark::State & state) \
{ \
BM_lists_scatter<type, coalesce>(state); \
} \
BENCHMARK_REGISTER_F(ScatterLists, name) \
->RangeMultiplier(8) \
->Ranges({{1 << 10, 1 << 25}, {64, 2048}}) /* 1K-1B rows, 64-2048 elements */ \
->UseManualTime();

SBM_BENCHMARK_DEFINE(double_type_colesce_o, double, true);
SBM_BENCHMARK_DEFINE(double_type_colesce_x, double, false);

} // namespace cudf
Loading