Skip to content

Commit bd76766

Browse files
author
Petr Vesely
committed
[UR] Integrate registry.yml
1 parent 478f864 commit bd76766

File tree

6 files changed

+6085
-5941
lines changed

6 files changed

+6085
-5941
lines changed

include/ur.py

Lines changed: 219 additions & 219 deletions
Large diffs are not rendered by default.

include/ur_api.h

Lines changed: 226 additions & 226 deletions
Large diffs are not rendered by default.

scripts/core/registry.yml

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
type: header
33
desc: "Intel $OneApi Unified Runtime function registry"
4-
ordinal: "9"
4+
ordinal: "-1"
55
---
66
name: $x_function_t
77
type: enum
@@ -502,3 +502,110 @@ etors:
502502
- name: COMMAND_BUFFER_APPEND_MEMBUFFER_READ_RECT_EXP
503503
desc: Enumerator for $xCommandBufferAppendMembufferReadRectExp
504504
value: '171'
505+
---
506+
type: enum
507+
desc: Defines structure types
508+
name: $x_structure_type_t
509+
etors:
510+
- name: CONTEXT_PROPERTIES
511+
desc: $x_context_properties_t
512+
value: '0'
513+
- name: IMAGE_DESC
514+
desc: $x_image_desc_t
515+
value: '1'
516+
- name: BUFFER_PROPERTIES
517+
desc: $x_buffer_properties_t
518+
value: '2'
519+
- name: BUFFER_REGION
520+
desc: $x_buffer_region_t
521+
value: '3'
522+
- name: BUFFER_CHANNEL_PROPERTIES
523+
desc: $x_buffer_channel_properties_t
524+
value: '4'
525+
- name: BUFFER_ALLOC_LOCATION_PROPERTIES
526+
desc: $x_buffer_alloc_location_properties_t
527+
value: '5'
528+
- name: PROGRAM_PROPERTIES
529+
desc: $x_program_properties_t
530+
value: '6'
531+
- name: USM_DESC
532+
desc: $x_usm_desc_t
533+
value: '7'
534+
- name: USM_HOST_DESC
535+
desc: $x_usm_host_desc_t
536+
value: '8'
537+
- name: USM_DEVICE_DESC
538+
desc: $x_usm_device_desc_t
539+
value: '9'
540+
- name: USM_POOL_DESC
541+
desc: $x_usm_pool_desc_t
542+
value: '10'
543+
- name: USM_POOL_LIMITS_DESC
544+
desc: $x_usm_pool_limits_desc_t
545+
value: '11'
546+
- name: DEVICE_BINARY
547+
desc: $x_device_binary_t
548+
value: '12'
549+
- name: SAMPLER_DESC
550+
desc: $x_sampler_desc_t
551+
value: '13'
552+
- name: QUEUE_PROPERTIES
553+
desc: $x_queue_properties_t
554+
value: '14'
555+
- name: QUEUE_INDEX_PROPERTIES
556+
desc: $x_queue_index_properties_t
557+
value: '15'
558+
- name: CONTEXT_NATIVE_PROPERTIES
559+
desc: $x_context_native_properties_t
560+
value: '16'
561+
- name: KERNEL_NATIVE_PROPERTIES
562+
desc: $x_kernel_native_properties_t
563+
value: '17'
564+
- name: QUEUE_NATIVE_PROPERTIES
565+
desc: $x_queue_native_properties_t
566+
value: '18'
567+
- name: MEM_NATIVE_PROPERTIES
568+
desc: $x_mem_native_properties_t
569+
value: '19'
570+
- name: EVENT_NATIVE_PROPERTIES
571+
desc: $x_event_native_properties_t
572+
value: '20'
573+
- name: PLATFORM_NATIVE_PROPERTIES
574+
desc: $x_platform_native_properties_t
575+
value: '21'
576+
- name: DEVICE_NATIVE_PROPERTIES
577+
desc: $x_device_native_properties_t
578+
value: '22'
579+
- name: PROGRAM_NATIVE_PROPERTIES
580+
desc: $x_program_native_properties_t
581+
value: '23'
582+
- name: SAMPLER_NATIVE_PROPERTIES
583+
desc: $x_sampler_native_properties_t
584+
value: '24'
585+
- name: QUEUE_NATIVE_DESC
586+
desc: $x_queue_native_desc_t
587+
value: '25'
588+
- name: DEVICE_PARTITION_PROPERTIES
589+
desc: $x_device_partition_properties_t
590+
value: '26'
591+
- name: KERNEL_ARG_MEM_OBJ_PROPERTIES
592+
desc: $x_kernel_arg_mem_obj_properties_t
593+
value: '27'
594+
- name: PHYSICAL_MEM_PROPERTIES
595+
desc: $x_physical_mem_properties_t
596+
value: '28'
597+
- name: KERNEL_ARG_POINTER_PROPERTIES
598+
desc: $x_kernel_arg_pointer_properties_t
599+
value: '29'
600+
- name: KERNEL_ARG_SAMPLER_PROPERTIES
601+
desc: $x_kernel_arg_sampler_properties_t
602+
value: '30'
603+
- name: KERNEL_EXEC_INFO_PROPERTIES
604+
desc: $x_kernel_exec_info_properties_t
605+
value: '31'
606+
- name: KERNEL_ARG_VALUE_PROPERTIES
607+
desc: $x_kernel_arg_value_properties_t
608+
value: '32'
609+
- name: KERNEL_ARG_LOCAL_PROPERTIES
610+
desc: $x_kernel_arg_local_properties_t
611+
value: '33'

scripts/generate_ids.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ class quoted(str):
1818
def quoted_presenter(dumper, data):
1919
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"')
2020

21+
def write_registry(data, path):
22+
header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(-1)}
23+
data.insert(0, header)
24+
with open(path, 'w') as fout:
25+
yaml.add_representer(quoted, quoted_presenter)
26+
yaml.dump_all(data, fout,
27+
default_flow_style=False,
28+
sort_keys=False,
29+
explicit_start=True)
30+
31+
2132
def generate_registry(path, specs):
2233
try:
23-
existing_registry = list(util.yamlRead(path))[1]['etors']
34+
contents = list(util.yamlRead(path))
35+
existing_registry = contents[1]['etors']
2436
existing_etors = {etor["name"]: etor["value"] for etor in existing_registry}
2537
max_etor = int(max(existing_registry, key = lambda x : int(x["value"]))["value"])
2638
functions = [obj['class'][len('$x'):] + obj['name'] for s in specs for obj in s['objects'] if obj['type'] == 'function']
@@ -34,13 +46,9 @@ def generate_registry(path, specs):
3446
registry.append({'name': util.to_snake_case(fname).upper(), 'desc': 'Enumerator for $x'+fname, 'value': str(id)})
3547
registry = sorted(registry, key=lambda x: int(x['value']))
3648
wrapper = { 'name': ENUM_NAME, 'type': 'enum', 'desc': 'Defines unique stable identifiers for all functions' , 'etors': registry}
37-
header = {'type': 'header', 'desc': quoted('Intel $OneApi Unified Runtime function registry'), 'ordinal': quoted(9)}
38-
with open(path, 'w') as fout:
39-
yaml.add_representer(quoted, quoted_presenter)
40-
yaml.dump_all([header, wrapper], fout,
41-
default_flow_style=False,
42-
sort_keys=False,
43-
explicit_start=True)
49+
contents[1] = wrapper
50+
write_registry(contents[1:], path)
51+
4452
except BaseException as e:
4553
print("Failed to generate registry.yml... %s", e)
4654
raise e

scripts/parse_specs.py

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -853,26 +853,54 @@ def sort_etors(x):
853853
return value
854854
matching_enum['etors'] = sorted(matching_enum['etors'], key=sort_etors)
855855

856-
def _generate_structure_type_t(specs, meta):
856+
def _generate_structure_type_t(specs, meta, registry):
857857
extended_structs = [obj for s in specs for obj in s['objects'] if re.match(r"struct|union", obj['type']) and 'base' in obj]
858-
ur_structure_type_t = {
859-
"type": "enum",
860-
"desc": "Defines structure types",
861-
"name": "$x_structure_type_t",
862-
"etors": []
863-
}
858+
ur_structure_type_t = [obj for s in specs for obj in s['objects'] if obj['name'] == "$x_structure_type_t"][0]
859+
existing_etors = ur_structure_type_t['etors']
860+
max_enum = int(max(ur_structure_type_t['etors'], key= lambda x : int(x['value']))['value'])
861+
862+
out_etors = []
864863
for struct in extended_structs:
864+
# skip experimental enumerations
865865
if struct['name'].startswith("$x_exp_"):
866866
continue
867-
stype = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]
868-
etor = stype['init']
869-
ur_structure_type_t['etors'].append({"name": etor, "desc": struct['name']})
870-
871-
common_header = [s for s in specs if s['header']['desc'].endswith("common types")][0]
872-
result_t_index = [i for i, obj in enumerate(common_header['objects']) if obj['name'] == "$x_result_t"][0]
873-
common_header['objects'].insert(result_t_index + 1, ur_structure_type_t)
867+
868+
# name of the etor
869+
etor = [mem for mem in struct['members'] if mem['name'] == 'stype'][0]['init']
870+
871+
# try and match the etor
872+
matched_etor = [e for e in existing_etors if e['name'] == etor]
873+
874+
# if no match exists then we have to add it
875+
if len(matched_etor) == 0:
876+
max_enum += 1
877+
out_etors.append({
878+
"name": etor,
879+
"desc": struct['name'],
880+
"value": str(max_enum)
881+
})
882+
else:
883+
out_etors.append({
884+
"name": etor,
885+
"desc": struct['name'],
886+
"value": matched_etor[0]['value']
887+
})
888+
889+
out_etors = sorted(out_etors, key = lambda x : int(x['value']))
890+
ur_structure_type_t['etors'] = out_etors
874891
_refresh_enum_meta(ur_structure_type_t, meta)
875892

893+
## write the result out to the yml file
894+
try:
895+
contents = list(util.yamlRead(registry))
896+
cpy = copy.deepcopy(ur_structure_type_t)
897+
for e in cpy['etors']:
898+
e['name'] = e['name'][len("$X_STRUCTURE_TYPE_"):]
899+
contents[2] = cpy
900+
generate_ids.write_registry(contents[1:], registry)
901+
except:
902+
raise
903+
876904
"""
877905
Entry-point:
878906
Reads each YML file and extracts data
@@ -942,7 +970,8 @@ def parse(section, version, tags, meta, ref):
942970

943971
specs = sorted(specs, key=lambda s: s['header']['ordinal'])
944972
_inline_extended_structs(specs, meta)
945-
_generate_structure_type_t(specs, meta)
973+
registry = [f for f in files if f.endswith('registry.yml')][0]
974+
_generate_structure_type_t(specs, meta, registry)
946975
_extend_enums(enum_extensions, specs, meta)
947976
_generate_extra(specs, meta)
948977

0 commit comments

Comments
 (0)