Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Skip large allocation tests that exceed device memory.
Browse files Browse the repository at this point in the history
The merge sort test with pow2 >20 fails on GTX 1650. Detect
bad_alloc failures and skip those tests. Tests for smaller
problem sizes will still fail if there's a bad_alloc.
  • Loading branch information
alliepiper committed May 16, 2022
1 parent 4b692e4 commit f037174
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions test/test_device_merge_sort.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

#include <cstdio>
#include <limits>
#include <new> // for std::bad_alloc
#include <memory>
#include <typeinfo>

Expand Down Expand Up @@ -322,12 +323,29 @@ void Test(thrust::default_random_engine &rng)
{
for (unsigned int pow2 = 9; pow2 < 22; pow2 += 2)
{
const unsigned int num_items = 1 << pow2;
AllocateAndTestIterators<DataType, DataType>(num_items);


TestHelper<true>::AllocateAndTest<HugeDataType, DataType>(rng, num_items);
Test<DataType>(rng, num_items);
try
{
const unsigned int num_items = 1 << pow2;
AllocateAndTestIterators<DataType, DataType>(num_items);

TestHelper<true>::AllocateAndTest<HugeDataType, DataType>(rng, num_items);
Test<DataType>(rng, num_items);
}
catch (std::bad_alloc &e)
{
if (pow2 > 20)
{ // Some cards don't have enough memory for large allocations, these
// can be skipped.
printf("Skipping large memory test. (num_items=2^%u): %s\n",
pow2,
e.what());
}
else
{ // For smaller problem sizes, treat as an error:
printf("Error (num_items=2^%u): %s", pow2, e.what());
throw;
}
}
}
}

Expand Down

0 comments on commit f037174

Please sign in to comment.