Skip to content

Commit 958f35a

Browse files
committed
[L0 v2] properly handle shared device-read-only allocations
1 parent 70d6207 commit 958f35a

File tree

1 file changed

+13
-2
lines changed
  • source/adapters/level_zero/v2

1 file changed

+13
-2
lines changed

source/adapters/level_zero/v2/usm.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ ur_usm_pool_handle_t_::getPool(const usm::pool_descriptor &desc) {
192192
return pool;
193193
}
194194

195+
static ur_usm_device_mem_flags_t getDeviceFlags(const ur_usm_desc_t *pUSMDesc) {
196+
if (auto devDesc = find_stype_node<ur_usm_device_desc_t>(pUSMDesc)) {
197+
return devDesc->flags;
198+
}
199+
200+
return 0;
201+
}
202+
195203
ur_result_t ur_usm_pool_handle_t_::allocate(
196204
/// [in] handle of the context object
197205
ur_context_handle_t hContext,
@@ -204,8 +212,11 @@ ur_result_t ur_usm_pool_handle_t_::allocate(
204212
return UR_RESULT_ERROR_INVALID_VALUE;
205213
}
206214

207-
auto umfPool =
208-
getPool(usm::pool_descriptor{this, hContext, hDevice, type, false});
215+
auto deviceFlags = getDeviceFlags(pUSMDesc);
216+
217+
auto umfPool = getPool(usm::pool_descriptor{
218+
this, hContext, hDevice, type,
219+
bool(deviceFlags & UR_USM_DEVICE_MEM_FLAG_DEVICE_READ_ONLY)});
209220
if (!umfPool) {
210221
return UR_RESULT_ERROR_INVALID_ARGUMENT;
211222
}

0 commit comments

Comments
 (0)