Skip to content

Commit 3bea05e

Browse files
authored
[UR][Offload] Even more device info queries (#20203)
A lot of these are lifted from the HIP/Cuda backends and represent "minimum supported" levels for the appropriate features.
1 parent 4da7e66 commit 3bea05e

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

unified-runtime/source/adapters/offload/device.cpp

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
189189

190190
return UR_RESULT_SUCCESS;
191191
}
192+
case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: {
193+
// OL dimensions are uint32_t while UR is size_t, so they need to be mapped
194+
if (pPropSizeRet) {
195+
*pPropSizeRet = sizeof(size_t) * 3;
196+
}
197+
198+
if (pPropValue) {
199+
ol_dimensions_t olVec;
200+
size_t *urVec = reinterpret_cast<size_t *>(pPropValue);
201+
OL_RETURN_ON_ERR(olGetDeviceInfo(
202+
hDevice->OffloadDevice, OL_DEVICE_INFO_MAX_WORK_SIZE_PER_DIMENSION,
203+
sizeof(olVec), &olVec));
204+
205+
urVec[0] = olVec.x;
206+
urVec[1] = olVec.y;
207+
urVec[2] = olVec.z;
208+
}
209+
210+
return UR_RESULT_SUCCESS;
211+
}
212+
192213
// Unimplemented features
193214
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
194215
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
@@ -200,6 +221,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
200221
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORT:
201222
case UR_DEVICE_INFO_ASYNC_BARRIER:
202223
case UR_DEVICE_INFO_ESIMD_SUPPORT:
224+
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS:
225+
case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT:
203226
// TODO: Atomic queries in Offload
204227
case UR_DEVICE_INFO_ATOMIC_64:
205228
case UR_DEVICE_INFO_IMAGE_SRGB:
@@ -244,6 +267,91 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
244267
// device.
245268
return ReturnValue("");
246269
}
270+
case UR_DEVICE_INFO_ENDIAN_LITTLE: {
271+
return ReturnValue(ur_bool_t{true});
272+
}
273+
case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: {
274+
// Liboffload has no profiling timers yet
275+
return ReturnValue(size_t{0});
276+
}
277+
case UR_DEVICE_INFO_LOCAL_MEM_TYPE: {
278+
return ReturnValue(UR_DEVICE_LOCAL_MEM_TYPE_NONE);
279+
}
280+
case UR_DEVICE_INFO_LOCAL_MEM_SIZE: {
281+
return ReturnValue(size_t{0});
282+
}
283+
284+
// The following properties are lifted from the minimum supported
285+
// intersection of the HIP and CUDA backends until liboffload adds a specific
286+
// query
287+
case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
288+
ur_memory_order_capability_flags_t Capabilities =
289+
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED |
290+
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE |
291+
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE |
292+
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL;
293+
294+
return ReturnValue(Capabilities);
295+
}
296+
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
297+
ur_memory_scope_capability_flags_t Capabilities =
298+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
299+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
300+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
301+
return ReturnValue(Capabilities);
302+
}
303+
case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {
304+
ur_memory_order_capability_flags_t Capabilities =
305+
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED |
306+
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE |
307+
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE;
308+
return ReturnValue(Capabilities);
309+
}
310+
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
311+
ur_memory_scope_capability_flags_t Capabilities =
312+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
313+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
314+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
315+
return ReturnValue(Capabilities);
316+
}
317+
case UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE:
318+
return ReturnValue(false);
319+
case UR_DEVICE_INFO_EXECUTION_CAPABILITIES: {
320+
auto Capability = ur_device_exec_capability_flags_t{
321+
UR_DEVICE_EXEC_CAPABILITY_FLAG_KERNEL};
322+
return ReturnValue(Capability);
323+
}
324+
case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: {
325+
return ReturnValue(int32_t{1});
326+
}
327+
case UR_DEVICE_INFO_MAX_PARAMETER_SIZE: {
328+
return ReturnValue(size_t{4000});
329+
}
330+
case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: {
331+
return ReturnValue(uint32_t{9});
332+
}
333+
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: {
334+
return ReturnValue(ur_bool_t{true});
335+
}
336+
case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: {
337+
// The minimum value for the FULL profile is 1 MB.
338+
return ReturnValue(size_t(1024));
339+
}
340+
341+
// No image support in liboffload yet, so just return 0 for these properties
342+
case UR_DEVICE_INFO_IMAGE2D_MAX_HEIGHT:
343+
case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH:
344+
case UR_DEVICE_INFO_IMAGE3D_MAX_HEIGHT:
345+
case UR_DEVICE_INFO_IMAGE3D_MAX_WIDTH:
346+
case UR_DEVICE_INFO_IMAGE3D_MAX_DEPTH:
347+
case UR_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE:
348+
case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE:
349+
return ReturnValue(size_t{0});
350+
case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS:
351+
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
352+
case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS:
353+
case UR_DEVICE_INFO_MAX_SAMPLERS:
354+
return ReturnValue(uint32_t{0});
247355
default:
248356
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
249357
}

0 commit comments

Comments
 (0)