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

Rename concatenate_tests.cu to .cpp #8555

Merged
merged 3 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have stuck with the default stream and just synced it, but this is more general. 👍

}

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{}};
davidwendt marked this conversation as resolved.
Show resolved Hide resolved
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