Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions unified-runtime/include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions unified-runtime/include/ur_print.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
12 changes: 9 additions & 3 deletions unified-runtime/scripts/core/PROG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,17 @@ points for this are generally of the form:

where ``propName`` selects the information to query out. The object info enum
representing possible queries will generally be found in the enums section of
the relevant object. Some info queries would be difficult or impossible to
support for certain backends, these are denoted with [optional-query] in the
enum description. Using any enum marked optional in this way may result in
the relevant object.

Some info queries would be difficult or impossible to support for certain
backends, these are denoted with [optional-query] in the enum description.
Using any enum marked optional in this way may result in
${X}_RESULT_ERROR_UNSUPPORTED_ENUMERATION if the adapter doesn't support it.

Some info queries may become deprecated, denoted with [deprecated-value] in the
enum description. Using any enum marked as deprecated in this way may result in
${X}_RESULT_ERROR_INVALID_ENUMERATION if the adapter has ceased to support it.

Programs and Kernels
====================

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
32 changes: 28 additions & 4 deletions unified-runtime/scripts/templates/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_array_element_type(cls, name):
def get_struct_members(type_name, meta):
struct_type = _remove_const_ptr(type_name)
if not struct_type in meta["struct"]:
raise Exception(f"Cannot return members of non-struct type {struct_type}")
raise Exception(f"Cannot return members of non-struct type {struct_type}.")
return meta["struct"][struct_type]["members"]


Expand Down 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 @@ -917,13 +925,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 Expand Up @@ -1974,7 +1983,7 @@ def transform_queue_related_function_name(
function_name = function_name[0].lower() + function_name[1:]

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

params = make_param_lines(namespace, tags, obj, format=format)
params = params[1:]
Expand Down Expand Up @@ -2004,3 +2013,18 @@ def get_optional_queries(specs, namespace, tags):
type_name = make_type_name(namespace, tags, obj)
optional_queries[type_name] = optional_etors
return optional_queries


"""
Public:
Generator returning non-deprecated enum values.
"""


def get_etors(obj):
if not obj_traits.is_enum(obj):
raise TypeError("obj parameter is not an enum.")
for item in obj["etors"]:
if etor_traits.is_deprecated_etor(item):
continue
yield item
8 changes: 4 additions & 4 deletions unified-runtime/scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
%else:
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']):
%for n, item in enumerate(th.get_etors(obj)):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
%>case ${ename}:
Expand All @@ -216,7 +216,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
}

switch (value) {
%for n, item in enumerate(obj['etors']):
%for n, item in enumerate(th.get_etors(obj)):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
vtype = th.etor_get_associated_type(n, tags, item)
Expand Down Expand Up @@ -281,7 +281,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
## structure type enum value must be first
const enum ${th.make_enum_name(n, tags, obj)} *value = (const enum ${th.make_enum_name(n, tags, obj)} *)ptr;
switch (*value) {
%for n, item in enumerate(obj['etors']):
%for n, item in enumerate(th.get_etors(obj)):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
%>
Expand All @@ -307,7 +307,7 @@ template <typename T> inline ${x}_result_t printTagged(std::ostream &os, const v
inline ${x}_result_t printFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os, uint32_t flag) {
uint32_t val = flag;
bool first = true;
%for n, item in enumerate(obj['etors']):
%for n, item in enumerate(th.get_etors(obj)):
<%
ename = th.make_etor_name(n, tags, obj['name'], item['name'])
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from templates import helper as th

%for obj in th.extract_objs(specs, r"enum"):
%if obj["name"] == '$x_structure_type_t':
%for etor in obj['etors']:
%for etor in th.get_etors(obj):
%if 'UINT32' not in etor['name']:
template <>
struct stype_map<${x}_${etor['desc'][3:]}> : stype_map_impl<${X}_${etor['name'][3:]}> {};
Expand Down
8 changes: 4 additions & 4 deletions unified-runtime/scripts/templates/tools-info.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace urinfo {
%for obj in th.extract_objs(specs, r"enum"):
%if obj["name"] == '$x_loader_config_info_t':
inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, std::string_view prefix = " ") {
%for etor in obj['etors']:
%for etor in th.get_etors(obj):
%if 'REFERENCE_COUNT' not in etor['name']:
<%etype = th.etor_get_associated_type(n, tags, etor)
%>std::cout << prefix;
Expand All @@ -43,7 +43,7 @@ inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, st
%endif
%if obj["name"] == '$x_adapter_info_t':
inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view prefix = " ") {
%for etor in obj['etors']:
%for etor in th.get_etors(obj):
%if 'REFERENCE_COUNT' not in etor['name']:
<%etype = th.etor_get_associated_type(n, tags, etor)
%>std::cout << prefix;
Expand All @@ -55,7 +55,7 @@ inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view p
%endif
%if obj["name"] == '$x_platform_info_t':
inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_view prefix = " ") {
%for etor in obj['etors']:
%for etor in th.get_etors(obj):
<%etype = th.etor_get_associated_type(n, tags, etor)
%>std::cout << prefix;
printPlatformInfo<${etype}>(hPlatform, ${etor['name'].replace('$X', X)});
Expand All @@ -65,7 +65,7 @@ inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_vie
%endif
%if obj['name'] == '$x_device_info_t':
inline void printDeviceInfos(${x}_device_handle_t hDevice, std::string_view prefix = " ") {
%for etor in obj['etors']:
%for etor in th.get_etors(obj):
<%etype = th.etor_get_associated_type(n, tags, etor)
%>std::cout << prefix;
%if etor['name'] == '$X_DEVICE_INFO_UUID':
Expand Down
8 changes: 0 additions & 8 deletions unified-runtime/source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_BFLOAT16: {
int Major = 0;
UR_CHECK_ERROR(cuDeviceGetAttribute(
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, hDevice->get()));

bool BFloat16 = (Major >= 8) ? true : false;
return ReturnValue(BFloat16);
}
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
// NVIDIA devices only support one sub-group size (the warp size)
int WarpSize = 0;
Expand Down
2 changes: 0 additions & 2 deletions unified-runtime/source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
#else
return ReturnValue(ur_bool_t{false});
#endif
case UR_DEVICE_INFO_BFLOAT16:
return ReturnValue(true);
case UR_DEVICE_INFO_ASYNC_BARRIER:
return ReturnValue(false);
case UR_DEVICE_INFO_IL_VERSION:
Expand Down
4 changes: 0 additions & 4 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,6 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice});
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU});
case UR_DEVICE_INFO_BFLOAT16: {
// bfloat16 math functions are not yet supported on Intel GPUs.
return ReturnValue(ur_bool_t{false});
}
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
// There are no explicit restrictions in L0 programming guide, so assume all
// are supported
Expand Down
2 changes: 0 additions & 2 deletions unified-runtime/source/adapters/native_cpu/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue(bool{0});
case UR_DEVICE_INFO_ATOMIC_64:
return ReturnValue(bool{1});
case UR_DEVICE_INFO_BFLOAT16:
return ReturnValue(bool{0});
case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT:
return ReturnValue(bool{0});
case UR_DEVICE_INFO_IMAGE_SRGB:
Expand Down
3 changes: 0 additions & 3 deletions unified-runtime/source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

return UR_RESULT_SUCCESS;
}

case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
const cl_device_info info_name = CL_DEVICE_SUB_GROUP_SIZES_INTEL;
bool isExtensionSupported;
Expand All @@ -1486,7 +1485,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue.template operator()<uint32_t>(SubGroupSizes.data(),
SubGroupSizes.size());
}

case UR_DEVICE_INFO_UUID: {
// Use the cl_khr_device_uuid extension, if available.
bool isKhrDeviceUuidSupported = false;
Expand Down Expand Up @@ -1565,7 +1563,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
// TODO: 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:
case UR_DEVICE_INFO_USM_POOL_SUPPORT: // end of TODO
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
Expand Down
17 changes: 0 additions & 17 deletions unified-runtime/test/conformance/device/urDeviceGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,23 +1758,6 @@ TEST_P(urDeviceGetInfoTest, SuccessAtomicFenceScopeCapabilities) {
ASSERT_EQ(property_value & UR_MEMORY_SCOPE_CAPABILITY_FLAGS_MASK, 0);
}

TEST_P(urDeviceGetInfoTest, SuccessBFloat64) {
size_t property_size = 0;
const ur_device_info_t property_name = UR_DEVICE_INFO_BFLOAT16;

ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urDeviceGetInfo(device, property_name, 0, nullptr, &property_size),
property_name);
ASSERT_EQ(property_size, sizeof(ur_bool_t));

ur_bool_t property_value = false;
ASSERT_SUCCESS(urDeviceGetInfo(device, property_name, property_size,
&property_value, nullptr));

bool casted_value = static_cast<bool>(property_value);
ASSERT_TRUE(casted_value == false || casted_value == true);
}

TEST_P(urDeviceGetInfoTest, SuccessMaxComputeQueueIndices) {
UUR_KNOWN_FAILURE_ON(uur::NativeCPU{});

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
2 changes: 0 additions & 2 deletions unified-runtime/tools/urinfo/urinfo.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.