Skip to content

Commit e48ba39

Browse files
committed
Additional information is now printed when dpctl.dump is called.
1 parent 03a2ab3 commit e48ba39

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

backends/source/dppl_sycl_device_interface.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ using namespace cl::sycl;
3535
namespace
3636
{
3737
// Create wrappers for C Binding types (see CBindingWrapping.h).
38-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(device, DPPLSyclDeviceRef)
38+
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(device, DPPLSyclDeviceRef)
3939

4040
/*!
4141
* @brief Helper function to print the metadata for a sycl::device.
@@ -54,6 +54,23 @@ void dump_device_info (const device & Device)
5454
<< Device.get_info<info::device::vendor>() << '\n';
5555
ss << std::setw(4) << " " << std::left << std::setw(16) << "Profile"
5656
<< Device.get_info<info::device::profile>() << '\n';
57+
ss << std::setw(4) << " " << std::left << std::setw(16) << "Device type";
58+
59+
try {
60+
if (Device.has(aspect::accelerator))
61+
ss << "accelerator" << '\n';
62+
else if (Device.has(aspect::cpu))
63+
ss << "cpu" << '\n';
64+
else if (Device.has(aspect::custom))
65+
ss << "custom" << '\n';
66+
else if (Device.has(aspect::gpu))
67+
ss << "gpu" << '\n';
68+
else if (Device.has(aspect::host))
69+
ss << "host" << '\n';
70+
} catch (runtime_error re) {
71+
// \todo handle errors
72+
ss << "unknown\n";
73+
}
5774

5875
std::cout << ss.str();
5976
}

backends/source/dppl_sycl_platform_interface.cpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ using namespace cl::sycl;
3838
* found on the system:
3939
* - info::platform::name
4040
* - info::platform::version
41+
* - info::platform::vendor
4142
* - info::platform::profile
43+
* - backend (opencl, cuda, level-zero, host)
44+
* - number of devices on the platform
4245
*
46+
* Additionally, for each device we print out:
47+
* - info::device::name
48+
* - info::device::driver_version
49+
* - type of the device based on the aspects cpu, gpu, accelerator.
4350
*/
4451
void DPPLPlatform_DumpInfo ()
4552
{
@@ -51,14 +58,54 @@ void DPPLPlatform_DumpInfo ()
5158
std::cout << "---Platform " << i << '\n';
5259
std::stringstream ss;
5360

61+
auto vendor = p.get_info<info::platform::vendor>();
62+
if (vendor.empty())
63+
vendor = "unknown";
64+
5465
ss << std::setw(4) << " " << std::left << std::setw(12) << "Name"
5566
<< p.get_info<info::platform::name>() << '\n';
5667
ss << std::setw(4) << " " << std::left << std::setw(12) << "Version"
5768
<< p.get_info<info::platform::version>() << '\n';
5869
ss << std::setw(4) << " " << std::left << std::setw(12) << "Vendor"
59-
<< p.get_info<info::platform::vendor>() << '\n';
70+
<< vendor << '\n';
6071
ss << std::setw(4) << " " << std::left << std::setw(12) << "Profile"
6172
<< p.get_info<info::platform::profile>() << '\n';
73+
ss << std::setw(4) << " " << std::left << std::setw(12) << "Backend";
74+
p.is_host() ? (ss << "unknown") : (ss << p.get_backend());
75+
ss << '\n';
76+
77+
// Get number of devices on the platform
78+
auto devices = p.get_devices();
79+
80+
ss << std::setw(4) << " " << std::left << std::setw(12) << "Devices"
81+
<< devices.size() << '\n';
82+
// Print some of the device information
83+
for (auto dn = 0ul; dn < devices.size(); ++dn) {
84+
ss << std::setw(4) << "---Device " << dn << '\n';
85+
ss << std::setw(8) << " " << std::left << std::setw(20)
86+
<< "Name" << devices[dn].get_info<info::device::name>() << '\n';
87+
ss << std::setw(8) << " " << std::left << std::setw(20)
88+
<< "Driver version"
89+
<< devices[dn].get_info<info::device::driver_version>() << '\n';
90+
ss << std::setw(8) << " " << std::left << std::setw(20)
91+
<< "Device type";
92+
93+
try {
94+
if (devices[dn].has(aspect::accelerator))
95+
ss << "accelerator" << '\n';
96+
else if (devices[dn].has(aspect::cpu))
97+
ss << "cpu" << '\n';
98+
else if (devices[dn].has(aspect::custom))
99+
ss << "custom" << '\n';
100+
else if (devices[dn].has(aspect::gpu))
101+
ss << "gpu" << '\n';
102+
else if (devices[dn].has(aspect::host))
103+
ss << "host" << '\n';
104+
} catch (runtime_error re) {
105+
// \todo handle errors
106+
ss << "unknown\n";
107+
}
108+
}
62109

63110
std::cout << ss.str();
64111
++i;

0 commit comments

Comments
 (0)