Skip to content

Commit 4cbc46f

Browse files
committed
Explicitly define which info queries are optional.
This is now reflected in the spec and in the CTS tests. Also includes a number of minor fixes for adapter implementations of related info queries.
1 parent 7241ebf commit 4cbc46f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+485
-230
lines changed

include/ur_api.h

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ urDeviceGetSelected(
14861486
typedef enum ur_device_info_t {
14871487
UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device
14881488
UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device
1489-
UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device
1489+
UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t][optional-query] Id of the device
14901490
UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units
14911491
UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions
14921492
UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes
@@ -1513,7 +1513,7 @@ typedef enum ur_device_info_t {
15131513
UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double
15141514
UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float
15151515
UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz
1516-
UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz
1516+
UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t][optional-query] memory clock frequency in MHz
15171517
UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits
15181518
UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size
15191519
UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported
@@ -1537,7 +1537,8 @@ typedef enum ur_device_info_t {
15371537
UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes
15381538
UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes
15391539
UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes
1540-
UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes
1540+
UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t][optional-query] size of global memory which is free in
1541+
///< bytes
15411542
UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes
15421543
UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel
15431544
UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type
@@ -1594,15 +1595,16 @@ typedef enum ur_device_info_t {
15941595
///< shared memory access
15951596
UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide
15961597
///< shared memory access
1597-
UR_DEVICE_INFO_UUID = 88, ///< [uint8_t[]] return device UUID
1598-
UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address
1599-
UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count
1600-
UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width
1601-
UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices
1602-
UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice
1603-
UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice
1604-
UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU
1605-
UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s
1598+
UR_DEVICE_INFO_UUID = 88, ///< [uint8_t[]][optional-query] return device UUID
1599+
UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]][optional-query] return device PCI address
1600+
UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t][optional-query] return Intel GPU EU count
1601+
UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t][optional-query] return Intel GPU EU SIMD width
1602+
UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t][optional-query] return Intel GPU number of slices
1603+
UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t][optional-query] return Intel GPU EU count per subslice
1604+
UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t][optional-query] return Intel GPU number of subslices per
1605+
///< slice
1606+
UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t][optional-query] return Intel GPU number of threads per EU
1607+
UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t][optional-query] return max memory bandwidth in Mb/s
16061608
UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images
16071609
UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program
16081610
///< build
@@ -1621,17 +1623,18 @@ typedef enum ur_device_info_t {
16211623
///< available for this device.
16221624
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry
16231625
///< point
1624-
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the
1625-
///< device.
1626+
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t][optional-query] return the width in bits of the memory bus
1627+
///< interface of the device.
16261628
UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups
16271629
UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported
16281630
UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported
16291631
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands
16301632
///< to read and write pipes from the host.
1631-
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block.
1632-
UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version
1633-
///< is implementation-defined, but newer devices should have a higher
1634-
///< version than older devices.
1633+
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t][optional-query] The maximum number of registers available
1634+
///< per block.
1635+
UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t][optional-query] The device IP version. The meaning of the
1636+
///< device IP version is implementation-defined, but newer devices should
1637+
///< have a higher version than older devices.
16351638
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory.
16361639
UR_DEVICE_INFO_ESIMD_SUPPORT = 115, ///< [::ur_bool_t] return true if the device supports ESIMD.
16371640
UR_DEVICE_INFO_COMPONENT_DEVICES = 116, ///< [::ur_device_handle_t[]] The set of component devices contained by
@@ -3386,7 +3389,7 @@ typedef enum ur_usm_alloc_info_t {
33863389
UR_USM_ALLOC_INFO_BASE_PTR = 1, ///< [void *] Memory allocation base pointer info
33873390
UR_USM_ALLOC_INFO_SIZE = 2, ///< [size_t] Memory allocation size info
33883391
UR_USM_ALLOC_INFO_DEVICE = 3, ///< [::ur_device_handle_t] Memory allocation device info
3389-
UR_USM_ALLOC_INFO_POOL = 4, ///< [::ur_usm_pool_handle_t] Memory allocation pool info
3392+
UR_USM_ALLOC_INFO_POOL = 4, ///< [::ur_usm_pool_handle_t][optional-query] Memory allocation pool info
33903393
/// @cond
33913394
UR_USM_ALLOC_INFO_FORCE_UINT32 = 0x7fffffff
33923395
/// @endcond
@@ -4527,9 +4530,10 @@ typedef enum ur_program_info_t {
45274530
UR_PROGRAM_INFO_BINARY_SIZES = 5, ///< [size_t[]] Return program binary sizes for each device.
45284531
UR_PROGRAM_INFO_BINARIES = 6, ///< [unsigned char[]] Return program binaries for all devices for this
45294532
///< Program.
4530-
UR_PROGRAM_INFO_NUM_KERNELS = 7, ///< [size_t] Number of kernels in Program, return type size_t.
4531-
UR_PROGRAM_INFO_KERNEL_NAMES = 8, ///< [char[]] Return a null-terminated, semi-colon separated list of kernel
4532-
///< names in Program.
4533+
UR_PROGRAM_INFO_NUM_KERNELS = 7, ///< [size_t][optional-query] Number of kernels in Program, return type
4534+
///< size_t.
4535+
UR_PROGRAM_INFO_KERNEL_NAMES = 8, ///< [char[]][optional-query] Return a null-terminated, semi-colon
4536+
///< separated list of kernel names in Program.
45334537
/// @cond
45344538
UR_PROGRAM_INFO_FORCE_UINT32 = 0x7fffffff
45354539
/// @endcond
@@ -4880,8 +4884,8 @@ typedef enum ur_kernel_info_t {
48804884
UR_KERNEL_INFO_CONTEXT = 3, ///< [::ur_context_handle_t] Return Context object associated with Kernel.
48814885
UR_KERNEL_INFO_PROGRAM = 4, ///< [::ur_program_handle_t] Return Program object associated with Kernel.
48824886
UR_KERNEL_INFO_ATTRIBUTES = 5, ///< [char[]] Return null-terminated kernel attributes string.
4883-
UR_KERNEL_INFO_NUM_REGS = 6, ///< [uint32_t] Return the number of registers used by the compiled kernel
4884-
///< (device specific).
4887+
UR_KERNEL_INFO_NUM_REGS = 6, ///< [uint32_t][optional-query] Return the number of registers used by the
4888+
///< compiled kernel.
48854889
/// @cond
48864890
UR_KERNEL_INFO_FORCE_UINT32 = 0x7fffffff
48874891
/// @endcond
@@ -4891,7 +4895,7 @@ typedef enum ur_kernel_info_t {
48914895
///////////////////////////////////////////////////////////////////////////////
48924896
/// @brief Get Kernel Work Group information
48934897
typedef enum ur_kernel_group_info_t {
4894-
UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = 0, ///< [size_t[3]] Return Work Group maximum global size
4898+
UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = 0, ///< [size_t[3]][optional-query] Return Work Group maximum global size
48954899
UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE = 1, ///< [size_t] Return maximum Work Group size
48964900
UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE = 2, ///< [size_t[3]] Return Work Group size required by the source code, such
48974901
///< as __attribute__((required_work_group_size(X,Y,Z)), or (0, 0, 0) if
@@ -5422,8 +5426,8 @@ typedef enum ur_queue_info_t {
54225426
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue on the device. Only a valid query
54235427
///< if the queue was created with the `ON_DEVICE` queue flag, otherwise
54245428
///< `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`.
5425-
UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t] return true if the queue was empty at the time of the
5426-
///< query
5429+
UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t][optional-query] return true if the queue was empty at
5430+
///< the time of the query.
54275431
/// @cond
54285432
UR_QUEUE_INFO_FORCE_UINT32 = 0x7fffffff
54295433
/// @endcond

scripts/YaML.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ plural form *enumerators* is abbreviated to `etors`.
336336
- An etor requires the following scalar fields: {`name`, `desc`}
337337
+ `desc` will be used as the etors's description comment
338338
+ If the enum has `typed_etors`, `desc` must begin with type identifier: {`"[type]"`}
339+
+ `desc` may contain the [optional-query] annotation. This denotes the etor as an info query which is optional for adapters to implement, and may legally result in a non-success error code.
339340
+ `name` must be a unique ISO-C standard identifier, and be all caps
340341
- An etor may take the following optional scalar field: {`value`, `version`}
341342
+ `value` must be an ISO-C standard identifier

scripts/core/PROG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,24 @@ explicitly created against a context.
183183
// Release the context handle
184184
${x}ContextRelease(hContext);
185185
186+
Object Queries
187+
==============
188+
189+
Queries to get information from API objects follow a common pattern. The entry
190+
points for this are generally of the form:
191+
192+
.. code-block::
193+
194+
ObjectGetInfo(ur_object_handle_t hObject, ur_object_info_t propName,
195+
size_t propSize, void *pPropValue, size_t *pPropSizeRet)
196+
197+
where ``propName`` selects the information to query out. The object info enum
198+
representing possible queries will generally be found in the enums section of
199+
the relevant object. Some info queries would be difficult or impossible to
200+
support for certain backends, these are denoted with [optional-query] in the
201+
enum description. Using any enum marked optional in this way may result in
202+
${X}_RESULT_ERROR_UNSUPPORTED_ENUMERATION if the adapter doesn't support it.
203+
186204
Programs and Kernels
187205
====================
188206

scripts/core/device.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ etors:
200200
- name: VENDOR_ID
201201
desc: "[uint32_t] vendor Id of the device"
202202
- name: DEVICE_ID
203-
desc: "[uint32_t] Id of the device"
203+
desc: "[uint32_t][optional-query] Id of the device"
204204
- name: MAX_COMPUTE_UNITS
205205
desc: "[uint32_t] the number of compute units"
206206
- name: MAX_WORK_ITEM_DIMENSIONS
@@ -248,7 +248,7 @@ etors:
248248
- name: MAX_CLOCK_FREQUENCY
249249
desc: "[uint32_t] max clock frequency in MHz"
250250
- name: MEMORY_CLOCK_RATE
251-
desc: "[uint32_t] memory clock frequency in MHz"
251+
desc: "[uint32_t][optional-query] memory clock frequency in MHz"
252252
- name: ADDRESS_BITS
253253
desc: "[uint32_t] address bits"
254254
- name: MAX_MEM_ALLOC_SIZE
@@ -290,7 +290,7 @@ etors:
290290
- name: GLOBAL_MEM_SIZE
291291
desc: "[uint64_t] size of global memory in bytes"
292292
- name: GLOBAL_MEM_FREE
293-
desc: "[uint64_t] size of global memory which is free in bytes"
293+
desc: "[uint64_t][optional-query] size of global memory which is free in bytes"
294294
- name: MAX_CONSTANT_BUFFER_SIZE
295295
desc: "[uint64_t] max constant buffer size in bytes"
296296
- name: MAX_CONSTANT_ARGS
@@ -377,23 +377,23 @@ etors:
377377
- name: USM_SYSTEM_SHARED_SUPPORT
378378
desc: "[$x_device_usm_access_capability_flags_t] support USM system wide shared memory access"
379379
- name: UUID
380-
desc: "[uint8_t[]] return device UUID"
380+
desc: "[uint8_t[]][optional-query] return device UUID"
381381
- name: PCI_ADDRESS
382-
desc: "[char[]] return device PCI address"
382+
desc: "[char[]][optional-query] return device PCI address"
383383
- name: GPU_EU_COUNT
384-
desc: "[uint32_t] return Intel GPU EU count"
384+
desc: "[uint32_t][optional-query] return Intel GPU EU count"
385385
- name: GPU_EU_SIMD_WIDTH
386-
desc: "[uint32_t] return Intel GPU EU SIMD width"
386+
desc: "[uint32_t][optional-query] return Intel GPU EU SIMD width"
387387
- name: GPU_EU_SLICES
388-
desc: "[uint32_t] return Intel GPU number of slices"
388+
desc: "[uint32_t][optional-query] return Intel GPU number of slices"
389389
- name: GPU_EU_COUNT_PER_SUBSLICE
390-
desc: "[uint32_t] return Intel GPU EU count per subslice"
390+
desc: "[uint32_t][optional-query] return Intel GPU EU count per subslice"
391391
- name: GPU_SUBSLICES_PER_SLICE
392-
desc: "[uint32_t] return Intel GPU number of subslices per slice"
392+
desc: "[uint32_t][optional-query] return Intel GPU number of subslices per slice"
393393
- name: GPU_HW_THREADS_PER_EU
394-
desc: "[uint32_t] return Intel GPU number of threads per EU"
394+
desc: "[uint32_t][optional-query] return Intel GPU number of threads per EU"
395395
- name: MAX_MEMORY_BANDWIDTH
396-
desc: "[uint32_t] return max memory bandwidth in Mb/s"
396+
desc: "[uint32_t][optional-query] return max memory bandwidth in Mb/s"
397397
- name: IMAGE_SRGB
398398
desc: "[$x_bool_t] device supports sRGB images"
399399
- name: BUILD_ON_SUBDEVICE
@@ -418,7 +418,7 @@ etors:
418418
- name: KERNEL_SET_SPECIALIZATION_CONSTANTS
419419
desc: "[$x_bool_t] support the $xKernelSetSpecializationConstants entry point"
420420
- name: MEMORY_BUS_WIDTH
421-
desc: "[uint32_t] return the width in bits of the memory bus interface of the device."
421+
desc: "[uint32_t][optional-query] return the width in bits of the memory bus interface of the device."
422422
- name: MAX_WORK_GROUPS_3D
423423
desc: "[size_t[3]] return max 3D work groups"
424424
- name: ASYNC_BARRIER
@@ -428,9 +428,9 @@ etors:
428428
- name: HOST_PIPE_READ_WRITE_SUPPORTED
429429
desc: "[$x_bool_t] Return true if the device supports enqueueing commands to read and write pipes from the host."
430430
- name: MAX_REGISTERS_PER_WORK_GROUP
431-
desc: "[uint32_t] The maximum number of registers available per block."
431+
desc: "[uint32_t][optional-query] The maximum number of registers available per block."
432432
- name: IP_VERSION
433-
desc: "[uint32_t] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices."
433+
desc: "[uint32_t][optional-query] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices."
434434
- name: VIRTUAL_MEMORY_SUPPORT
435435
desc: "[$x_bool_t] return true if the device supports virtual memory."
436436
- name: ESIMD_SUPPORT

scripts/core/kernel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ etors:
124124
- name: ATTRIBUTES
125125
desc: "[char[]] Return null-terminated kernel attributes string."
126126
- name: NUM_REGS
127-
desc: "[uint32_t] Return the number of registers used by the compiled kernel (device specific)."
127+
desc: "[uint32_t][optional-query] Return the number of registers used by the compiled kernel."
128128
--- #--------------------------------------------------------------------------
129129
type: enum
130130
desc: "Get Kernel Work Group information"
@@ -133,7 +133,7 @@ name: $x_kernel_group_info_t
133133
typed_etors: True
134134
etors:
135135
- name: GLOBAL_WORK_SIZE
136-
desc: "[size_t[3]] Return Work Group maximum global size"
136+
desc: "[size_t[3]][optional-query] Return Work Group maximum global size"
137137
- name: WORK_GROUP_SIZE
138138
desc: "[size_t] Return maximum Work Group size"
139139
- name: COMPILE_WORK_GROUP_SIZE

0 commit comments

Comments
 (0)