Skip to content

Commit

Permalink
[SYCL] Align sycl-ls output with ONEAPI_DEVICE_SELECTOR syntax (intel…
Browse files Browse the repository at this point in the history
…#12368)

Emit

  `[backend:device_type][backend:device_number] <Text...>`

in place of

  `[backend:device_type:device_number] <Text...>`

as ONEAPI_DEVICE_SELECTOR accepts either device_type or device_number
and not both simultaneously.
aelovikov-intel authored Jan 12, 2024
1 parent 230692a commit 38ce764
Showing 2 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -413,7 +413,7 @@
config.available_features.add("gpu-amd-gfx90a")
if not line.startswith("["):
continue
(backend, device, _) = line[1:].split(":", 2)
(backend, device) = line[1:].split("]")[0].split(":")
devices.add("{}:{}".format(backend, device))
config.sycl_devices = list(devices)

39 changes: 24 additions & 15 deletions sycl/tools/sycl-ls/sycl-ls.cpp
Original file line number Diff line number Diff line change
@@ -117,25 +117,27 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}

bool SuppressNumberPrinting = false;

const char *filter = std::getenv("SYCL_DEVICE_FILTER");
if (filter) {
std::cerr << "Warning: SYCL_DEVICE_FILTER environment variable is set to "
<< filter << "." << std::endl;
std::cerr
<< "To see the correct device id, please unset SYCL_DEVICE_FILTER."
<< std::endl
<< std::endl;
std::cerr << "To see device ids, please unset SYCL_DEVICE_FILTER."
<< std::endl
<< std::endl;
SuppressNumberPrinting = true;
}

const char *ods_targets = std::getenv("ONEAPI_DEVICE_SELECTOR");
if (ods_targets) {
std::cerr
<< "Warning: ONEAPI_DEVICE_SELECTOR environment variable is set to "
<< ods_targets << "." << std::endl;
std::cerr
<< "To see the correct device id, please unset ONEAPI_DEVICE_SELECTOR."
<< std::endl
<< std::endl;
std::cerr << "To see device ids, please unset ONEAPI_DEVICE_SELECTOR."
<< std::endl
<< std::endl;
SuppressNumberPrinting = true;
}

try {
@@ -156,9 +158,13 @@ int main(int argc, char **argv) {

for (const auto &Device : Devices) {
std::cout << "[" << detail::get_backend_name_no_vendor(Backend) << ":"
<< getDeviceTypeName(Device) << ":" << DeviceNums[Backend]
<< "] ";
++DeviceNums[Backend];
<< getDeviceTypeName(Device) << "]";
if (!SuppressNumberPrinting) {
std::cout << "[" << detail::get_backend_name_no_vendor(Backend) << ":"
<< DeviceNums[Backend] << "]";
++DeviceNums[Backend];
}
std::cout << " ";
// Verbose parameter is set to false to print regular devices output
// first
printDeviceInfo(Device, false, PlatformName);
@@ -168,7 +174,8 @@ int main(int argc, char **argv) {
if (verbose) {
std::cout << "\nPlatforms: " << Platforms.size() << std::endl;
uint32_t PlatformNum = 0;
DeviceNums.clear();
if (!SuppressNumberPrinting)
DeviceNums.clear();
for (const auto &Platform : Platforms) {
backend Backend = Platform.get_backend();
++PlatformNum;
@@ -183,9 +190,11 @@ int main(int argc, char **argv) {
const auto &Devices = Platform.get_devices();
std::cout << " Devices : " << Devices.size() << std::endl;
for (const auto &Device : Devices) {
std::cout << " Device [#" << DeviceNums[Backend]
<< "]:" << std::endl;
++DeviceNums[Backend];
if (!SuppressNumberPrinting) {
std::cout << " Device [#" << DeviceNums[Backend]
<< "]:" << std::endl;
++DeviceNums[Backend];
}
printDeviceInfo(Device, true, " ");
}
}

0 comments on commit 38ce764

Please sign in to comment.