Skip to content

Commit a0df523

Browse files
authored
[UR] Deprecate UR_DEVICE_INFO_BFLOAT16 (#17053)
* Add support for deprecation of enum values in UR spec. * Deprecate UR_DEVICE_INFO_BFLOAT16. * Remove testing for UR_DEVICE_INFO_BFLOAT16. * Remove UR_DEVICE_INFO_BFLOAT16 support from adapters. * Resolves oneapi-src/unified-runtime#2385.
1 parent 7650d83 commit a0df523

File tree

18 files changed

+50
-78
lines changed

18 files changed

+50
-78
lines changed

unified-runtime/include/ur_api.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/include/ur_print.hpp

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/scripts/YaML.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ plural form *enumerators* is abbreviated to `etors`.
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]"`}
339339
+ `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.
340+
+ `desc` may contain the [deprecated-value] annotation. This marks the etor with the `[[deprecated]]` attribute specifier.
340341
+ `name` must be a unique ISO-C standard identifier, and be all caps
341342
- An etor may take the following optional scalar field: {`value`, `version`}
342343
+ `value` must be an ISO-C standard identifier

unified-runtime/scripts/core/PROG.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,17 @@ points for this are generally of the form:
196196
197197
where ``propName`` selects the information to query out. The object info enum
198198
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
199+
the relevant object.
200+
201+
Some info queries would be difficult or impossible to support for certain
202+
backends, these are denoted with [optional-query] in the enum description.
203+
Using any enum marked optional in this way may result in
202204
${X}_RESULT_ERROR_UNSUPPORTED_ENUMERATION if the adapter doesn't support it.
203205

206+
Some info queries may become deprecated, denoted with [deprecated-value] in the
207+
enum description. Using any enum marked as deprecated in this way may result in
208+
${X}_RESULT_ERROR_INVALID_ENUMERATION if the adapter has ceased to support it.
209+
204210
Programs and Kernels
205211
====================
206212

unified-runtime/scripts/core/device.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ etors:
409409
- name: ATOMIC_FENCE_SCOPE_CAPABILITIES
410410
desc: "[$x_memory_scope_capability_flags_t] return a bit-field of atomic memory fence scope capabilities"
411411
- name: BFLOAT16
412-
desc: "[$x_bool_t] support for bfloat16"
412+
desc: "[$x_bool_t][deprecated-value] support for bfloat16"
413413
- name: MAX_COMPUTE_QUEUE_INDICES
414414
desc: |
415415
[uint32_t] Returns 1 if the device doesn't have a notion of a

unified-runtime/scripts/templates/helper.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def get_array_element_type(cls, name):
271271
def get_struct_members(type_name, meta):
272272
struct_type = _remove_const_ptr(type_name)
273273
if not struct_type in meta["struct"]:
274-
raise Exception(f"Cannot return members of non-struct type {struct_type}")
274+
raise Exception(f"Cannot return members of non-struct type {struct_type}.")
275275
return meta["struct"][struct_type]["members"]
276276

277277

@@ -565,6 +565,7 @@ def is_global(item, tags):
565565

566566
class etor_traits:
567567
RE_OPTIONAL_QUERY = r".*\[optional-query\].*"
568+
RE_DEPRECATED = r".*\[deprecated-value\].*"
568569

569570
@classmethod
570571
def is_optional_query(cls, item):
@@ -573,6 +574,13 @@ def is_optional_query(cls, item):
573574
except:
574575
return False
575576

577+
@classmethod
578+
def is_deprecated_etor(cls, item):
579+
try:
580+
return True if re.match(cls.RE_DEPRECATED, item["desc"]) else False
581+
except:
582+
return False
583+
576584

577585
"""
578586
Public:
@@ -917,13 +925,14 @@ def make_etor_lines(namespace, tags, obj, meta=None):
917925
lines = []
918926
for item in obj["etors"]:
919927
name = make_etor_name(namespace, tags, obj["name"], item["name"], meta)
928+
deprecated = " [[deprecated]]" if etor_traits.is_deprecated_etor(item) else ""
920929

921930
if "value" in item:
922931
delim = ","
923932
value = _get_value_name(namespace, tags, item["value"])
924-
prologue = "%s = %s%s" % (name, value, delim)
933+
prologue = "%s%s = %s%s" % (name, deprecated, value, delim)
925934
else:
926-
prologue = "%s," % (name)
935+
prologue = "%s%s," % (name, deprecated)
927936

928937
for line in split_line(subt(namespace, tags, item["desc"], True), 70):
929938
lines.append(" /// %s" % line)
@@ -1974,7 +1983,7 @@ def transform_queue_related_function_name(
19741983
function_name = function_name[0].lower() + function_name[1:]
19751984

19761985
if obj["params"][0]["type"] != "$x_queue_handle_t":
1977-
raise ValueError("First parameter is not a queue handle")
1986+
raise ValueError("First parameter is not a queue handle.")
19781987

19791988
params = make_param_lines(namespace, tags, obj, format=format)
19801989
params = params[1:]
@@ -2004,3 +2013,18 @@ def get_optional_queries(specs, namespace, tags):
20042013
type_name = make_type_name(namespace, tags, obj)
20052014
optional_queries[type_name] = optional_etors
20062015
return optional_queries
2016+
2017+
2018+
"""
2019+
Public:
2020+
Generator returning non-deprecated enum values.
2021+
"""
2022+
2023+
2024+
def get_etors(obj):
2025+
if not obj_traits.is_enum(obj):
2026+
raise TypeError("obj parameter is not an enum.")
2027+
for item in obj["etors"]:
2028+
if etor_traits.is_deprecated_etor(item):
2029+
continue
2030+
yield item

unified-runtime/scripts/templates/print.hpp.mako

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
191191
%else:
192192
inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value) {
193193
switch (value) {
194-
%for n, item in enumerate(obj['etors']):
194+
%for n, item in enumerate(th.get_etors(obj)):
195195
<%
196196
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
197197
%>case ${ename}:
@@ -216,7 +216,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
216216
}
217217

218218
switch (value) {
219-
%for n, item in enumerate(obj['etors']):
219+
%for n, item in enumerate(th.get_etors(obj)):
220220
<%
221221
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
222222
vtype = th.etor_get_associated_type(n, tags, item)
@@ -281,7 +281,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
281281
## structure type enum value must be first
282282
const enum ${th.make_enum_name(n, tags, obj)} *value = (const enum ${th.make_enum_name(n, tags, obj)} *)ptr;
283283
switch (*value) {
284-
%for n, item in enumerate(obj['etors']):
284+
%for n, item in enumerate(th.get_etors(obj)):
285285
<%
286286
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
287287
%>
@@ -307,7 +307,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
307307
inline ${x}_result_t printFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, uint32_t flag) {
308308
uint32_t val = flag;
309309
bool first = true;
310-
%for n, item in enumerate(obj['etors']):
310+
%for n, item in enumerate(th.get_etors(obj)):
311311
<%
312312
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
313313
%>

unified-runtime/scripts/templates/stype_map_helpers.hpp.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ from templates import helper as th
1212

1313
%for obj in th.extract_objs(specs, r"enum"):
1414
%if obj["name"] == '$x_structure_type_t':
15-
%for etor in obj['etors']:
15+
%for etor in th.get_etors(obj):
1616
%if 'UINT32' not in etor['name']:
1717
template <>
1818
struct stype_map<${x}_${etor['desc'][3:]}> : stype_map_impl<${X}_${etor['name'][3:]}> {};

unified-runtime/scripts/templates/tools-info.hpp.mako

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace urinfo {
3232
%for obj in th.extract_objs(specs, r"enum"):
3333
%if obj["name"] == '$x_loader_config_info_t':
3434
inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, std::string_view prefix = " ") {
35-
%for etor in obj['etors']:
35+
%for etor in th.get_etors(obj):
3636
%if 'REFERENCE_COUNT' not in etor['name']:
3737
<%etype = th.etor_get_associated_type(n, tags, etor)
3838
%>std::cout << prefix;
@@ -43,7 +43,7 @@ inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, st
4343
%endif
4444
%if obj["name"] == '$x_adapter_info_t':
4545
inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view prefix = " ") {
46-
%for etor in obj['etors']:
46+
%for etor in th.get_etors(obj):
4747
%if 'REFERENCE_COUNT' not in etor['name']:
4848
<%etype = th.etor_get_associated_type(n, tags, etor)
4949
%>std::cout << prefix;
@@ -55,7 +55,7 @@ inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view p
5555
%endif
5656
%if obj["name"] == '$x_platform_info_t':
5757
inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_view prefix = " ") {
58-
%for etor in obj['etors']:
58+
%for etor in th.get_etors(obj):
5959
<%etype = th.etor_get_associated_type(n, tags, etor)
6060
%>std::cout << prefix;
6161
printPlatformInfo<${etype}>(hPlatform, ${etor['name'].replace('$X', X)});
@@ -65,7 +65,7 @@ inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_vie
6565
%endif
6666
%if obj['name'] == '$x_device_info_t':
6767
inline void printDeviceInfos(${x}_device_handle_t hDevice, std::string_view prefix = " ") {
68-
%for etor in obj['etors']:
68+
%for etor in th.get_etors(obj):
6969
<%etype = th.etor_get_associated_type(n, tags, etor)
7070
%>std::cout << prefix;
7171
%if etor['name'] == '$X_DEVICE_INFO_UUID':

unified-runtime/source/adapters/cuda/device.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
253253
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
254254
return ReturnValue(Capabilities);
255255
}
256-
case UR_DEVICE_INFO_BFLOAT16: {
257-
int Major = 0;
258-
UR_CHECK_ERROR(cuDeviceGetAttribute(
259-
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, hDevice->get()));
260-
261-
bool BFloat16 = (Major >= 8) ? true : false;
262-
return ReturnValue(BFloat16);
263-
}
264256
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
265257
// NVIDIA devices only support one sub-group size (the warp size)
266258
int WarpSize = 0;

0 commit comments

Comments
 (0)