Skip to content
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
65 changes: 54 additions & 11 deletions projects/rocprim/test/rocprim/test_device_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,21 @@ TYPED_TEST(RocprimDeviceMergeTests, MergeKey)

test_utils::out_of_bounds_flag out_of_bounds;

common::device_ptr<key_type> d_keys_input1(keys_input1);
common::device_ptr<key_type> d_keys_input2(keys_input2);
common::device_ptr<key_type> d_keys_output(keys_output.size());
common::device_ptr<key_type> d_keys_input1;
common::device_ptr<key_type> d_keys_input2;
common::device_ptr<key_type> d_keys_output;

if(!d_keys_input1.resize_with_memory_check(keys_input1.size())
|| !d_keys_input2.resize_with_memory_check(keys_input2.size())
|| !d_keys_output.resize_with_memory_check(keys_output.size()))
{
std::cout << "Out of memory. Skipping test with sizes = {" << size1 << ", " << size2
<< "}" << std::endl;
break;
}

d_keys_input1.store(keys_input1);
d_keys_input2.store(keys_input2);

test_utils::bounds_checking_iterator<key_type> d_keys_checking_output(
d_keys_output.get(),
Expand All @@ -219,7 +231,14 @@ TYPED_TEST(RocprimDeviceMergeTests, MergeKey)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test with sizes = {" << size1 << ", " << size2
<< "}" << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down Expand Up @@ -354,12 +373,29 @@ TYPED_TEST(RocprimDeviceMergeTests, MergeKeyValue)

test_utils::out_of_bounds_flag out_of_bounds;

common::device_ptr<key_type> d_keys_input1(keys_input1);
common::device_ptr<key_type> d_keys_input2(keys_input2);
common::device_ptr<key_type> d_keys_output(keys_output.size());
common::device_ptr<value_type> d_values_input1(values_input1);
common::device_ptr<value_type> d_values_input2(values_input2);
common::device_ptr<value_type> d_values_output(values_output.size());
common::device_ptr<key_type> d_keys_input1;
common::device_ptr<key_type> d_keys_input2;
common::device_ptr<key_type> d_keys_output;
common::device_ptr<value_type> d_values_input1;
common::device_ptr<value_type> d_values_input2;
common::device_ptr<value_type> d_values_output;

if(!d_keys_input1.resize_with_memory_check(keys_input1.size())
|| !d_keys_input2.resize_with_memory_check(keys_input2.size())
|| !d_keys_output.resize_with_memory_check(keys_output.size())
|| !d_values_input1.resize_with_memory_check(values_input1.size())
|| !d_values_input2.resize_with_memory_check(values_input1.size())
|| !d_values_output.resize_with_memory_check(values_output.size()))
{
std::cout << "Out of memory. Skipping test with sizes = {" << size1 << ", " << size2
<< "}" << std::endl;
break;
}

d_keys_input1.store(keys_input1);
d_keys_input2.store(keys_input2);
d_values_input1.store(values_input1);
d_values_input2.store(values_input2);

test_utils::bounds_checking_iterator<key_type> d_keys_checking_output(
d_keys_output.get(),
Expand Down Expand Up @@ -390,7 +426,14 @@ TYPED_TEST(RocprimDeviceMergeTests, MergeKeyValue)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test with sizes = {" << size1 << ", " << size2
<< "}" << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down
52 changes: 41 additions & 11 deletions projects/rocprim/test/rocprim/test_device_merge_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,17 @@ TYPED_TEST(RocprimDeviceSortTests, SortKey)
100,
seed_value); // float16 can't exceed 65504

common::device_ptr<key_type> d_input(input);
common::device_ptr<key_type> d_input;
common::device_ptr<key_type> d_output_alloc;
d_output_alloc.resize(in_place ? 0 : size);

if(!d_input.resize_with_memory_check(size)
|| !d_output_alloc.resize_with_memory_check(in_place ? 0 : size))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_input.store(input);
common::device_ptr<key_type>& d_output = in_place ? d_input : d_output_alloc;

// compare function
Expand All @@ -175,7 +183,13 @@ TYPED_TEST(RocprimDeviceSortTests, SortKey)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down Expand Up @@ -258,15 +272,25 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
std::vector<value_type> values_input(size);
test_utils::iota(values_input.begin(), values_input.end(), 0);

common::device_ptr<key_type> d_keys_input(keys_input);
common::device_ptr<key_type> d_keys_output_alloc;
d_keys_output_alloc.resize(in_place ? 0 : size);
common::device_ptr<key_type> d_keys_input;
common::device_ptr<key_type> d_keys_output_alloc;
common::device_ptr<value_type> d_values_input;
common::device_ptr<value_type> d_values_output_alloc;

if(!d_keys_input.resize_with_memory_check(size)
|| !d_keys_output_alloc.resize_with_memory_check(in_place ? 0 : size)
|| !d_values_input.resize_with_memory_check(size)
|| !d_values_output_alloc.resize_with_memory_check(in_place ? 0 : size))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_keys_input.store(keys_input);
d_values_input.store(values_input);

common::device_ptr<key_type>& d_keys_output
= in_place ? d_keys_input : d_keys_output_alloc;

common::device_ptr<value_type> d_values_input(values_input);
common::device_ptr<value_type> d_values_output_alloc;
d_values_output_alloc.resize(in_place ? 0 : size);
common::device_ptr<value_type>& d_values_output
= in_place ? d_values_input : d_values_output_alloc;

Expand Down Expand Up @@ -302,7 +326,13 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down
106 changes: 86 additions & 20 deletions projects/rocprim/test/rocprim/test_device_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,21 @@ TYPED_TEST(RocprimDevicePartitionTests, Flagged)
std::vector<T> input = test_utils::get_random_data_wrapped<T>(size, 1, 100, seed_value);
std::vector<F> flags = test_utils::get_random_data01<F>(size, 0.25, seed_value);

common::device_ptr<T> d_input(input);
common::device_ptr<F> d_flags(flags);
common::device_ptr<U> d_output(input.size());
common::device_ptr<unsigned int> d_selected_count_output(1);
common::device_ptr<T> d_input;
common::device_ptr<F> d_flags;
common::device_ptr<U> d_output;
common::device_ptr<unsigned int> d_selected_count_output;

if(!d_input.resize_with_memory_check(size) || !d_flags.resize_with_memory_check(size)
|| !d_output.resize_with_memory_check(size)
|| !d_selected_count_output.resize_with_memory_check(1))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_input.store(input);
d_flags.store(flags);

// Calculate expected_selected and expected_rejected results on host
std::vector<U> expected_selected;
Expand Down Expand Up @@ -184,7 +195,13 @@ TYPED_TEST(RocprimDevicePartitionTests, Flagged)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down Expand Up @@ -366,9 +383,18 @@ TYPED_TEST(RocprimDevicePartitionTests, Predicate)
// Generate data
std::vector<T> input = test_utils::get_random_data_wrapped<T>(size, 1, 100, seed_value);

common::device_ptr<T> d_input(input);
common::device_ptr<U> d_output(input.size());
common::device_ptr<unsigned int> d_selected_count_output(1);
common::device_ptr<T> d_input;
common::device_ptr<U> d_output;
common::device_ptr<unsigned int> d_selected_count_output;

if(!d_input.resize_with_memory_check(size) || !d_output.resize_with_memory_check(size)
|| !d_selected_count_output.resize_with_memory_check(1))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_input.store(input);

// Calculate expected_selected and expected_rejected results on host
std::vector<U> expected_selected;
Expand Down Expand Up @@ -406,7 +432,13 @@ TYPED_TEST(RocprimDevicePartitionTests, Predicate)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down Expand Up @@ -496,10 +528,20 @@ TYPED_TEST(RocprimDevicePartitionTests, PredicateTwoWay)
// Generate data
std::vector<T> input = test_utils::get_random_data_wrapped<T>(size, 1, 100, seed_value);

common::device_ptr<T> d_input(input);
common::device_ptr<U> d_selected(input.size());
common::device_ptr<U> d_rejected(input.size());
common::device_ptr<unsigned int> d_selected_count_output(1);
common::device_ptr<T> d_input;
common::device_ptr<U> d_selected;
common::device_ptr<U> d_rejected;
common::device_ptr<unsigned int> d_selected_count_output;

if(!d_input.resize_with_memory_check(size) || !d_selected.resize_with_memory_check(size)
|| !d_rejected.resize_with_memory_check(size)
|| !d_selected_count_output.resize_with_memory_check(1))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_input.store(input);

// Calculate expected_selected and expected_rejected results on host
std::vector<U> expected_selected;
Expand Down Expand Up @@ -537,7 +579,13 @@ TYPED_TEST(RocprimDevicePartitionTests, PredicateTwoWay)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down Expand Up @@ -645,11 +693,23 @@ TYPED_TEST(RocprimDevicePartitionTests, PredicateThreeWay)
// Generate data
const auto input = test_utils::get_random_data_wrapped<T>(size, 1, 100, seed_value);

common::device_ptr<T> d_input(input);
common::device_ptr<U> d_first_output(input.size());
common::device_ptr<U> d_second_output(input.size());
common::device_ptr<U> d_unselected_output(input.size());
common::device_ptr<unsigned int> d_selected_counts(2);
common::device_ptr<T> d_input;
common::device_ptr<U> d_first_output;
common::device_ptr<U> d_second_output;
common::device_ptr<U> d_unselected_output;
common::device_ptr<unsigned int> d_selected_counts;

if(!d_input.resize_with_memory_check(size)
|| !d_first_output.resize_with_memory_check(size)
|| !d_second_output.resize_with_memory_check(size)
|| !d_unselected_output.resize_with_memory_check(size)
|| !d_selected_counts.resize_with_memory_check(2))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

d_input.store(input);

const auto first_op = LessOp<T>{std::get<0>(limits)};
const auto second_op = LessOp<T>{std::get<1>(limits)};
Expand Down Expand Up @@ -696,7 +756,13 @@ TYPED_TEST(RocprimDevicePartitionTests, PredicateThreeWay)
ASSERT_GT(temp_storage_size_bytes, 0);

// allocate temporary storage
common::device_ptr<void> d_temp_storage(temp_storage_size_bytes);
common::device_ptr<void> d_temp_storage;

if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
{
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
break;
}

test_utils::GraphHelper gHelper;
if(TestFixture::use_graphs)
Expand Down
Loading
Loading