Skip to content

Commit

Permalink
[UR] Deprecate UR_DEVICE_INFO_BFLOAT16
Browse files Browse the repository at this point in the history
* 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 OpenCL adapter.
  • Loading branch information
isaacault committed Feb 20, 2025
1 parent 7b9779e commit a03e964
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 74 deletions.
4 changes: 2 additions & 2 deletions unified-runtime/include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2143,8 +2143,8 @@ typedef enum ur_device_info_t {
/// [::ur_memory_scope_capability_flags_t] return a bit-field of atomic
/// memory fence scope capabilities
UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 103,
/// [::ur_bool_t] support for bfloat16
UR_DEVICE_INFO_BFLOAT16 = 104,
/// [::ur_bool_t][deprecated-value] support for bfloat16
UR_DEVICE_INFO_BFLOAT16 [[deprecated]] = 104,
/// [uint32_t] Returns 1 if the device doesn't have a notion of a
/// queue index. Otherwise, returns the number of queue indices that are
/// available for this device.
Expand Down
16 changes: 0 additions & 16 deletions unified-runtime/include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,9 +2822,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES:
os << "UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES";
break;
case UR_DEVICE_INFO_BFLOAT16:
os << "UR_DEVICE_INFO_BFLOAT16";
break;
case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES:
os << "UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES";
break;
Expand Down Expand Up @@ -4297,19 +4294,6 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,

os << ")";
} break;
case UR_DEVICE_INFO_BFLOAT16: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: {
const uint32_t *tptr = (const uint32_t *)ptr;
if (sizeof(uint32_t) > size) {
Expand Down
1 change: 1 addition & 0 deletions unified-runtime/scripts/YaML.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ plural form *enumerators* is abbreviated to `etors`.
+ `desc` will be used as the etors's description comment
+ If the enum has `typed_etors`, `desc` must begin with type identifier: {`"[type]"`}
+ `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.
+ `desc` may contain the [deprecated-value] annotation. This marks the etor with the `[[deprecated]]` attribute specifier.
+ `name` must be a unique ISO-C standard identifier, and be all caps
- An etor may take the following optional scalar field: {`value`, `version`}
+ `value` must be an ISO-C standard identifier
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ etors:
- name: ATOMIC_FENCE_SCOPE_CAPABILITIES
desc: "[$x_memory_scope_capability_flags_t] return a bit-field of atomic memory fence scope capabilities"
- name: BFLOAT16
desc: "[$x_bool_t] support for bfloat16"
desc: "[$x_bool_t][deprecated-value] support for bfloat16"
- name: MAX_COMPUTE_QUEUE_INDICES
desc: |
[uint32_t] Returns 1 if the device doesn't have a notion of a
Expand Down
13 changes: 11 additions & 2 deletions unified-runtime/scripts/templates/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def is_global(item, tags):

class etor_traits:
RE_OPTIONAL_QUERY = r".*\[optional-query\].*"
RE_DEPRECATED = r".*\[deprecated-value\].*"

@classmethod
def is_optional_query(cls, item):
Expand All @@ -573,6 +574,13 @@ def is_optional_query(cls, item):
except:
return False

@classmethod
def is_deprecated_etor(cls, item):
try:
return True if re.match(cls.RE_DEPRECATED, item["desc"]) else False
except:
return False


"""
Public:
Expand Down Expand Up @@ -903,13 +911,14 @@ def make_etor_lines(namespace, tags, obj, meta=None):
lines = []
for item in obj["etors"]:
name = make_etor_name(namespace, tags, obj["name"], item["name"], meta)
deprecated = " [[deprecated]]" if etor_traits.is_deprecated_etor(item) else ""

if "value" in item:
delim = ","
value = _get_value_name(namespace, tags, item["value"])
prologue = "%s = %s%s" % (name, value, delim)
prologue = "%s%s = %s%s" % (name, deprecated, value, delim)
else:
prologue = "%s," % (name)
prologue = "%s%s," % (name, deprecated)

for line in split_line(subt(namespace, tags, item["desc"], True), 70):
lines.append(" /// %s" % line)
Expand Down
94 changes: 49 additions & 45 deletions unified-runtime/scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,13 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value) {
switch (value) {
%for n, item in enumerate(obj['etors']):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
%>case ${ename}:
os << "${ename}";
break;
%if not th.etor_traits.is_deprecated_etor(item):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
%>case ${ename}:
os << "${ename}";
break;
%endif
%endfor
default:
os << "unknown enumerator";
Expand All @@ -217,49 +219,51 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v

switch (value) {
%for n, item in enumerate(obj['etors']):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
vtype = th.etor_get_associated_type(n, tags, item)
%>case ${ename}: {
%if th.value_traits.is_array(vtype):
<% atype = th.value_traits.get_array_name(vtype) %>
%if 'void' in atype:
const ${atype} const *tptr = (const ${atype} const*)ptr;
%else:
const ${atype} *tptr = (const ${atype} *)ptr;
%endif
%if "char" in atype: ## print char* arrays as simple NULL-terminated strings
printPtr(os, tptr);
%if not th.etor_traits.is_deprecated_etor(item):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
vtype = th.etor_get_associated_type(n, tags, item)
%>case ${ename}: {
%if th.value_traits.is_array(vtype):
<% atype = th.value_traits.get_array_name(vtype) %>
%if 'void' in atype:
const ${atype} const *tptr = (const ${atype} const*)ptr;
%else:
os << "{";
size_t nelems = size / sizeof(${atype});
for (size_t i = 0; i < nelems; ++i) {
if (i != 0) {
os << ", ";
const ${atype} *tptr = (const ${atype} *)ptr;
%endif
%if "char" in atype: ## print char* arrays as simple NULL-terminated strings
printPtr(os, tptr);
%else:
os << "{";
size_t nelems = size / sizeof(${atype});
for (size_t i = 0; i < nelems; ++i) {
if (i != 0) {
os << ", ";
}
<%call expr="member(tptr, atype, True)">
tptr[i]
</%call>
}
<%call expr="member(tptr, atype, True)">
tptr[i]
</%call>
}
os << "}";
os << "}";
%endif
%else:
%if 'void' in vtype:
const ${vtype} const *tptr = (const ${vtype} const *)ptr;
%else:
const ${vtype} *tptr = (const ${vtype} *)ptr;
%endif
%else:
%if 'void' in vtype:
const ${vtype} const *tptr = (const ${vtype} const *)ptr;
%else:
const ${vtype} *tptr = (const ${vtype} *)ptr;
%endif
if (sizeof(${vtype}) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(${vtype}) << ")";
return ${X}_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";
<%call expr="member(tptr, vtype, False)">
*tptr
</%call>
os << ")";
%endif
} break;
if (sizeof(${vtype}) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(${vtype}) << ")";
return ${X}_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";
<%call expr="member(tptr, vtype, False)">
*tptr
</%call>
os << ")";
%endif
} break;
%endif
%endfor
default:
os << "unknown enumerator";
Expand Down
1 change: 0 additions & 1 deletion unified-runtime/source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
// 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_KERNEL_SET_SPECIALIZATION_CONSTANTS:
case UR_DEVICE_INFO_BFLOAT16:
case UR_DEVICE_INFO_ASYNC_BARRIER: {
return ReturnValue(false);
}
Expand Down
2 changes: 0 additions & 2 deletions unified-runtime/test/conformance/device/urDeviceGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ static std::unordered_map<ur_device_info_t, size_t> device_info_size_map = {
sizeof(ur_memory_order_capability_flags_t)},
{UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES,
sizeof(ur_memory_scope_capability_flags_t)},
{UR_DEVICE_INFO_BFLOAT16, sizeof(ur_bool_t)},
{UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES, sizeof(uint32_t)},
{UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, sizeof(ur_bool_t)},
{UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS, sizeof(ur_bool_t)},
Expand Down Expand Up @@ -235,7 +234,6 @@ UUR_DEVICE_TEST_SUITE_WITH_PARAM(
UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, //
UR_DEVICE_INFO_ATOMIC_64, //
UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, //
UR_DEVICE_INFO_BFLOAT16, //
UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES, //
UR_DEVICE_INFO_MEMORY_BUS_WIDTH, //
UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ GetDeviceMemoryOrderCapabilities(ur_device_handle_t device,
ur_result_t
GetDeviceMemoryScopeCapabilities(ur_device_handle_t device,
ur_memory_scope_capability_flags_t &flags);
ur_result_t GetDeviceBFloat16Support(ur_device_handle_t device, bool &support);
ur_result_t GetDeviceMaxComputeQueueIndices(ur_device_handle_t device,
uint32_t &max_indices);
ur_result_t GetDeviceHostPipeRWSupported(ur_device_handle_t device,
Expand Down
4 changes: 0 additions & 4 deletions unified-runtime/test/conformance/testing/source/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,6 @@ GetDeviceMemoryScopeCapabilities(ur_device_handle_t device,
device, UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, flags);
}

ur_result_t GetDeviceBFloat16Support(ur_device_handle_t device, bool &support) {
return GetDeviceInfo<bool>(device, UR_DEVICE_INFO_BFLOAT16, support);
}

ur_result_t GetDeviceMaxComputeQueueIndices(ur_device_handle_t device,
uint32_t &max_indices) {
return GetDeviceInfo<uint32_t>(
Expand Down

0 comments on commit a03e964

Please sign in to comment.