Skip to content

Commit

Permalink
Fix a bunch of minor issues with query implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Feb 12, 2024
1 parent c4ce13a commit 076d1e5
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 73 deletions.
13 changes: 5 additions & 8 deletions source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
int Major = 0;
UR_CHECK_ERROR(cuDeviceGetAttribute(
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, hDevice->get()));
uint64_t Capabilities =
ur_memory_scope_capability_flags_t Capabilities =
(Major >= 7) ? UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP |
Expand Down Expand Up @@ -288,12 +288,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

return ReturnValue(Enabled);
}
case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS: {
// This call doesn't match to CUDA as it doesn't have images, but instead
// surfaces and textures. No clear call in the CUDA API to determine this,
// but some searching found as of SM 2.x 128 are supported.
return ReturnValue(128u);
}
//
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
case UR_DEVICE_INFO_MAX_READ_IMAGE_ARGS:
case UR_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS: {
// This call doesn't match to CUDA as it doesn't have images, but instead
// surfaces and textures. No clear call in the CUDA API to determine this,
Expand Down Expand Up @@ -1026,13 +1023,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
// These two are exclusive of L0.
return ReturnValue(0);
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
case UR_DEVICE_INFO_GPU_EU_COUNT:
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
case UR_DEVICE_INFO_GPU_EU_SLICES:
case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE:
case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
case UR_DEVICE_INFO_IP_VERSION:
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;

default:
Expand Down
20 changes: 14 additions & 6 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
// Because scopes are hierarchical, wider scopes support all narrower
// scopes. At a minimum, each device must support WORK_ITEM, SUB_GROUP and
// WORK_GROUP. (https://github.com/KhronosGroup/SYCL-Docs/pull/382)
uint64_t Capabilities = UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
ur_memory_scope_capability_flags_t Capabilities =
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
Expand Down Expand Up @@ -827,6 +828,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
// These two are exclusive of L0.
return ReturnValue(0);
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
return ReturnValue(false);
case UR_DEVICE_INFO_BFLOAT16:
return ReturnValue(true);
/* This functionality only works with the cuda backend, see */
case UR_DEVICE_INFO_ASYNC_BARRIER:
return ReturnValue(false);
case UR_DEVICE_INFO_IL_VERSION:
return ReturnValue("");

// TODO: Investigate if this information is available on HIP.
case UR_DEVICE_INFO_GPU_EU_COUNT:
Expand All @@ -836,9 +846,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
case UR_DEVICE_INFO_BFLOAT16:
case UR_DEVICE_INFO_IL_VERSION:
case UR_DEVICE_INFO_ASYNC_BARRIER:
case UR_DEVICE_INFO_IP_VERSION:
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;

default:
Expand Down
48 changes: 26 additions & 22 deletions source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
}
case UR_DEVICE_INFO_ATOMIC_64:
return ReturnValue(
static_cast<uint32_t>(Device->ZeDeviceModuleProperties->flags &
ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS));
static_cast<ur_bool_t>(Device->ZeDeviceModuleProperties->flags &
ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS));
case UR_DEVICE_INFO_EXTENSIONS: {
// Convention adopted from OpenCL:
// "Returns a space separated list of extension names (the extension
Expand Down Expand Up @@ -256,11 +256,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
// > The application must only use the module for the device, or its
// > sub-devices, which was provided during creation.
case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE:
return ReturnValue(uint32_t{0});
return ReturnValue(static_cast<ur_bool_t>(false));
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
return ReturnValue(static_cast<uint32_t>(true));
return ReturnValue(static_cast<ur_bool_t>(true));
case UR_DEVICE_INFO_LINKER_AVAILABLE:
return ReturnValue(static_cast<uint32_t>(true));
return ReturnValue(static_cast<ur_bool_t>(true));
case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: {
uint32_t MaxComputeUnits =
Device->ZeDeviceProperties->numEUsPerSubslice *
Expand Down Expand Up @@ -323,14 +323,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return ReturnValue(
uint64_t{Device->ZeDeviceComputeProperties->maxSharedLocalMemory});
case UR_DEVICE_INFO_IMAGE_SUPPORTED:
return ReturnValue(static_cast<uint32_t>(
return ReturnValue(static_cast<ur_bool_t>(
Device->ZeDeviceImageProperties->maxImageDims1D > 0));
case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY:
return ReturnValue(
static_cast<uint32_t>((Device->ZeDeviceProperties->flags &
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0));
static_cast<ur_bool_t>((Device->ZeDeviceProperties->flags &
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0));
case UR_DEVICE_INFO_AVAILABLE:
return ReturnValue(static_cast<uint32_t>(ZeDevice ? true : false));
return ReturnValue(static_cast<ur_bool_t>(ZeDevice ? true : false));
case UR_DEVICE_INFO_VENDOR:
// TODO: Level-Zero does not return vendor's name at the moment
// only the ID.
Expand Down Expand Up @@ -411,7 +411,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
case UR_EXT_DEVICE_INFO_OPENCL_C_VERSION:
return ReturnValue("");
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
return ReturnValue(static_cast<uint32_t>(true));
return ReturnValue(static_cast<ur_bool_t>(true));
case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE:
return ReturnValue(
size_t{Device->ZeDeviceModuleProperties->printfBufferSize});
Expand All @@ -428,10 +428,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return ReturnValue(ur_device_exec_capability_flag_t{
UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL});
case UR_DEVICE_INFO_ENDIAN_LITTLE:
return ReturnValue(static_cast<uint32_t>(true));
return ReturnValue(static_cast<ur_bool_t>(true));
case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT:
return ReturnValue(static_cast<uint32_t>(Device->ZeDeviceProperties->flags &
ZE_DEVICE_PROPERTY_FLAG_ECC));
return ReturnValue(static_cast<ur_bool_t>(
Device->ZeDeviceProperties->flags & ZE_DEVICE_PROPERTY_FLAG_ECC));
case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION:
return ReturnValue(
static_cast<size_t>(Device->ZeDeviceProperties->timerResolution));
Expand Down Expand Up @@ -605,7 +605,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
}
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
// TODO: Not supported yet. Needs to be updated after support is added.
return ReturnValue(static_cast<uint32_t>(false));
return ReturnValue(static_cast<ur_bool_t>(false));
}
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
// ze_device_compute_properties.subGroupSizes is in uint32_t whereas the
Expand Down Expand Up @@ -782,9 +782,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice});
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU});
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
// currently not supported in level zero runtime
return UR_RESULT_ERROR_INVALID_VALUE;
case UR_DEVICE_INFO_BFLOAT16: {
// bfloat16 math functions are not yet supported on Intel GPUs.
return ReturnValue(bool{false});
Expand Down Expand Up @@ -836,9 +833,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return ReturnValue(capabilities);
}
case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT:
return ReturnValue(uint32_t{false});
return ReturnValue(static_cast<ur_bool_t>(false));
case UR_DEVICE_INFO_IMAGE_SRGB:
return ReturnValue(uint32_t{false});
return ReturnValue(static_cast<ur_bool_t>(false));

case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: {
Expand All @@ -850,7 +847,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
0)); //__read_write attribute currently undefinde in opencl
}
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: {
return ReturnValue(static_cast<uint32_t>(true));
return ReturnValue(static_cast<ur_bool_t>(true));
}

case UR_DEVICE_INFO_ESIMD_SUPPORT: {
Expand Down Expand Up @@ -915,11 +912,18 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return ze2urResult(errc);
return ReturnValue(UrRootDev);
}
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
case UR_DEVICE_INFO_ASYNC_BARRIER:
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED:
return ReturnValue(static_cast<ur_bool_t>(false));
case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP:
case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH:
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;

default:
urPrint("Unsupported ParamName in urGetDeviceInfo\n");
urPrint("Invalid ParamName in urGetDeviceInfo\n");
urPrint("ParamName=%d(0x%x)\n", ParamName, ParamName);
return UR_RESULT_ERROR_INVALID_VALUE;
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

return UR_RESULT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(
}
case UR_EVENT_INFO_COMMAND_TYPE: {
std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);
return ReturnValue(ur_cast<uint64_t>(Event->CommandType));
return ReturnValue(ur_cast<ur_command_t>(Event->CommandType));
}
case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: {
// Check to see if the event's Queue has an open command list due to
Expand Down
19 changes: 8 additions & 11 deletions source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(
return ReturnValue(Queue->Device);
case UR_QUEUE_INFO_REFERENCE_COUNT:
return ReturnValue(uint32_t{Queue->RefCount.load()});
case UR_QUEUE_INFO_FLAGS:
die("UR_QUEUE_INFO_FLAGS in urQueueGetInfo not implemented\n");
break;
case UR_QUEUE_INFO_SIZE:
die("UR_QUEUE_INFO_SIZE in urQueueGetInfo not implemented\n");
break;
case UR_QUEUE_INFO_DEVICE_DEFAULT:
die("UR_QUEUE_INFO_DEVICE_DEFAULT in urQueueGetInfo not implemented\n");
break;
case UR_QUEUE_INFO_EMPTY: {
// We can exit early if we have in-order queue.
if (Queue->isInOrderQueue()) {
Expand Down Expand Up @@ -249,10 +240,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(
}
return ReturnValue(true);
}
default:
case UR_QUEUE_INFO_FLAGS:
case UR_QUEUE_INFO_SIZE:
case UR_QUEUE_INFO_DEVICE_DEFAULT:
urPrint("Unsupported ParamName in urQueueGetInfo: ParamName=%d(0x%x)\n",
ParamName, ParamName);
return UR_RESULT_ERROR_INVALID_VALUE;
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
default:
urPrint("Unrecognized ParamName in urQueueGetInfo: ParamName=%d(0x%x)\n",
ParamName, ParamName);
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

return UR_RESULT_SUCCESS;
Expand Down
18 changes: 9 additions & 9 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue(true);
}

case UR_DEVICE_INFO_BFLOAT16: {
return ReturnValue(false);
}
case UR_DEVICE_INFO_ATOMIC_64: {
bool Supported = false;
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
Expand Down Expand Up @@ -777,9 +774,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

return ReturnValue(Supported);
}
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: {
return ReturnValue(false);
}
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: {
bool Supported = false;
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
Expand Down Expand Up @@ -820,7 +814,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
case UR_DEVICE_INFO_LINKER_AVAILABLE:
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
/* CL type: cl_bool
* UR type: ur_bool_t */
Expand Down Expand Up @@ -927,6 +920,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
// These two are exclusive of L0.
return ReturnValue(0);
// We can't query to check if these are supported, they will need to be
// manually updated if support is ever implemented.
case UR_DEVICE_INFO_BFLOAT16:
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT:
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
case UR_DEVICE_INFO_ASYNC_BARRIER: {
return ReturnValue(false);
}
/* TODO: Check regularly to see if support is enabled in OpenCL. Intel GPU
* EU device-specific information extensions. Some of the queries are
* enabled by cl_intel_device_attribute_query extension, but it's not yet in
Expand All @@ -947,8 +948,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP:
case UR_DEVICE_INFO_GLOBAL_MEM_FREE:
case UR_DEVICE_INFO_MEMORY_CLOCK_RATE:
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH:
case UR_DEVICE_INFO_ASYNC_BARRIER: {
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
default: {
Expand Down
6 changes: 4 additions & 2 deletions source/adapters/opencl/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ static cl_int mapURKernelInfoToCL(ur_kernel_info_t URPropName) {
return CL_KERNEL_PROGRAM;
case UR_KERNEL_INFO_ATTRIBUTES:
return CL_KERNEL_ATTRIBUTES;
case UR_KERNEL_INFO_NUM_REGS:
return CL_KERNEL_NUM_ARGS;
default:
return -1;
}
Expand All @@ -72,6 +70,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
size_t propSize,
void *pPropValue,
size_t *pPropSizeRet) {
// This is not supported in OpenCL
if (propName == UR_KERNEL_INFO_NUM_REGS) {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
// We need this little bit of ugliness because the UR NUM_ARGS property is
// size_t whereas the CL one is cl_uint. We should consider changing that see
// #1038
Expand Down
1 change: 0 additions & 1 deletion test/conformance/event/event_adapter_level_zero.match
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{OPT}}urEventGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_EVENT_INFO_COMMAND_TYPE
{{OPT}}urEventGetProfilingInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_PROFILING_INFO_COMMAND_QUEUED
{{OPT}}urEventGetProfilingInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_PROFILING_INFO_COMMAND_SUBMIT
{{OPT}}{{Segmentation fault|Aborted}}
4 changes: 0 additions & 4 deletions test/conformance/kernel/kernel_adapter_opencl.match
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
urKernelSetArgValueTest.InvalidKernelArgumentSize/Intel_R__OpenCL___{{.*}}
urKernelSetSpecializationConstantsTest.Success/Intel_R__OpenCL___{{.*}}
urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/Intel_R__OpenCL___{{.*}}
urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/Intel_R__OpenCL___{{.*}}
urKernelSetSpecializationConstantsTest.InvalidSizeCount/Intel_R__OpenCL___{{.*}}
Loading

0 comments on commit 076d1e5

Please sign in to comment.