From 1878309a05adb2f0c7e6fb122bb07643abc2a82f Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 31 May 2024 15:55:19 -0700 Subject: [PATCH 1/4] Add UUID and CCS info in sycl-ls --verbose --- sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp | 14 ++++++ sycl/tools/sycl-ls/sycl-ls.cpp | 50 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp diff --git a/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp new file mode 100644 index 0000000000000..111e96d04374a --- /dev/null +++ b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp @@ -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 + +// 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{{.*}} \ No newline at end of file diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index a59b33c1de65d..d7dffd8390421 100644 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #ifdef _WIN32 @@ -68,6 +69,38 @@ std::string getDeviceTypeName(const device &Device) { } } +template +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(), Prop); +} + +std::array 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_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(); + 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(); @@ -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(); + std::cout << Prepend << "UUID : "; + for (int i = 0; i < 16; i++) { + 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)) \ From fac3bf77182bed4028db24816b35a31e64953e34 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 31 May 2024 16:25:41 -0700 Subject: [PATCH 2/4] Fix formatting --- sycl/tools/sycl-ls/sycl-ls.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index d7dffd8390421..fab276fa9c5e6 100644 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -109,17 +109,19 @@ static void printDeviceInfo(const device &Device, bool Verbose, auto DeviceDriverVersion = Device.get_info(); 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 << "Name : " << DeviceName << std::endl; + std::cout << Prepend << "Vendor : " << DeviceVendor << std::endl; + std::cout << Prepend << "Driver : " << DeviceDriverVersion << 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; // Get and print device UUID, if it is available. if (Device.has(aspect::ext_intel_device_info_uuid)) { auto UUID = Device.get_info(); - std::cout << Prepend << "UUID : "; + std::cout << Prepend << "UUID : "; for (int i = 0; i < 16; i++) { std::cout << std::to_string(UUID[i]); } @@ -129,11 +131,13 @@ static void printDeviceInfo(const device &Device, bool Verbose, // 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 << "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; From e22bdffcfe6b7f442e00baa769b0fe4d9075d90b Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Sun, 2 Jun 2024 19:11:46 -0700 Subject: [PATCH 3/4] Fix formatting; test case --- sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp | 9 ++++---- sycl/tools/sycl-ls/sycl-ls.cpp | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp index 111e96d04374a..49f312c6115dd 100644 --- a/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp +++ b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp @@ -1,4 +1,5 @@ -/* Test to check that sycl-ls is outputting UUID and number of sub and sub-sub devices. */ +/* 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 @@ -9,6 +10,6 @@ // 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{{.*}} \ No newline at end of file +// CHECK: {{.*}}UUID : {{.*}} +// CHECK: {{.*}}Num SubDevices : {{.*}} +// CHECK-NEXT: {{.*}}Num SubSubDevices : {{.*}} \ No newline at end of file diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index fab276fa9c5e6..f71221840d397 100644 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -82,19 +82,24 @@ std::array 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_affinity_domain::next_partitionable); + // 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(); + } 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 { + } else { // Not partitionable for OpenCL, CUDA, and HIP backends. } From 2c56e1d710a413e7cf37b5e910cfcb429d963dab Mon Sep 17 00:00:00 2001 From: Udit Agarwal Date: Mon, 3 Jun 2024 14:09:57 -0700 Subject: [PATCH 4/4] Add line at EOF --- sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp index 49f312c6115dd..45650758bc756 100644 --- a/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp +++ b/sycl/test-e2e/Plugin/sycl-ls-uuid-subdevs.cpp @@ -12,4 +12,4 @@ // CHECK: {{.*}}UUID : {{.*}} // CHECK: {{.*}}Num SubDevices : {{.*}} -// CHECK-NEXT: {{.*}}Num SubSubDevices : {{.*}} \ No newline at end of file +// CHECK-NEXT: {{.*}}Num SubSubDevices : {{.*}}