Skip to content

Commit

Permalink
Retry clSVMAlloc in SVMAllocation after running GC
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Sep 8, 2022
1 parent 2c2eaa7 commit e2cb9d7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/wrap_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3646,10 +3646,19 @@ namespace pyopencl
"supplying an out-of-order queue to SVMAllocation is invalid");
}

PYOPENCL_PRINT_CALL_TRACE("clSVMalloc");
m_allocation = clSVMAlloc(
ctx->data(),
flags, size, alignment);
int try_count = 0;
while (try_count < 2)
{
PYOPENCL_PRINT_CALL_TRACE("clSVMalloc");
m_allocation = clSVMAlloc(
ctx->data(),
flags, size, alignment);
if (m_allocation)
return;

++try_count;
run_python_gc();
}

if (!m_allocation)
throw pyopencl::error("clSVMAlloc", CL_OUT_OF_RESOURCES);
Expand Down

0 comments on commit e2cb9d7

Please sign in to comment.