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

Commit 3efed83

Browse files
committed
Skip large allocation tests that exceed device memory.
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.
1 parent 6bce5b7 commit 3efed83

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

test/test_device_merge_sort.cu

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
#include <cstdio>
5151
#include <limits>
52+
#include <new> // for std::bad_alloc
5253
#include <memory>
5354
#include <typeinfo>
5455

@@ -322,12 +323,29 @@ void Test(thrust::default_random_engine &rng)
322323
{
323324
for (unsigned int pow2 = 9; pow2 < 22; pow2 += 2)
324325
{
325-
const unsigned int num_items = 1 << pow2;
326-
AllocateAndTestIterators<DataType, DataType>(num_items);
327-
328-
329-
TestHelper<true>::AllocateAndTest<HugeDataType, DataType>(rng, num_items);
330-
Test<DataType>(rng, num_items);
326+
try
327+
{
328+
const unsigned int num_items = 1 << pow2;
329+
AllocateAndTestIterators<DataType, DataType>(num_items);
330+
331+
TestHelper<true>::AllocateAndTest<HugeDataType, DataType>(rng, num_items);
332+
Test<DataType>(rng, num_items);
333+
}
334+
catch (std::bad_alloc &e)
335+
{
336+
if (pow2 > 20)
337+
{ // Some cards don't have enough memory for large allocations, these
338+
// can be skipped.
339+
printf("Skipping large memory test. (num_items=2^%u): %s\n",
340+
pow2,
341+
e.what());
342+
}
343+
else
344+
{ // For smaller problem sizes, treat as an error:
345+
printf("Error (num_items=2^%u): %s", pow2, e.what());
346+
throw;
347+
}
348+
}
331349
}
332350
}
333351

0 commit comments

Comments
 (0)