22
22
#include < iostream>
23
23
#include < map>
24
24
#include < stdlib.h>
25
+ #include < string>
25
26
#include < vector>
26
27
27
28
#ifdef _WIN32
@@ -68,6 +69,43 @@ std::string getDeviceTypeName(const device &Device) {
68
69
}
69
70
}
70
71
72
+ template <typename RangeTy, typename ElemTy>
73
+ bool contains (RangeTy &&Range, const ElemTy &Elem) {
74
+ return std::find (Range.begin (), Range.end (), Elem) != Range.end ();
75
+ }
76
+
77
+ bool isPartitionableBy (const device &Dev, info::partition_property Prop) {
78
+ return contains (Dev.get_info <info::device::partition_properties>(), Prop);
79
+ }
80
+
81
+ std::array<int , 2 > GetNumberOfSubAndSubSubDevices (const device &Device) {
82
+ int NumSubDevices = 0 ;
83
+ int NumSubSubDevices = 0 ;
84
+
85
+ // Assume a composite device hierarchy and try to partition Device by
86
+ // affinity.
87
+ if (isPartitionableBy (
88
+ Device, info::partition_property::partition_by_affinity_domain)) {
89
+ auto SubDevs = Device.create_sub_devices <
90
+ info::partition_property::partition_by_affinity_domain>(
91
+ info::partition_affinity_domain::next_partitionable);
92
+ NumSubDevices = SubDevs.size ();
93
+ NumSubSubDevices = GetNumberOfSubAndSubSubDevices (SubDevs[0 ])[0 ];
94
+ } else if (isPartitionableBy (
95
+ Device,
96
+ info::partition_property::ext_intel_partition_by_cslice)) {
97
+ auto SubDevs = Device.create_sub_devices <
98
+ info::partition_property::ext_intel_partition_by_cslice>();
99
+ NumSubDevices = SubDevs.size ();
100
+ // CCSs can't be divided further.
101
+ NumSubSubDevices = 0 ;
102
+ } else {
103
+ // Not partitionable for OpenCL, CUDA, and HIP backends.
104
+ }
105
+
106
+ return {NumSubDevices, NumSubDevices * NumSubSubDevices};
107
+ }
108
+
71
109
static void printDeviceInfo (const device &Device, bool Verbose,
72
110
const std::string &Prepend) {
73
111
auto DeviceVersion = Device.get_info <info::device::version>();
@@ -76,14 +114,35 @@ static void printDeviceInfo(const device &Device, bool Verbose,
76
114
auto DeviceDriverVersion = Device.get_info <info::device::driver_version>();
77
115
78
116
if (Verbose) {
79
- std::cout << Prepend << " Type : " << getDeviceTypeName (Device)
117
+ std::cout << Prepend << " Type : " << getDeviceTypeName (Device)
118
+ << std::endl;
119
+ std::cout << Prepend << " Version : " << DeviceVersion
80
120
<< std::endl;
81
- std::cout << Prepend << " Version : " << DeviceVersion << std::endl;
82
- std::cout << Prepend << " Name : " << DeviceName << std::endl;
83
- std::cout << Prepend << " Vendor : " << DeviceVendor << std::endl;
84
- std::cout << Prepend << " Driver : " << DeviceDriverVersion << std::endl;
121
+ std::cout << Prepend << " Name : " << DeviceName << std::endl;
122
+ std::cout << Prepend << " Vendor : " << DeviceVendor << std::endl;
123
+ std::cout << Prepend << " Driver : " << DeviceDriverVersion
124
+ << std::endl;
125
+
126
+ // Get and print device UUID, if it is available.
127
+ if (Device.has (aspect::ext_intel_device_info_uuid)) {
128
+ auto UUID = Device.get_info <sycl::ext::intel::info::device::uuid>();
129
+ std::cout << Prepend << " UUID : " ;
130
+ for (int i = 0 ; i < 16 ; i++) {
131
+ std::cout << std::to_string (UUID[i]);
132
+ }
133
+ std::cout << std::endl;
134
+ }
135
+
136
+ // Print sub and sub-sub devices.
137
+ {
138
+ auto DevCount = GetNumberOfSubAndSubSubDevices (Device);
139
+ std::cout << Prepend << " Num SubDevices : " << DevCount[0 ]
140
+ << std::endl;
141
+ std::cout << Prepend << " Num SubSubDevices : " << DevCount[1 ]
142
+ << std::endl;
143
+ }
85
144
86
- std::cout << Prepend << " Aspects :" ;
145
+ std::cout << Prepend << " Aspects :" ;
87
146
#define __SYCL_ASPECT (ASPECT, ID ) \
88
147
if (Device.has (aspect::ASPECT)) \
89
148
std::cout << " " << #ASPECT;
0 commit comments