Skip to content

Commit 0bebee4

Browse files
committed
changed device-id unique per backend
Signed-off-by: Byoungro So <[email protected]>
1 parent e898390 commit 0bebee4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sycl/doc/EnvironmentVariables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Possible values of "device_type" are:
6565
- acc
6666
- \*
6767

68-
Device_num is an integer that indexes the enumeration of devices from the sycl-ls utility tool, where the first device in that enumeration has index zero in each platform. For example, SYCL_DEVICE_FILTER=2 will return all devices with index '2' from all different platforms. If multiple devices satisfy this device number (e.g., GPU and CPU devices can be assigned device number '2'), then default_selector will choose the device with the highest heuristic point.
68+
Device_num is an integer that indexes the enumeration of devices from the sycl-ls utility tool, where the first device in that enumeration has index zero in each backend. For example, SYCL_DEVICE_FILTER=2 will return all devices with index '2' from all different backends. If multiple devices satisfy this device number (e.g., GPU and CPU devices can be assigned device number '2'), then default_selector will choose the device with the highest heuristic point.
6969

7070
Assuming a filter has all three elements of the triple, it selects only those devices that come from the given backend, have the specified device type, AND have the given device index. If more than one filter is specified, the RT is restricted to the union of devices selected by all filters. The RT does not include the "host" backend and the host device automatically unless one of the filters explicitly specifies the "host" device type. Therefore, SYCL_DEVICE_FILTER=host should be set to enforce SYCL to use the host device only.
7171

sycl/tools/sycl-ls/sycl-ls.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
using namespace cl::sycl;
2626

27+
#define NumOfBackends 5
28+
2729
// Controls verbose output vs. concise.
2830
bool verbose;
2931

@@ -107,9 +109,14 @@ int main(int argc, char **argv) {
107109
std::cout << "Platforms: " << Platforms.size() << std::endl;
108110

109111
uint32_t PlatformNum = 0;
112+
std::vector<uint32_t> DeviceNums;
113+
// For each backend, device num starts at zero.
114+
for (int I = 0; I < NumOfBackends; I++) {
115+
DeviceNums.push_back(0);
116+
}
110117

111118
for (const auto &Platform : Platforms) {
112-
uint32_t DeviceNum = 0;
119+
backend Backend = Platform.get_backend();
113120
++PlatformNum;
114121
if (verbose) {
115122
auto PlatformVersion = Platform.get_info<info::platform::version>();
@@ -124,10 +131,10 @@ int main(int argc, char **argv) {
124131
if (verbose)
125132
std::cout << " Devices : " << Devices.size() << std::endl;
126133
for (const auto &Device : Devices) {
134+
uint32_t DeviceNum = DeviceNums[(int)Backend]++;
127135
if (verbose)
128136
std::cout << " Device [#" << DeviceNum << "]:" << std::endl;
129137
else {
130-
backend Backend = Platform.get_backend();
131138
std::cout << "[" << Backend << ":" << getDeviceTypeName(Device) << ":"
132139
<< DeviceNum << "]";
133140
}

0 commit comments

Comments
 (0)