Skip to content

Commit 707a124

Browse files
committed
Add support for getting device node mask
1 parent 9efadd2 commit 707a124

File tree

14 files changed

+155
-2
lines changed

14 files changed

+155
-2
lines changed

llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def AspectExt_intel_fan_speed : Aspect<"ext_intel_fan_speed">;
9393
def AspectExt_intel_power_limits : Aspect<"ext_intel_power_limits">;
9494
def AspectExt_oneapi_async_memory_alloc : Aspect<"ext_oneapi_async_memory_alloc">;
9595
def AspectExt_intel_device_info_luid : Aspect<"ext_intel_device_info_luid">;
96+
def AspectExt_intel_device_info_node_mask : Aspect<"ext_intel_device_info_node_mask">;
9697

9798
// Deprecated aspects
9899
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
@@ -165,7 +166,8 @@ def : TargetInfo<"__TestAspectList",
165166
AspectExt_intel_fan_speed,
166167
AspectExt_intel_power_limits,
167168
AspectExt_oneapi_async_memory_alloc,
168-
AspectExt_intel_device_info_luid],
169+
AspectExt_intel_device_info_luid,
170+
AspectExt_intel_device_info_node_mask],
169171
[]>;
170172
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
171173
// match.

sycl/doc/extensions/supported/sycl_ext_intel_device_info.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of
2020
| 5 | Device ID is supported |
2121
| 6 | Memory clock rate and bus width queries are supported |
2222
| 7 | Throttle reasons, fan speed and power limits queries are supported |
23-
| 8 | Device LUID is supported |
23+
| 8 | Device LUID and device node mask is supported |
2424

2525

2626

@@ -657,6 +657,37 @@ The LUID can be obtained using the standard `get_info()` interface.
657657
}
658658
```
659659

660+
661+
# Device Node Mask #
662+
663+
A new device descriptor is added which will provide the device node mask.
664+
665+
## Version ##
666+
667+
The extension supports this query in version 8 and later.
668+
669+
| Device Descriptors | Return Type | Description |
670+
| ------------------ | ----------- | ----------- |
671+
|`ext::intel::info::device::node_mask` |`unsigned int` | Returns the device node mask. |
672+
673+
## Aspects ##
674+
675+
A new aspect, `ext_intel_device_info_node_mask`, is added.
676+
677+
## Error Condition ##
678+
679+
Throws a synchronous `exception` with the `errc::feature_not_supported` error code if the device does not have `aspect::ext_intel_device_info_node_mask`.
680+
681+
## Example Usage ##
682+
683+
The device node mask can be obtained using the standard `get_info()` interface.
684+
685+
```
686+
if (dev.has(aspect::ext_intel_device_info_node_mask)) {
687+
auto node_mask = dev.get_info<ext::intel::info::device::node_mask>();
688+
}
689+
```
690+
660691
# Deprecated queries #
661692

662693
The table below lists deprecated, that would soon be removed and their replacements:

sycl/include/sycl/info/aspects.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ __SYCL_ASPECT(ext_intel_fan_speed, 85)
7979
__SYCL_ASPECT(ext_intel_power_limits, 86)
8080
__SYCL_ASPECT(ext_oneapi_async_memory_alloc, 87)
8181
__SYCL_ASPECT(ext_intel_device_info_luid, 88)
82+
__SYCL_ASPECT(ext_intel_device_info_node_mask, 89)
8283

sycl/include/sycl/info/ext_intel_device_traits.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, fan_speed, int32_t, UR_DEVICE_INFO_
2222
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, min_power_limit, int32_t, UR_DEVICE_INFO_MIN_POWER_LIMIT)
2323
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, max_power_limit, int32_t, UR_DEVICE_INFO_MAX_POWER_LIMIT)
2424
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, luid, detail::luid_type, __SYCL_TRAIT_HANDLED_IN_RT)
25+
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, node_mask, uint32_t, __SYCL_TRAIT_HANDLED_IN_RT)
2526
#ifdef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
2627
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC
2728
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF

sycl/source/detail/device_impl.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,13 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
12021202
"The device does not have the ext_intel_device_info_luid aspect");
12031203
return get_info_impl<UR_DEVICE_INFO_LUID>();
12041204
}
1205+
CASE(ext::intel::info::device::node_mask) {
1206+
if (!has(aspect::ext_intel_device_info_node_mask))
1207+
throw exception(
1208+
make_error_code(errc::feature_not_supported),
1209+
"The device does not have the ext_intel_device_info_node_mask aspect");
1210+
return get_info_impl<UR_DEVICE_INFO_NODE_MASK>();
1211+
}
12051212
else {
12061213
constexpr auto Desc = UrInfoCode<Param>::value;
12071214
return static_cast<typename Param::return_type>(get_info_impl<Desc>());
@@ -1315,6 +1322,9 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
13151322
CASE(ext_intel_device_info_luid) {
13161323
return has_info_desc(UR_DEVICE_INFO_LUID);
13171324
}
1325+
CASE(ext_intel_device_info_node_mask) {
1326+
return has_info_desc(UR_DEVICE_INFO_NODE_MASK);
1327+
}
13181328
CASE(ext_intel_max_mem_bandwidth) {
13191329
// currently not supported
13201330
return false;

sycl/source/detail/ur_device_info_ret_types.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ MAP(UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE, ur_bool_t)
157157
MAP(UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES, ur_kernel_launch_properties_flags_t)
158158
// Manually changed std::vector<uint8_t> -> std::array<uint8_t, 8>
159159
MAP(UR_DEVICE_INFO_LUID, std::array<uint8_t, 8>)
160+
MAP(UR_DEVICE_INFO_NODE_MASK, uint32_t)
160161

161162
// These aren't present in the specification, extracted from ur_api.h
162163
// instead.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// REQUIRES: aspect-ext_intel_device_info_luid
2+
// REQUIRES: gpu, level_zero, level_zero_dev_kit, windows
3+
4+
// RUN: %{build} %level_zero_options -o %t.out
5+
// RUN: %{run} %t.out
6+
7+
// Test that the node mask is read correctly from Level Zero.
8+
9+
#include <iomanip>
10+
#include <iostream>
11+
#include <level_zero/ze_api.h>
12+
#include <sstream>
13+
#include <sycl/backend.hpp>
14+
#include <sycl/detail/core.hpp>
15+
16+
int main() {
17+
sycl::device dev;
18+
auto nodeMaskSYCL = dev.get_info<sycl::ext::intel::info::device::node_mask>();
19+
20+
std::cout << "SYCL: " << nodeMaskSYCL << std::endl;
21+
22+
auto zedev = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(dev);
23+
ze_device_properties_t device_properties{};
24+
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
25+
26+
ze_device_luid_ext_properties_t luid_device_properties{};
27+
luid_device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES;
28+
29+
device_properties.pNext = &luid_device_properties;
30+
31+
zeDeviceGetProperties(zedev, &device_properties);
32+
33+
ze_device_luid_ext_properties_t *luid_dev_prop =
34+
static_cast<ze_device_luid_ext_properties_t *>(device_properties.pNext);
35+
36+
uint32_t nodeMaskL0 = luid_dev_prop->nodeMask;
37+
38+
std::cout << "L0 : " << nodeMaskL0 << std::endl;
39+
40+
if (nodeMaskSYCL != nodeMaskL0) {
41+
std::cout << "FAILED" << std::endl;
42+
return -1;
43+
}
44+
45+
std::cout << "PASSED" << std::endl;
46+
return 0;
47+
}

unified-runtime/include/ur_api.h

Lines changed: 2 additions & 0 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: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ etors:
466466
desc: "[$x_kernel_launch_properties_flags_t] Bitfield of supported kernel launch properties."
467467
- name: LUID
468468
desc: "[uint8_t[]][optional-query] return device LUID"
469+
- name: NODE_MASK
470+
desc: "[uint32_t][optional-query] return device node mask"
469471
--- #--------------------------------------------------------------------------
470472
type: function
471473
desc: "Retrieves various information about device"

0 commit comments

Comments
 (0)