Skip to content

Commit

Permalink
handle rmm::out_of_memory instead of std::bad_alloc for retry (#1477)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert (Bobby) Evans <[email protected]>
  • Loading branch information
revans2 authored Oct 6, 2023
1 parent e8219ce commit 93f4d22
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/cpp/src/SparkResourceAdaptorJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,15 +1352,18 @@ class spark_resource_adaptor final : public rmm::mr::device_memory_resource {
void* ret = resource->allocate(num_bytes, stream);
post_alloc_success(tid, likely_spill);
return ret;
} catch (const std::bad_alloc& e) {
} catch (const rmm::out_of_memory& e) {
// rmm::out_of_memory is what is thrown when an allocation failed
// but there are other rmm::bad_alloc exceptions that could be
// thrown as well, which are handled by the std::exception case.
if (!post_alloc_failed(tid, true, likely_spill)) { throw; }
} catch (const std::exception& e) {
post_alloc_failed(tid, false, likely_spill);
throw;
}
}
// we should never reach this point, but just in case
throw std::bad_alloc();
throw rmm::bad_alloc("Internal Error");
}

void do_deallocate(void* p, std::size_t size, rmm::cuda_stream_view stream) override
Expand Down

0 comments on commit 93f4d22

Please sign in to comment.