Skip to content

Commit

Permalink
Rename concatenate_tests.cu to .cpp (#8555)
Browse files Browse the repository at this point in the history
Found this file can be changed to .cpp by modifying the `TypedColumnTest` to build its test data in the CPU and then cudaMemcpy it to the GPU. The remain ~1000 lines did not require any updates. Only a few `lists_column_wrapper` ctors needed to be corrected as similar to PR #8527.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - https://github.com/nvdbaranec
  - Mark Harris (https://github.com/harrism)

URL: #8555
  • Loading branch information
davidwendt authored Jun 23, 2021
1 parent be62be3 commit 20c807d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ ConfigureTest(SORT_TEST
###################################################################################################
# - copying tests ---------------------------------------------------------------------------------
ConfigureTest(COPYING_TEST
copying/concatenate_tests.cu
copying/concatenate_tests.cpp
copying/copy_if_else_nested_tests.cpp
copying/copy_range_tests.cpp
copying/copy_tests.cu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
#include <cudf/fixed_point/fixed_point.hpp>
#include <cudf/table/table.hpp>

#include <rmm/device_uvector.hpp>

#include <thrust/iterator/counting_iterator.h>
#include <thrust/sequence.h>

#include <numeric>
#include <string>

template <typename T>
Expand All @@ -53,14 +51,21 @@ struct TypedColumnTest : public cudf::test::BaseFixture {
static std::size_t mask_size() { return 100; }
cudf::data_type type() { return cudf::data_type{cudf::type_to_id<T>()}; }

TypedColumnTest()
: data{_num_elements * cudf::size_of(type()), rmm::cuda_stream_default},
mask{cudf::bitmask_allocation_size_bytes(_num_elements), rmm::cuda_stream_default}
TypedColumnTest(rmm::cuda_stream_view stream = rmm::cuda_stream_default)
: data{_num_elements * cudf::size_of(type()), stream},
mask{cudf::bitmask_allocation_size_bytes(_num_elements), stream}
{
auto typed_data = static_cast<char*>(data.data());
auto typed_mask = static_cast<char*>(mask.data());
thrust::sequence(thrust::device, typed_data, typed_data + data_size());
thrust::sequence(thrust::device, typed_mask, typed_mask + mask_size());
std::vector<char> h_data(data_size());
std::iota(h_data.begin(), h_data.end(), char{0});
std::vector<char> h_mask(mask_size());
std::iota(h_mask.begin(), h_mask.end(), char{0});
CUDA_TRY(cudaMemcpyAsync(
typed_data, h_data.data(), data_size(), cudaMemcpyHostToDevice, stream.value()));
CUDA_TRY(cudaMemcpyAsync(
typed_mask, h_mask.data(), mask_size(), cudaMemcpyHostToDevice, stream.value()));
stream.synchronize();
}

cudf::size_type num_elements() { return _num_elements; }
Expand Down Expand Up @@ -703,7 +708,7 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists)
}

{
cudf::test::lists_column_wrapper<int> a{{LCW{}}};
cudf::test::lists_column_wrapper<int> a{LCW{}};
cudf::test::lists_column_wrapper<int> b{4, 5, 6, 7};
cudf::test::lists_column_wrapper<int> expected{LCW{}, {4, 5, 6, 7}};

Expand All @@ -713,7 +718,7 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists)
}

{
cudf::test::lists_column_wrapper<int> a{{LCW{}}}, b{{LCW{}}}, c{{LCW{}}};
cudf::test::lists_column_wrapper<int> a{LCW{}}, b{LCW{}}, c{LCW{}};
cudf::test::lists_column_wrapper<int> d{4, 5, 6, 7};
cudf::test::lists_column_wrapper<int> expected{LCW{}, LCW{}, LCW{}, {4, 5, 6, 7}};

Expand All @@ -724,7 +729,7 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists)

{
cudf::test::lists_column_wrapper<int> a{1, 2};
cudf::test::lists_column_wrapper<int> b{{LCW{}}}, c{{LCW{}}};
cudf::test::lists_column_wrapper<int> b{LCW{}}, c{LCW{}};
cudf::test::lists_column_wrapper<int> d{4, 5, 6, 7};
cudf::test::lists_column_wrapper<int> expected{{1, 2}, LCW{}, LCW{}, {4, 5, 6, 7}};

Expand Down Expand Up @@ -797,10 +802,10 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists)
// empty lists in lists_column_wrapper documentation
using LCW = cudf::test::lists_column_wrapper<T>;
{
cudf::test::lists_column_wrapper<T> a{{{LCW{}}}, {{0, 1}, {2, 3}}};
cudf::test::lists_column_wrapper<T> a{{LCW{}}, {{0, 1}, {2, 3}}};
cudf::test::lists_column_wrapper<int> b{{{6, 7}}, {LCW{}, {11, 12}}};
cudf::test::lists_column_wrapper<int> expected{
{{LCW{}}}, {{0, 1}, {2, 3}}, {{6, 7}}, {LCW{}, {11, 12}}};
{LCW{}}, {{0, 1}, {2, 3}}, {{6, 7}}, {LCW{}, {11, 12}}};

auto result = cudf::concatenate(std::vector<column_view>({a, b}));

Expand All @@ -810,23 +815,23 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists)
{
cudf::test::lists_column_wrapper<int> a{
{{{0, 1, 2}, LCW{}}, {{5}, {6, 7}}, {{8, 9}}},
{{{LCW{}}}, {{17, 18}, {19, 20}}},
{{{LCW{}}}},
{{LCW{}}, {{17, 18}, {19, 20}}},
{{LCW{}}},
{{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}}};

cudf::test::lists_column_wrapper<int> b{
{{{21, 22}, {23, 24}}, {LCW{}, {26, 27}}, {{28, 29, 30}}},
{{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}},
{{{LCW{}}}}};
{{LCW{}}}};

cudf::test::lists_column_wrapper<int> expected{
{{{0, 1, 2}, LCW{}}, {{5}, {6, 7}}, {{8, 9}}},
{{{LCW{}}}, {{17, 18}, {19, 20}}},
{{{LCW{}}}},
{{LCW{}}, {{17, 18}, {19, 20}}},
{{LCW{}}},
{{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}},
{{{21, 22}, {23, 24}}, {LCW{}, {26, 27}}, {{28, 29, 30}}},
{{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}},
{{{LCW{}}}}};
{{LCW{}}}};

auto result = cudf::concatenate(std::vector<column_view>({a, b}));

Expand Down

0 comments on commit 20c807d

Please sign in to comment.