Skip to content

Commit 4d6499a

Browse files
authored
[UR][L0][L0v2] Remove redundant cleanup from async alloc (#19473)
The current implementation unnecessarily cleans up the freelist when enqueueing new USM allocations. This creates a potential scenario where active allocations present in the freelist could be incorrectly freed.
1 parent 3640695 commit 4d6499a

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

unified-runtime/source/adapters/level_zero/usm.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,17 +1232,10 @@ ur_result_t ur_usm_pool_handle_t_::allocate(ur_context_handle_t Context,
12321232

12331233
*RetMem = umfPoolAlignedMalloc(UmfPool, Size, Alignment);
12341234
if (*RetMem == nullptr) {
1235-
if (Pool->AsyncPool.cleanup()) { // true means that objects were deallocated
1236-
// let's try again
1237-
*RetMem = umfPoolAlignedMalloc(UmfPool, Size, Alignment);
1238-
}
1239-
if (*RetMem == nullptr) {
1240-
auto UmfRet = umfPoolGetLastAllocationError(UmfPool);
1241-
UR_LOG(ERR,
1242-
"enqueueUSMAllocHelper: allocation from the UMF pool {} failed",
1243-
UmfPool);
1244-
return umf::umf2urResult(UmfRet);
1245-
}
1235+
auto UmfRet = umfPoolGetLastAllocationError(UmfPool);
1236+
UR_LOG(ERR, "enqueueUSMAllocHelper: allocation from the UMF pool {} failed",
1237+
UmfPool);
1238+
return umf::umf2urResult(UmfRet);
12461239
}
12471240

12481241
if (IndirectAccessTrackingEnabled) {

unified-runtime/source/adapters/level_zero/v2/usm.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,8 @@ ur_result_t ur_usm_pool_handle_t_::allocate(
230230

231231
*ppRetMem = umfPoolAlignedMalloc(umfPool, size, alignment);
232232
if (*ppRetMem == nullptr) {
233-
if (pool->asyncPool.cleanup()) { // true means that objects were deallocated
234-
// let's try again
235-
*ppRetMem = umfPoolAlignedMalloc(umfPool, size, alignment);
236-
}
237-
if (*ppRetMem == nullptr) {
238-
auto umfRet = umfPoolGetLastAllocationError(umfPool);
239-
return umf::umf2urResult(umfRet);
240-
}
233+
auto umfRet = umfPoolGetLastAllocationError(umfPool);
234+
return umf::umf2urResult(umfRet);
241235
}
242236

243237
size_t usableSize = 0;

0 commit comments

Comments
 (0)