Skip to content

Commit 5a4abe7

Browse files
committed
Make out_of_memory_recovery test trigger OOM faster.
Fixes NVIDIA#1183. This test is taking up the majority of the test runtime on CPU backends, slowing eating away at RAM/swap for two minutes while the rest of the system gets evicted from RAM and stops responding. Replaced the allocation loop with a single large allocation, now the test runs in ~1ms and doesn't actually allocate significant resources.
1 parent 640499d commit 5a4abe7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

testing/out_of_memory_recovery.cu

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
// Regression test for NVBug 2720132.
2+
//
3+
// Summary of 2720132:
4+
//
5+
// 1. The large allocation fails due to running out of memory.
6+
// 2. A `thrust::system::system_error` exception is thrown.
7+
// 3. Local objects are destroyed as the stack is unwound, leading to the destruction of `x`.
8+
// 4. `x` runs a parallel algorithm in its destructor to call the destructors of all of its elements.
9+
// 5. Launching that parallel algorithm fails because of the prior CUDA out of memory error.
10+
// 6. A `thrust::system::system_error` exception is thrown.
11+
// 7. Because we've already got an active exception, `terminate` is called.
212

313
#include <unittest/unittest.h>
414
#include <thrust/device_vector.h>
@@ -16,8 +26,7 @@ void test_out_of_memory_recovery()
1626
{
1727
thrust::device_vector<non_trivial> x(1);
1828

19-
for (thrust::detail::uint64_t n = 1 ;; n <<= 1)
20-
thrust::device_vector<thrust::detail::uint32_t> y(n);
29+
thrust::device_vector<thrust::detail::uint32_t> y(0x00ffffffffffffff);
2130
}
2231
catch (...) { }
2332
}

0 commit comments

Comments
 (0)