Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Test to check that sycl-ls is outputting UUID and number of sub and sub-sub devices. */
// REQUIRES: gpu, level_zero
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work on Gen12 ? Or is it PVC only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work on Gen12 as well. The test passes on Gen12 precommit: https://github.com/intel/llvm/actions/runs/9343215312/job/25714501971


// UNSUPPORTED: gpu-intel-pvc-1T

// As of now, ZEX_NUMBER_OF_CCS is not working with FLAT hierachy,
// which is the new default on PVC.

// RUN: env ONEAPI_DEVICE_SELECTOR="level_zero:*" env ZE_FLAT_DEVICE_HIERARCHY=COMPOSITE env ZEX_NUMBER_OF_CCS=0:4 sycl-ls --verbose >%t.default.out
// RUN: FileCheck %s --input-file %t.default.out

// CHECK: {{.*}}UUID : {{.*}}
// CHECK: {{.*}}SubDevices : 2{{.*}}
// CHECK-NEXT: {{.*}}SubSubDevices : 8{{.*}}
50 changes: 50 additions & 0 deletions sycl/tools/sycl-ls/sycl-ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <iostream>
#include <map>
#include <stdlib.h>
#include <string>
#include <vector>

#ifdef _WIN32
Expand Down Expand Up @@ -68,6 +69,38 @@ std::string getDeviceTypeName(const device &Device) {
}
}

template <typename RangeTy, typename ElemTy>
bool contains(RangeTy &&Range, const ElemTy &Elem) {
return std::find(Range.begin(), Range.end(), Elem) != Range.end();
}

bool isPartitionableBy(const device &Dev, info::partition_property Prop) {
return contains(Dev.get_info<info::device::partition_properties>(), Prop);
}

std::array<int, 2> GetNumberOfSubAndSubSubDevices(const device &Device) {
int NumSubDevices = 0;
int NumSubSubDevices = 0;

// Assume a composite device hierarchy and try to partition Device by affinity.
if (isPartitionableBy(Device, info::partition_property::partition_by_affinity_domain)) {
auto SubDevs = Device.create_sub_devices<info::partition_property::partition_by_affinity_domain>(info::partition_affinity_domain::next_partitionable);
NumSubDevices = SubDevs.size();
NumSubSubDevices = GetNumberOfSubAndSubSubDevices(SubDevs[0])[0];
}
else if (isPartitionableBy(Device, info::partition_property::ext_intel_partition_by_cslice)) {
auto SubDevs = Device.create_sub_devices<info::partition_property::ext_intel_partition_by_cslice>();
NumSubDevices = SubDevs.size();
// CCSs can't be divided further.
NumSubSubDevices = 0;
}
else {
// Not partitionable for OpenCL, CUDA, and HIP backends.
}

return {NumSubDevices, NumSubDevices * NumSubSubDevices};
}

static void printDeviceInfo(const device &Device, bool Verbose,
const std::string &Prepend) {
auto DeviceVersion = Device.get_info<info::device::version>();
Expand All @@ -83,6 +116,23 @@ static void printDeviceInfo(const device &Device, bool Verbose,
std::cout << Prepend << "Vendor : " << DeviceVendor << std::endl;
std::cout << Prepend << "Driver : " << DeviceDriverVersion << std::endl;

// Get and print device UUID, if it is available.
if (Device.has(aspect::ext_intel_device_info_uuid)) {
auto UUID = Device.get_info<sycl::ext::intel::info::device::uuid>();
std::cout << Prepend << "UUID : ";
for (int i = 0; i < 16; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you be using ZE_MAX_DEVICE_UUID_SIZE instead of assuming size is 16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is documented as 16 then ok.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just use a range-based for loop on UUID

std::cout << std::to_string(UUID[i]);
}
std::cout << std::endl;
}

// Print sub and sub-sub devices.
{
auto DevCount = GetNumberOfSubAndSubSubDevices(Device);
std::cout << Prepend << "SubDevices : " << DevCount[0] << std::endl;
std::cout << Prepend << "SubSubDevices : " << DevCount[1] << std::endl;
}

std::cout << Prepend << "Aspects :";
#define __SYCL_ASPECT(ASPECT, ID) \
if (Device.has(aspect::ASPECT)) \
Expand Down