Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UR][L0] Propagate OOM errors from USMAllocationMakeResident #1022

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ static ur_result_t USMDeviceAllocImpl(void **ResultPtr,
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0,
UR_RESULT_ERROR_INVALID_VALUE);

USMAllocationMakeResident(USMDeviceAllocationForceResidency, Context, Device,
*ResultPtr, Size);
auto Result = USMAllocationMakeResident(USMDeviceAllocationForceResidency,
Context, Device, *ResultPtr, Size);
if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
return Result;
}
return UR_RESULT_SUCCESS;
}

Expand Down Expand Up @@ -225,8 +229,12 @@ static ur_result_t USMSharedAllocImpl(void **ResultPtr,
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0,
UR_RESULT_ERROR_INVALID_VALUE);

USMAllocationMakeResident(USMSharedAllocationForceResidency, Context, Device,
*ResultPtr, Size);
auto Result = USMAllocationMakeResident(USMSharedAllocationForceResidency,
Context, Device, *ResultPtr, Size);
if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
return Result;
}

// TODO: Handle PI_MEM_ALLOC_DEVICE_READ_ONLY.
return UR_RESULT_SUCCESS;
Expand All @@ -247,8 +255,12 @@ static ur_result_t USMHostAllocImpl(void **ResultPtr,
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0,
UR_RESULT_ERROR_INVALID_VALUE);

USMAllocationMakeResident(USMHostAllocationForceResidency, Context, nullptr,
*ResultPtr, Size);
auto Result = USMAllocationMakeResident(USMHostAllocationForceResidency,
Context, nullptr, *ResultPtr, Size);
if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
return Result;
}
return UR_RESULT_SUCCESS;
}

Expand Down