From 24eaba083a484881f5d42aeb4d2b5528c3931a04 Mon Sep 17 00:00:00 2001 From: Mithun RK Date: Tue, 4 May 2021 11:55:42 -0700 Subject: [PATCH] Fix scatter output size for structs. 1. Output struct size must match target column, not source. 2. Test case for #1. 3. Also, move scatter_struct_tests and scatter_list_tests from .cu to .cpp, for faster compile. --- cpp/include/cudf/detail/scatter.cuh | 2 +- cpp/tests/CMakeLists.txt | 4 ++-- ...r_list_tests.cu => scatter_list_tests.cpp} | 2 -- ...ruct_tests.cu => scatter_struct_tests.cpp} | 21 +++++++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) rename cpp/tests/copying/{scatter_list_tests.cu => scatter_list_tests.cpp} (99%) rename cpp/tests/copying/{scatter_struct_tests.cu => scatter_struct_tests.cpp} (93%) diff --git a/cpp/include/cudf/detail/scatter.cuh b/cpp/include/cudf/detail/scatter.cuh index d069ed06cae..68f4adfadc9 100644 --- a/cpp/include/cudf/detail/scatter.cuh +++ b/cpp/include/cudf/detail/scatter.cuh @@ -317,7 +317,7 @@ struct column_scatterer_impl { // Need to put the result column in a vector to call `gather_bitmask` std::vector> result; - result.emplace_back(cudf::make_structs_column(source.size(), + result.emplace_back(cudf::make_structs_column(target.size(), std::move(output_struct_members), 0, rmm::device_buffer{0, stream, mr}, diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 6dd50592274..29dd4319bfc 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -206,8 +206,8 @@ ConfigureTest(COPYING_TEST copying/pack_tests.cu copying/sample_tests.cpp copying/scatter_tests.cpp - copying/scatter_list_tests.cu - copying/scatter_struct_tests.cu + copying/scatter_list_tests.cpp + copying/scatter_struct_tests.cpp copying/segmented_gather_list_tests.cpp copying/shift_tests.cpp copying/slice_tests.cpp diff --git a/cpp/tests/copying/scatter_list_tests.cu b/cpp/tests/copying/scatter_list_tests.cpp similarity index 99% rename from cpp/tests/copying/scatter_list_tests.cu rename to cpp/tests/copying/scatter_list_tests.cpp index 92f1d44c46f..64fdf6d00d5 100644 --- a/cpp/tests/copying/scatter_list_tests.cu +++ b/cpp/tests/copying/scatter_list_tests.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include #include diff --git a/cpp/tests/copying/scatter_struct_tests.cu b/cpp/tests/copying/scatter_struct_tests.cpp similarity index 93% rename from cpp/tests/copying/scatter_struct_tests.cu rename to cpp/tests/copying/scatter_struct_tests.cpp index a9bb1980d53..3993664168b 100644 --- a/cpp/tests/copying/scatter_struct_tests.cu +++ b/cpp/tests/copying/scatter_struct_tests.cpp @@ -291,3 +291,24 @@ TYPED_TEST(TypedStructScatterTest, ScatterStructOfListsTest) auto const scatter_map = int32s_col{-3, -2, -1, 5, 4, 3, 2}.release(); test_scatter(structs_src, structs_tgt, structs_expected, scatter_map); } + +TYPED_TEST(TypedStructScatterTest, ScatterSourceSmallerThanTarget) +{ + using namespace cudf; + using namespace cudf::test; + + using fixed_width = fixed_width_column_wrapper; + using structs_col = structs_column_wrapper; + using scatter_map_col = fixed_width_column_wrapper; + + auto source_child = fixed_width{22, 55}; + auto target_child = fixed_width{0, 1, 2, 3, 4, 5, 6}; + auto expected_child = fixed_width{0, 1, 22, 3, 4, 55, 6}; + + auto const source = structs_col{{source_child}}.release(); + auto const target = structs_col{{target_child}}.release(); + auto const scatter_map = scatter_map_col{2, 5}.release(); + auto const expected = structs_col{{expected_child}}.release(); + + test_scatter(source, target, expected, scatter_map); +}