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

Commit

Permalink
Make out_of_memory_recovery test trigger OOM faster.
Browse files Browse the repository at this point in the history
Fixes #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.
  • Loading branch information
alliepiper committed Jun 10, 2020
1 parent 640499d commit 5a4abe7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions testing/out_of_memory_recovery.cu
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// Regression test for NVBug 2720132.
//
// Summary of 2720132:
//
// 1. The large allocation fails due to running out of memory.
// 2. A `thrust::system::system_error` exception is thrown.
// 3. Local objects are destroyed as the stack is unwound, leading to the destruction of `x`.
// 4. `x` runs a parallel algorithm in its destructor to call the destructors of all of its elements.
// 5. Launching that parallel algorithm fails because of the prior CUDA out of memory error.
// 6. A `thrust::system::system_error` exception is thrown.
// 7. Because we've already got an active exception, `terminate` is called.

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

for (thrust::detail::uint64_t n = 1 ;; n <<= 1)
thrust::device_vector<thrust::detail::uint32_t> y(n);
thrust::device_vector<thrust::detail::uint32_t> y(0x00ffffffffffffff);
}
catch (...) { }
}
Expand Down

0 comments on commit 5a4abe7

Please sign in to comment.