Skip to content

Commit 08f14c1

Browse files
committed
Fix a bunch of minor issues with query implementations.
1 parent c4ce13a commit 08f14c1

File tree

8 files changed

+67
-60
lines changed

8 files changed

+67
-60
lines changed

source/adapters/cuda/device.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
207207
int Major = 0;
208208
UR_CHECK_ERROR(cuDeviceGetAttribute(
209209
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, hDevice->get()));
210-
uint64_t Capabilities =
210+
ur_memory_scope_capability_flags_t Capabilities =
211211
(Major >= 7) ? UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
212212
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
213213
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP |
@@ -288,12 +288,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
288288

289289
return ReturnValue(Enabled);
290290
}
291-
case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: {
292-
// This call doesn't match to CUDA as it doesn't have images, but instead
293-
// surfaces and textures. No clear call in the CUDA API to determine this,
294-
// but some searching found as of SM 2.x 128 are supported.
295-
return ReturnValue(128u);
296-
}
291+
//
292+
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
293+
case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS:
297294
case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: {
298295
// This call doesn't match to CUDA as it doesn't have images, but instead
299296
// surfaces and textures. No clear call in the CUDA API to determine this,
@@ -1026,13 +1023,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10261023
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10271024
// These two are exclusive of L0.
10281025
return ReturnValue(0);
1029-
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10301026
case UR_DEVICE_INFO_GPU_EU_COUNT:
10311027
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
10321028
case UR_DEVICE_INFO_GPU_EU_SLICES:
10331029
case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE:
10341030
case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
10351031
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
1032+
case UR_DEVICE_INFO_IP_VERSION:
10361033
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
10371034

10381035
default:

source/adapters/hip/device.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
752752
// Because scopes are hierarchical, wider scopes support all narrower
753753
// scopes. At a minimum, each device must support WORK_ITEM, SUB_GROUP and
754754
// WORK_GROUP. (https://github.com/KhronosGroup/SYCL-Docs/pull/382)
755-
uint64_t Capabilities = UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
756-
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
757-
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
755+
ur_memory_scope_capability_flags_t Capabilities =
756+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
757+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
758+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
758759
return ReturnValue(Capabilities);
759760
}
760761
case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
@@ -827,6 +828,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
827828
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
828829
// These two are exclusive of L0.
829830
return ReturnValue(0);
831+
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
832+
return ReturnValue(false);
833+
case UR_DEVICE_INFO_BFLOAT16:
834+
return ReturnValue(true);
835+
/* This functionality only works with the cuda backend, see */
836+
case UR_DEVICE_INFO_ASYNC_BARRIER:
837+
return ReturnValue(false);
838+
case UR_DEVICE_INFO_IL_VERSION:
839+
return ReturnValue("");
830840

831841
// TODO: Investigate if this information is available on HIP.
832842
case UR_DEVICE_INFO_GPU_EU_COUNT:
@@ -836,9 +846,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
836846
case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
837847
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
838848
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
839-
case UR_DEVICE_INFO_BFLOAT16:
840-
case UR_DEVICE_INFO_IL_VERSION:
841-
case UR_DEVICE_INFO_ASYNC_BARRIER:
849+
case UR_DEVICE_INFO_IP_VERSION:
842850
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
843851

844852
default:

source/adapters/level_zero/device.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
188188
}
189189
case UR_DEVICE_INFO_ATOMIC_64:
190190
return ReturnValue(
191-
static_cast<uint32_t>(Device->ZeDeviceModuleProperties->flags &
192-
ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS));
191+
static_cast<ur_bool_t>(Device->ZeDeviceModuleProperties->flags &
192+
ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS));
193193
case UR_DEVICE_INFO_EXTENSIONS: {
194194
// Convention adopted from OpenCL:
195195
// "Returns a space separated list of extension names (the extension
@@ -256,11 +256,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
256256
// > The application must only use the module for the device, or its
257257
// > sub-devices, which was provided during creation.
258258
case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE:
259-
return ReturnValue(uint32_t{0});
259+
return ReturnValue(static_cast<ur_bool_t>(false));
260260
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
261-
return ReturnValue(static_cast<uint32_t>(true));
261+
return ReturnValue(static_cast<ur_bool_t>(true));
262262
case UR_DEVICE_INFO_LINKER_AVAILABLE:
263-
return ReturnValue(static_cast<uint32_t>(true));
263+
return ReturnValue(static_cast<ur_bool_t>(true));
264264
case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: {
265265
uint32_t MaxComputeUnits =
266266
Device->ZeDeviceProperties->numEUsPerSubslice *
@@ -323,14 +323,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
323323
return ReturnValue(
324324
uint64_t{Device->ZeDeviceComputeProperties->maxSharedLocalMemory});
325325
case UR_DEVICE_INFO_IMAGE_SUPPORTED:
326-
return ReturnValue(static_cast<uint32_t>(
326+
return ReturnValue(static_cast<ur_bool_t>(
327327
Device->ZeDeviceImageProperties->maxImageDims1D > 0));
328328
case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY:
329329
return ReturnValue(
330-
static_cast<uint32_t>((Device->ZeDeviceProperties->flags &
331-
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0));
330+
static_cast<ur_bool_t>((Device->ZeDeviceProperties->flags &
331+
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0));
332332
case UR_DEVICE_INFO_AVAILABLE:
333-
return ReturnValue(static_cast<uint32_t>(ZeDevice ? true : false));
333+
return ReturnValue(static_cast<ur_bool_t>(ZeDevice ? true : false));
334334
case UR_DEVICE_INFO_VENDOR:
335335
// TODO: Level-Zero does not return vendor's name at the moment
336336
// only the ID.
@@ -411,7 +411,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
411411
case UR_EXT_DEVICE_INFO_OPENCL_C_VERSION:
412412
return ReturnValue("");
413413
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
414-
return ReturnValue(static_cast<uint32_t>(true));
414+
return ReturnValue(static_cast<ur_bool_t>(true));
415415
case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE:
416416
return ReturnValue(
417417
size_t{Device->ZeDeviceModuleProperties->printfBufferSize});
@@ -428,10 +428,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
428428
return ReturnValue(ur_device_exec_capability_flag_t{
429429
UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL});
430430
case UR_DEVICE_INFO_ENDIAN_LITTLE:
431-
return ReturnValue(static_cast<uint32_t>(true));
431+
return ReturnValue(static_cast<ur_bool_t>(true));
432432
case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT:
433-
return ReturnValue(static_cast<uint32_t>(Device->ZeDeviceProperties->flags &
434-
ZE_DEVICE_PROPERTY_FLAG_ECC));
433+
return ReturnValue(static_cast<ur_bool_t>(
434+
Device->ZeDeviceProperties->flags & ZE_DEVICE_PROPERTY_FLAG_ECC));
435435
case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION:
436436
return ReturnValue(
437437
static_cast<size_t>(Device->ZeDeviceProperties->timerResolution));
@@ -605,7 +605,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
605605
}
606606
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
607607
// TODO: Not supported yet. Needs to be updated after support is added.
608-
return ReturnValue(static_cast<uint32_t>(false));
608+
return ReturnValue(static_cast<ur_bool_t>(false));
609609
}
610610
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
611611
// ze_device_compute_properties.subGroupSizes is in uint32_t whereas the
@@ -782,9 +782,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
782782
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice});
783783
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
784784
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU});
785-
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
786-
// currently not supported in level zero runtime
787-
return UR_RESULT_ERROR_INVALID_VALUE;
788785
case UR_DEVICE_INFO_BFLOAT16: {
789786
// bfloat16 math functions are not yet supported on Intel GPUs.
790787
return ReturnValue(bool{false});
@@ -836,9 +833,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
836833
return ReturnValue(capabilities);
837834
}
838835
case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT:
839-
return ReturnValue(uint32_t{false});
836+
return ReturnValue(static_cast<ur_bool_t>(false));
840837
case UR_DEVICE_INFO_IMAGE_SRGB:
841-
return ReturnValue(uint32_t{false});
838+
return ReturnValue(static_cast<ur_bool_t>(false));
842839

843840
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
844841
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: {
@@ -850,7 +847,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
850847
0)); //__read_write attribute currently undefinde in opencl
851848
}
852849
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: {
853-
return ReturnValue(static_cast<uint32_t>(true));
850+
return ReturnValue(static_cast<ur_bool_t>(true));
854851
}
855852

856853
case UR_DEVICE_INFO_ESIMD_SUPPORT: {
@@ -915,11 +912,18 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
915912
return ze2urResult(errc);
916913
return ReturnValue(UrRootDev);
917914
}
915+
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
916+
case UR_DEVICE_INFO_ASYNC_BARRIER:
917+
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED:
918+
return ReturnValue(static_cast<ur_bool_t>(false));
919+
case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP:
920+
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
921+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
918922

919923
default:
920-
urPrint("Unsupported ParamName in urGetDeviceInfo\n");
924+
urPrint("Invalid ParamName in urGetDeviceInfo\n");
921925
urPrint("ParamName=%d(0x%x)\n", ParamName, ParamName);
922-
return UR_RESULT_ERROR_INVALID_VALUE;
926+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
923927
}
924928

925929
return UR_RESULT_SUCCESS;

source/adapters/level_zero/event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(
388388
}
389389
case UR_EVENT_INFO_COMMAND_TYPE: {
390390
std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);
391-
return ReturnValue(ur_cast<uint64_t>(Event->CommandType));
391+
return ReturnValue(ur_cast<ur_command_t>(Event->CommandType));
392392
}
393393
case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: {
394394
// Check to see if the event's Queue has an open command list due to

source/adapters/level_zero/queue.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(
161161
return ReturnValue(Queue->Device);
162162
case UR_QUEUE_INFO_REFERENCE_COUNT:
163163
return ReturnValue(uint32_t{Queue->RefCount.load()});
164-
case UR_QUEUE_INFO_FLAGS:
165-
die("UR_QUEUE_INFO_FLAGS in urQueueGetInfo not implemented\n");
166-
break;
167-
case UR_QUEUE_INFO_SIZE:
168-
die("UR_QUEUE_INFO_SIZE in urQueueGetInfo not implemented\n");
169-
break;
170-
case UR_QUEUE_INFO_DEVICE_DEFAULT:
171-
die("UR_QUEUE_INFO_DEVICE_DEFAULT in urQueueGetInfo not implemented\n");
172-
break;
173164
case UR_QUEUE_INFO_EMPTY: {
174165
// We can exit early if we have in-order queue.
175166
if (Queue->isInOrderQueue()) {
@@ -249,10 +240,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(
249240
}
250241
return ReturnValue(true);
251242
}
252-
default:
243+
case UR_QUEUE_INFO_FLAGS:
244+
case UR_QUEUE_INFO_SIZE:
245+
case UR_QUEUE_INFO_DEVICE_DEFAULT:
253246
urPrint("Unsupported ParamName in urQueueGetInfo: ParamName=%d(0x%x)\n",
254247
ParamName, ParamName);
255-
return UR_RESULT_ERROR_INVALID_VALUE;
248+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
249+
default:
250+
urPrint("Unrecognized ParamName in urQueueGetInfo: ParamName=%d(0x%x)\n",
251+
ParamName, ParamName);
252+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
256253
}
257254

258255
return UR_RESULT_SUCCESS;

source/adapters/opencl/device.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
731731
return ReturnValue(true);
732732
}
733733

734-
case UR_DEVICE_INFO_BFLOAT16: {
735-
return ReturnValue(false);
736-
}
737734
case UR_DEVICE_INFO_ATOMIC_64: {
738735
bool Supported = false;
739736
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
@@ -777,9 +774,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
777774

778775
return ReturnValue(Supported);
779776
}
780-
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: {
781-
return ReturnValue(false);
782-
}
783777
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: {
784778
bool Supported = false;
785779
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
@@ -820,7 +814,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
820814
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
821815
case UR_DEVICE_INFO_LINKER_AVAILABLE:
822816
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
823-
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
824817
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
825818
/* CL type: cl_bool
826819
* UR type: ur_bool_t */
@@ -927,6 +920,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
927920
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
928921
// These two are exclusive of L0.
929922
return ReturnValue(0);
923+
// We can't query to check if these are supported, they will need to be
924+
// manually updated if support is ever implemented.
925+
case UR_DEVICE_INFO_BFLOAT16:
926+
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT:
927+
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
928+
case UR_DEVICE_INFO_ASYNC_BARRIER: {
929+
return ReturnValue(false);
930+
}
930931
/* TODO: Check regularly to see if support is enabled in OpenCL. Intel GPU
931932
* EU device-specific information extensions. Some of the queries are
932933
* enabled by cl_intel_device_attribute_query extension, but it's not yet in
@@ -947,8 +948,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
947948
case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP:
948949
case UR_DEVICE_INFO_GLOBAL_MEM_FREE:
949950
case UR_DEVICE_INFO_MEMORY_CLOCK_RATE:
950-
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH:
951-
case UR_DEVICE_INFO_ASYNC_BARRIER: {
951+
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: {
952952
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
953953
}
954954
default: {

source/adapters/opencl/kernel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ static cl_int mapURKernelInfoToCL(ur_kernel_info_t URPropName) {
6060
return CL_KERNEL_PROGRAM;
6161
case UR_KERNEL_INFO_ATTRIBUTES:
6262
return CL_KERNEL_ATTRIBUTES;
63-
case UR_KERNEL_INFO_NUM_REGS:
64-
return CL_KERNEL_NUM_ARGS;
6563
default:
6664
return -1;
6765
}
@@ -72,6 +70,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
7270
size_t propSize,
7371
void *pPropValue,
7472
size_t *pPropSizeRet) {
73+
// This is not supported in OpenCL
74+
if (propName == UR_KERNEL_INFO_NUM_REGS) {
75+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
76+
}
7577
// We need this little bit of ugliness because the UR NUM_ARGS property is
7678
// size_t whereas the CL one is cl_uint. We should consider changing that see
7779
// #1038
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{OPT}}urEventGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_EVENT_INFO_COMMAND_TYPE
21
{{OPT}}urEventGetProfilingInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_PROFILING_INFO_COMMAND_QUEUED
32
{{OPT}}urEventGetProfilingInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_PROFILING_INFO_COMMAND_SUBMIT
43
{{OPT}}{{Segmentation fault|Aborted}}

0 commit comments

Comments
 (0)