-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL] Add UUID and sub-, sub-sub- device info in sycl-ls --verbose
#13999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* Test to check that sycl-ls is outputting UUID and number of sub and sub-sub | ||
* devices. */ | ||
// REQUIRES: gpu, level_zero | ||
|
||
// 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: {{.*}}Num SubDevices : {{.*}} | ||
// CHECK-NEXT: {{.*}}Num SubSubDevices : {{.*}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
#include <iostream> | ||
#include <map> | ||
#include <stdlib.h> | ||
#include <string> | ||
#include <vector> | ||
|
||
#ifdef _WIN32 | ||
|
@@ -68,6 +69,43 @@ 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>(); | ||
|
@@ -76,14 +114,35 @@ static void printDeviceInfo(const device &Device, bool Verbose, | |
auto DeviceDriverVersion = Device.get_info<info::device::driver_version>(); | ||
|
||
if (Verbose) { | ||
std::cout << Prepend << "Type : " << getDeviceTypeName(Device) | ||
std::cout << Prepend << "Type : " << getDeviceTypeName(Device) | ||
<< std::endl; | ||
std::cout << Prepend << "Version : " << DeviceVersion | ||
<< std::endl; | ||
std::cout << Prepend << "Version : " << DeviceVersion << std::endl; | ||
std::cout << Prepend << "Name : " << DeviceName << std::endl; | ||
std::cout << Prepend << "Vendor : " << DeviceVendor << std::endl; | ||
std::cout << Prepend << "Driver : " << DeviceDriverVersion << std::endl; | ||
std::cout << Prepend << "Name : " << DeviceName << std::endl; | ||
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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That can be done. But, Isn't the UUID size fixed to 16: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md#device-uuid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is documented as 16 then ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 << "Num SubDevices : " << DevCount[0] | ||
<< std::endl; | ||
std::cout << Prepend << "Num SubSubDevices : " << DevCount[1] | ||
<< std::endl; | ||
} | ||
|
||
std::cout << Prepend << "Aspects :"; | ||
std::cout << Prepend << "Aspects :"; | ||
#define __SYCL_ASPECT(ASPECT, ID) \ | ||
if (Device.has(aspect::ASPECT)) \ | ||
std::cout << " " << #ASPECT; | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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