Skip to content

Commit a4a8283

Browse files
Expanded intel_device_info output
Added "free_memory" for Free Global Memory on the device in bytes, "memory_clock_rate" for Maximum Memory Clock Rate in MHz, and "memory_bus_width" for bus width in bits.
1 parent aaf444e commit a4a8283

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

dpctl/tests/test_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ def test_intel_device_info():
141141
"gpu_subslices_per_slice",
142142
"gpu_eu_count_per_subslice",
143143
"max_mem_bandwidth",
144+
"free_memory",
145+
"memory_clock_rate",
146+
"memory_bus_width",
144147
]
145148
for descriptor_name in descr.keys():
146149
test = descriptor_name in allowed_names

dpctl/utils/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727
)
2828
from ._device_queries import (
2929
intel_device_info_device_id,
30+
intel_device_info_free_memory,
3031
intel_device_info_gpu_eu_count,
3132
intel_device_info_gpu_eu_count_per_subslice,
3233
intel_device_info_gpu_eu_simd_width,
3334
intel_device_info_gpu_hw_threads_per_eu,
3435
intel_device_info_gpu_slices,
3536
intel_device_info_gpu_subslices_per_slice,
3637
intel_device_info_max_mem_bandwidth,
38+
intel_device_info_memory_bus_width,
39+
intel_device_info_memory_clock_rate,
3740
)
3841
from ._onetrace_context import onetrace_enabled
3942

@@ -62,6 +65,8 @@ def intel_device_info(dev, /):
6265
Number of EUs in subslice
6366
max_mem_bandwidth:
6467
Maximum memory bandwidth in bytes/second
68+
free_memory:
69+
Global memory available on the device in units of bytes
6570
6671
Unsupported descriptors are omitted from the dictionary.
6772
@@ -97,6 +102,15 @@ def intel_device_info(dev, /):
97102
bw = intel_device_info_max_mem_bandwidth(dev)
98103
if bw:
99104
res["max_mem_bandwidth"] = bw
105+
fm = intel_device_info_free_memory(dev)
106+
if fm:
107+
res["free_memory"] = fm
108+
mcr = intel_device_info_memory_clock_rate(dev)
109+
if mcr:
110+
res["memory_clock_rate"] = mcr
111+
mbw = intel_device_info_memory_bus_width(dev)
112+
if mbw:
113+
res["memory_bus_width"] = mbw
100114
return res
101115
return dict()
102116

dpctl/utils/src/device_queries.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,36 @@ std::uint64_t py_intel_max_mem_bandwidth(const sycl::device &d)
100100
return bandwidth_unavailable;
101101
}
102102

103+
std::uint64_t py_intel_free_memory(const sycl::device &d)
104+
{
105+
static constexpr std::uint64_t free_memory_unavailable = 0;
106+
107+
if (d.has(sycl::aspect::ext_intel_free_memory)) {
108+
return d.get_info<sycl::ext::intel::info::device::free_memory>();
109+
}
110+
return free_memory_unavailable;
111+
}
112+
113+
std::uint32_t py_intel_memory_clock_rate(const sycl::device &d)
114+
{
115+
static constexpr std::uint32_t rate_unavailable = 0;
116+
117+
if (d.has(sycl::aspect::ext_intel_memory_clock_rate)) {
118+
return d.get_info<sycl::ext::intel::info::device::memory_clock_rate>();
119+
}
120+
return rate_unavailable;
121+
}
122+
123+
std::uint32_t py_intel_memory_bus_width(const sycl::device &d)
124+
{
125+
static constexpr std::uint32_t width_unavailable = 0;
126+
127+
if (d.has(sycl::aspect::ext_intel_memory_bus_width)) {
128+
return d.get_info<sycl::ext::intel::info::device::memory_bus_width>();
129+
}
130+
return width_unavailable;
131+
}
132+
103133
}; // namespace
104134

105135
PYBIND11_MODULE(_device_queries, m)
@@ -136,4 +166,16 @@ PYBIND11_MODULE(_device_queries, m)
136166
m.def("intel_device_info_max_mem_bandwidth", &py_intel_max_mem_bandwidth,
137167
"Returns the maximum memory bandwidth in units of bytes/second.",
138168
py::arg("device"));
169+
170+
m.def("intel_device_info_free_memory", &py_intel_free_memory,
171+
"Returns the memory avialble on the device in units of bytes.",
172+
py::arg("device"));
173+
174+
m.def("intel_device_info_memory_clock_rate", &py_intel_memory_clock_rate,
175+
"Returns the maximum clock rate of device's global memory in MHz.",
176+
py::arg("device"));
177+
178+
m.def("intel_device_info_memory_bus_width", &py_intel_memory_bus_width,
179+
"Returns the maximum bus width between device and memory in bits.",
180+
py::arg("device"));
139181
}

0 commit comments

Comments
 (0)