Skip to content

Commit fa1e678

Browse files
committed
Merge branch 'sycl' into move-clean-shadow-to-launchinfo
2 parents 50bf1df + ea0f3a1 commit fa1e678

File tree

118 files changed

+1248
-569
lines changed

Some content is hidden

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

118 files changed

+1248
-569
lines changed

include/ur_api.h

+53-44
Large diffs are not rendered by default.

include/ur_ddi.h

+1
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetKernelProcAddrTable_t)(
651651
/// @brief Function-pointer for urKernelSuggestMaxCooperativeGroupCountExp
652652
typedef ur_result_t(UR_APICALL *ur_pfnKernelSuggestMaxCooperativeGroupCountExp_t)(
653653
ur_kernel_handle_t,
654+
ur_device_handle_t,
654655
uint32_t,
655656
const size_t *,
656657
size_t,

include/ur_print.hpp

+22
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_platform_info_t value)
20742074
case UR_PLATFORM_INFO_BACKEND:
20752075
os << "UR_PLATFORM_INFO_BACKEND";
20762076
break;
2077+
case UR_PLATFORM_INFO_ADAPTER:
2078+
os << "UR_PLATFORM_INFO_ADAPTER";
2079+
break;
20772080
default:
20782081
os << "unknown enumerator";
20792082
break;
@@ -2127,6 +2130,19 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_platform_in
21272130

21282131
os << ")";
21292132
} break;
2133+
case UR_PLATFORM_INFO_ADAPTER: {
2134+
const ur_adapter_handle_t *tptr = (const ur_adapter_handle_t *)ptr;
2135+
if (sizeof(ur_adapter_handle_t) > size) {
2136+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_adapter_handle_t) << ")";
2137+
return UR_RESULT_ERROR_INVALID_SIZE;
2138+
}
2139+
os << (const void *)(tptr) << " (";
2140+
2141+
ur::details::printPtr(os,
2142+
*tptr);
2143+
2144+
os << ")";
2145+
} break;
21302146
default:
21312147
os << "unknown enumerator";
21322148
return UR_RESULT_ERROR_INVALID_ENUMERATION;
@@ -13187,6 +13203,12 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1318713203
ur::details::printPtr(os,
1318813204
*(params->phKernel));
1318913205

13206+
os << ", ";
13207+
os << ".hDevice = ";
13208+
13209+
ur::details::printPtr(os,
13210+
*(params->phDevice));
13211+
1319013212
os << ", ";
1319113213
os << ".workDim = ";
1319213214

scripts/YaML.md

+1
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

+18
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/context.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ etors:
102102
- name: USM_FILL2D_SUPPORT
103103
desc: "[$x_bool_t] to indicate if the $xEnqueueUSMFill2D entrypoint is supported."
104104
- name: ATOMIC_MEMORY_ORDER_CAPABILITIES
105-
desc: "[$x_memory_order_capability_flags_t] return a bit-field of atomic memory order capabilities."
105+
desc: "[$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory order capabilities."
106106
- name: ATOMIC_MEMORY_SCOPE_CAPABILITIES
107-
desc: "[$x_memory_scope_capability_flags_t] return a bit-field of atomic memory scope capabilities."
107+
desc: "[$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory scope capabilities."
108108
- name: ATOMIC_FENCE_ORDER_CAPABILITIES
109109
desc: |
110-
[$x_memory_order_capability_flags_t] return a bit-field of atomic memory fence order capabilities.
110+
[$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory fence order capabilities.
111111
Zero is returned if the backend does not support context-level fences.
112112
- name: ATOMIC_FENCE_SCOPE_CAPABILITIES
113113
desc: |
114-
[$x_memory_scope_capability_flags_t] return a bit-field of atomic memory fence scope capabilities.
114+
[$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory fence scope capabilities.
115115
Zero is returned if the backend does not support context-level fences.
116116
--- #--------------------------------------------------------------------------
117117
type: function

scripts/core/device.yml

+17-17
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,17 +428,17 @@ 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
437437
desc: "[$x_bool_t] return true if the device supports ESIMD."
438438
- name: COMPONENT_DEVICES
439-
desc: "[$x_device_handle_t[]] The set of component devices contained by this composite device."
439+
desc: "[$x_device_handle_t[]][optional-query] The set of component devices contained by this composite device."
440440
- name: COMPOSITE_DEVICE
441-
desc: "[$x_device_handle_t] The composite device containing this component device."
441+
desc: "[$x_device_handle_t][optional-query] The composite device containing this component device."
442442
- name: GLOBAL_VARIABLE_SUPPORT
443443
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
444444
- name: USM_POOL_SUPPORT

scripts/core/exp-cooperative-kernels.yml

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ params:
7878
- type: $x_kernel_handle_t
7979
name: hKernel
8080
desc: "[in] handle of the kernel object"
81+
- type: $x_device_handle_t
82+
name: hDevice
83+
desc: "[in] handle of the device object"
8184
- type: uint32_t
8285
name: workDim
8386
desc: "[in] number of dimensions, from 1 to 3, to specify the work-group work-items"

scripts/core/kernel.yml

+6-6
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
@@ -146,12 +146,12 @@ etors:
146146
desc: "[size_t] Return minimum amount of private memory in bytes used by each work item in the Kernel"
147147
- name: COMPILE_MAX_WORK_GROUP_SIZE
148148
desc: |
149-
[size_t[3]] Return the maximum Work Group size guaranteed by the
150-
source code, or (0, 0, 0) if unspecified
149+
[size_t[3]][optional-query] Return the maximum Work Group size guaranteed
150+
by the source code, or (0, 0, 0) if unspecified
151151
- name: COMPILE_MAX_LINEAR_WORK_GROUP_SIZE
152152
desc: |
153-
[size_t] Return the maximum linearized Work Group size (X * Y * Z)
154-
guaranteed by the source code, or 0 if unspecified
153+
[size_t][optional-query] Return the maximum linearized Work Group size
154+
(X * Y * Z) guaranteed by the source code, or 0 if unspecified
155155
--- #--------------------------------------------------------------------------
156156
type: enum
157157
desc: "Get Kernel SubGroup information"

scripts/core/platform.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ etors:
7777
- name: BACKEND
7878
value: "6"
7979
desc: "[$x_platform_backend_t] The backend of the platform. Identifies the native backend adapter implementing this platform."
80-
80+
- name: ADAPTER
81+
value: "7"
82+
desc: "[$x_adapter_handle_t] The adapter handle associated with the platform."
8183
--- #--------------------------------------------------------------------------
8284
type: function
8385
desc: "Retrieves various information about platform"

scripts/core/program.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ etors:
387387
- name: BINARIES
388388
desc: "[unsigned char[]] Return program binaries for all devices for this Program."
389389
- name: NUM_KERNELS
390-
desc: "[size_t] Number of kernels in Program, return type size_t."
390+
desc: "[size_t][optional-query] Number of kernels in Program, return type size_t."
391391
- name: KERNEL_NAMES
392-
desc: "[char[]] Return a null-terminated, semi-colon separated list of kernel names in Program."
392+
desc: "[char[]][optional-query] Return a null-terminated, semi-colon separated list of kernel names in Program."
393393
--- #--------------------------------------------------------------------------
394394
type: function
395395
desc: "Query information about a Program object"

scripts/core/queue.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ etors:
3737
if the queue was created with the `ON_DEVICE` queue flag, otherwise
3838
`$xQueueGetInfo` will return `$X_RESULT_ERROR_INVALID_QUEUE`.
3939
- name: EMPTY
40-
desc: "[$x_bool_t] return true if the queue was empty at the time of the query"
40+
desc: "[$x_bool_t][optional-query] return true if the queue was empty at the time of the query."
4141
--- #--------------------------------------------------------------------------
4242
type: enum
4343
desc: "Queue property flags"

scripts/core/usm.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ etors:
7474
- name: DEVICE
7575
desc: "[$x_device_handle_t] Memory allocation device info"
7676
- name: POOL
77-
desc: "[$x_usm_pool_handle_t] Memory allocation pool info"
77+
desc: "[$x_usm_pool_handle_t][optional-query] Memory allocation pool info"
7878
--- #--------------------------------------------------------------------------
7979
type: enum
8080
desc: "USM memory advice"

scripts/generate_code.py

+21
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,24 @@ def generate_level_zero_queue_api(path, section, namespace, tags, version, specs
548548
specs=specs,
549549
meta=meta)
550550
print("QUEUE Generated %s lines of code.\n" % loc)
551+
552+
"""
553+
Entry-point:
554+
generates headers used by the CTS, for example containing meta-information
555+
about info query enums
556+
"""
557+
def generate_cts_headers(path, section, namespace, tags, version, specs, meta):
558+
template = "optional_queries.h.mako"
559+
fin = os.path.join("templates", template)
560+
name = "optional_queries"
561+
filename = "optional_queries.h"
562+
dstpath = os.path.join(path, "conformance", "testing", "include", "uur")
563+
fout = os.path.join(dstpath, filename)
564+
565+
print("Generating %s..." % fout)
566+
567+
loc = util.makoWrite(fin, fout,
568+
filename = name, namespace = namespace,
569+
tags = tags, specs = specs, meta = meta)
570+
571+
print("CTS Generated %s lines of code.\n" % loc)

scripts/json2src.py

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def add_argument(parser, name, help, default=False):
3232
add_argument(parser, "common", "generation of common files.", True)
3333
add_argument(parser, "tools", "generation of common files.", True)
3434
add_argument(parser, "l0_queue", "generation of l0 queue abstractions.", True)
35+
add_argument(parser, "cts", "generation of cts headers", True)
3536
parser.add_argument("--debug", action='store_true', help="dump intermediate data to disk.")
3637
parser.add_argument("--sections", type=list, default=None, help="Optional list of sections for which to generate source, default is all")
3738
parser.add_argument("--ver", type=str, default="1.0", help="specification version to generate.")
@@ -45,6 +46,7 @@ def add_argument(parser, name, help, default=False):
4546

4647
srcpath = os.path.join(args.out_dir, "source")
4748
toolspath = os.path.join(args.out_dir, "tools")
49+
testpath = os.path.join(args.out_dir, "test")
4850

4951
for idx, specs in enumerate(input['specs']):
5052
config = input['configs'][idx]
@@ -63,6 +65,8 @@ def add_argument(parser, name, help, default=False):
6365
generate_code.generate_tools(toolspath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta'])
6466
if args.l0_queue:
6567
generate_code.generate_level_zero_queue_api(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta'])
68+
if args.cts:
69+
generate_code.generate_cts_headers(testpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta'])
6670

6771
if args.debug:
6872
util.makoFileListWrite("generated.json")

scripts/templates/helper.py

+34-1
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,18 @@ def is_global(item, tags):
541541
except:
542542
return False
543543

544+
"""
545+
Extracts traits from an enumerator
546+
"""
547+
class etor_traits:
548+
RE_OPTIONAL_QUERY = r".*\[optional-query\].*"
549+
550+
@classmethod
551+
def is_optional_query(cls, item):
552+
try:
553+
return True if re.match(cls.RE_OPTIONAL_QUERY, item['desc']) else False
554+
except:
555+
return False
544556

545557
"""
546558
Public:
@@ -780,7 +792,7 @@ def make_etor_name(namespace, tags, enum, etor, meta=None):
780792
returns the associated type of an etor from a typed enum
781793
"""
782794
def etor_get_associated_type(namespace, tags, item):
783-
match = re.match(r'^\[(.+)\]\s', item['desc'])
795+
match = re.match(r'^\[([$A-Za-z0-9_*[\] ]+)\]', item['desc'])
784796
if match:
785797
associated_type = match.group(1)
786798
return subt(namespace, tags, associated_type)
@@ -1692,3 +1704,24 @@ def transform_queue_related_function_name(namespace, tags, obj, format = ["name"
16921704
params = params[1:]
16931705

16941706
return "{}({})".format(function_name, ", ".join(params))
1707+
1708+
"""
1709+
Public:
1710+
Returns a dictionary mapping info enum types to the list of optional queries
1711+
within that enum. If an enum type doesn't have any optional queries it will
1712+
not appear in the dictionary as a key.
1713+
"""
1714+
def get_optional_queries(specs, namespace, tags):
1715+
optional_queries = {}
1716+
for s in specs:
1717+
for obj in s['objects']:
1718+
if obj['type'] == 'enum':
1719+
optional_etors = []
1720+
for e in obj['etors']:
1721+
if etor_traits.is_optional_query(e):
1722+
name = make_enum_name(namespace, tags, e)
1723+
optional_etors.append(name)
1724+
if optional_etors:
1725+
type_name = make_type_name(namespace, tags, obj)
1726+
optional_queries[type_name] = optional_etors
1727+
return optional_queries

0 commit comments

Comments
 (0)