Skip to content

Commit 48021a1

Browse files
committed
Retry clSVMAlloc in SVMAllocation after running GC
1 parent 54712f9 commit 48021a1

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/wrap_cl.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,10 +3646,19 @@ namespace pyopencl
36463646
"supplying an out-of-order queue to SVMAllocation is invalid");
36473647
}
36483648

3649-
PYOPENCL_PRINT_CALL_TRACE("clSVMalloc");
3650-
m_allocation = clSVMAlloc(
3651-
ctx->data(),
3652-
flags, size, alignment);
3649+
int try_count = 0;
3650+
while (try_count < 2)
3651+
{
3652+
PYOPENCL_PRINT_CALL_TRACE("clSVMalloc");
3653+
m_allocation = clSVMAlloc(
3654+
ctx->data(),
3655+
flags, size, alignment);
3656+
if (m_allocation)
3657+
return;
3658+
3659+
++try_count;
3660+
run_python_gc();
3661+
}
36533662

36543663
if (!m_allocation)
36553664
throw pyopencl::error("clSVMAlloc", CL_OUT_OF_RESOURCES);

0 commit comments

Comments
 (0)