From a4a8283bb1d5e37f297447a76338817d1d769cc7 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Fri, 26 Apr 2024 06:55:54 -0500 Subject: [PATCH 1/3] 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. --- dpctl/tests/test_utils.py | 3 +++ dpctl/utils/__init__.py | 14 ++++++++++ dpctl/utils/src/device_queries.cpp | 42 ++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/dpctl/tests/test_utils.py b/dpctl/tests/test_utils.py index adcfa1b0a3..4966f42b55 100644 --- a/dpctl/tests/test_utils.py +++ b/dpctl/tests/test_utils.py @@ -141,6 +141,9 @@ def test_intel_device_info(): "gpu_subslices_per_slice", "gpu_eu_count_per_subslice", "max_mem_bandwidth", + "free_memory", + "memory_clock_rate", + "memory_bus_width", ] for descriptor_name in descr.keys(): test = descriptor_name in allowed_names diff --git a/dpctl/utils/__init__.py b/dpctl/utils/__init__.py index f5e5797d0c..5336dcaa70 100644 --- a/dpctl/utils/__init__.py +++ b/dpctl/utils/__init__.py @@ -27,6 +27,7 @@ ) from ._device_queries import ( intel_device_info_device_id, + intel_device_info_free_memory, intel_device_info_gpu_eu_count, intel_device_info_gpu_eu_count_per_subslice, intel_device_info_gpu_eu_simd_width, @@ -34,6 +35,8 @@ intel_device_info_gpu_slices, intel_device_info_gpu_subslices_per_slice, intel_device_info_max_mem_bandwidth, + intel_device_info_memory_bus_width, + intel_device_info_memory_clock_rate, ) from ._onetrace_context import onetrace_enabled @@ -62,6 +65,8 @@ def intel_device_info(dev, /): Number of EUs in subslice max_mem_bandwidth: Maximum memory bandwidth in bytes/second + free_memory: + Global memory available on the device in units of bytes Unsupported descriptors are omitted from the dictionary. @@ -97,6 +102,15 @@ def intel_device_info(dev, /): bw = intel_device_info_max_mem_bandwidth(dev) if bw: res["max_mem_bandwidth"] = bw + fm = intel_device_info_free_memory(dev) + if fm: + res["free_memory"] = fm + mcr = intel_device_info_memory_clock_rate(dev) + if mcr: + res["memory_clock_rate"] = mcr + mbw = intel_device_info_memory_bus_width(dev) + if mbw: + res["memory_bus_width"] = mbw return res return dict() diff --git a/dpctl/utils/src/device_queries.cpp b/dpctl/utils/src/device_queries.cpp index 6407e69dbb..132cb21b3e 100644 --- a/dpctl/utils/src/device_queries.cpp +++ b/dpctl/utils/src/device_queries.cpp @@ -100,6 +100,36 @@ std::uint64_t py_intel_max_mem_bandwidth(const sycl::device &d) return bandwidth_unavailable; } +std::uint64_t py_intel_free_memory(const sycl::device &d) +{ + static constexpr std::uint64_t free_memory_unavailable = 0; + + if (d.has(sycl::aspect::ext_intel_free_memory)) { + return d.get_info(); + } + return free_memory_unavailable; +} + +std::uint32_t py_intel_memory_clock_rate(const sycl::device &d) +{ + static constexpr std::uint32_t rate_unavailable = 0; + + if (d.has(sycl::aspect::ext_intel_memory_clock_rate)) { + return d.get_info(); + } + return rate_unavailable; +} + +std::uint32_t py_intel_memory_bus_width(const sycl::device &d) +{ + static constexpr std::uint32_t width_unavailable = 0; + + if (d.has(sycl::aspect::ext_intel_memory_bus_width)) { + return d.get_info(); + } + return width_unavailable; +} + }; // namespace PYBIND11_MODULE(_device_queries, m) @@ -136,4 +166,16 @@ PYBIND11_MODULE(_device_queries, m) m.def("intel_device_info_max_mem_bandwidth", &py_intel_max_mem_bandwidth, "Returns the maximum memory bandwidth in units of bytes/second.", py::arg("device")); + + m.def("intel_device_info_free_memory", &py_intel_free_memory, + "Returns the memory avialble on the device in units of bytes.", + py::arg("device")); + + m.def("intel_device_info_memory_clock_rate", &py_intel_memory_clock_rate, + "Returns the maximum clock rate of device's global memory in MHz.", + py::arg("device")); + + m.def("intel_device_info_memory_bus_width", &py_intel_memory_bus_width, + "Returns the maximum bus width between device and memory in bits.", + py::arg("device")); } From 3df29cd5826cf79d035dd2f95cc95a7b49149ff1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Fri, 26 Apr 2024 12:30:15 -0500 Subject: [PATCH 2/3] Update dpctl/utils/src/device_queries.cpp Fixed typo Co-authored-by: ndgrigorian <46709016+ndgrigorian@users.noreply.github.com> --- dpctl/utils/src/device_queries.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpctl/utils/src/device_queries.cpp b/dpctl/utils/src/device_queries.cpp index 132cb21b3e..c350a1f280 100644 --- a/dpctl/utils/src/device_queries.cpp +++ b/dpctl/utils/src/device_queries.cpp @@ -168,7 +168,7 @@ PYBIND11_MODULE(_device_queries, m) py::arg("device")); m.def("intel_device_info_free_memory", &py_intel_free_memory, - "Returns the memory avialble on the device in units of bytes.", + "Returns the memory available on the device in units of bytes.", py::arg("device")); m.def("intel_device_info_memory_clock_rate", &py_intel_memory_clock_rate, From 94e36614929bb39cf2ebd9886470a925ab373d59 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Sat, 27 Apr 2024 19:16:00 +0000 Subject: [PATCH 3/3] Added note that ZES_ENABLE_SYSMAN may need to be set The lenient verbiage is to allow Level-Zero driver to change its defaults. --- dpctl/utils/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dpctl/utils/__init__.py b/dpctl/utils/__init__.py index 5336dcaa70..e0c14a263d 100644 --- a/dpctl/utils/__init__.py +++ b/dpctl/utils/__init__.py @@ -72,6 +72,10 @@ def intel_device_info(dev, /): Descriptors other than the PCI identifier are supported only for :class:`.SyclDevices` with Level-Zero backend. + + .. note:: + Environment variable ``ZES_ENABLE_SYSMAN`` may need to be set + to ``1`` for the ``"free_memory"`` key to be reported. """ if not isinstance(dev, SyclDevice): raise TypeError(f"Expected dpctl.SyclDevice, got {type(dev)}")