diff --git a/python/src/main.cpp b/python/src/main.cpp index 9e065c21..acf4308a 100644 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -9,6 +9,8 @@ #include "docstrings.hpp" namespace py = pybind11; +using namespace pybind11::literals; // for the `_a` literal + //used in Core.hpp py::object kp_debug, kp_info, kp_warning, kp_error; @@ -217,7 +219,24 @@ PYBIND11_MODULE(kp, m) { py::arg("spirv"), py::arg("workgroup") = kp::Workgroup(), py::arg("spec_consts") = kp::Constants(), - py::arg("push_consts") = kp::Constants()); + py::arg("push_consts") = kp::Constants()) + .def("get_device_properties", [](kp::Manager& self){ + const auto properties = self.getDeviceProperties(); + py::dict py_props( + "device_name"_a = std::string(properties.deviceName.data()), + "max_work_group_count"_a = py::make_tuple(properties.limits.maxComputeWorkGroupCount[0], + properties.limits.maxComputeWorkGroupCount[1], + properties.limits.maxComputeWorkGroupCount[2]), + "max_work_group_invocations"_a = properties.limits.maxComputeWorkGroupInvocations, + "max_work_group_size"_a = py::make_tuple(properties.limits.maxComputeWorkGroupSize[0], + properties.limits.maxComputeWorkGroupSize[1], + properties.limits.maxComputeWorkGroupSize[2]), + "timestamps_supported"_a = (bool)properties.limits.timestampComputeAndGraphics + ); + + return py_props; + }, "Return a dict containing information about the device"); + #ifdef VERSION_INFO m.attr("__version__") = VERSION_INFO; diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 547793cc..44689d86 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -2091,6 +2091,11 @@ class Manager **/ void clear(); + /** + * Return a struct containing information about the device. + **/ + vk::PhysicalDeviceProperties getDeviceProperties() const; + private: // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mInstance = nullptr; diff --git a/src/Manager.cpp b/src/Manager.cpp index cdc89633..807d4832 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -447,4 +447,10 @@ Manager::sequence(uint32_t queueIndex, uint32_t totalTimestamps) return sq; } +vk::PhysicalDeviceProperties +Manager::getDeviceProperties() const +{ + return this->mPhysicalDevice->getProperties(); +} + } diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 6b06b83f..e9e28415 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -153,6 +153,11 @@ class Manager **/ void clear(); + /** + * Return a struct containing information about the device. + **/ + vk::PhysicalDeviceProperties getDeviceProperties() const; + private: // -------------- OPTIONALLY OWNED RESOURCES std::shared_ptr mInstance = nullptr; diff --git a/test/TestManager.cpp b/test/TestManager.cpp index f759208a..6d6756d4 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -62,3 +62,10 @@ TEST(TestManager, TestMultipleSequences) EXPECT_EQ(tensorOutput->vector(), std::vector({ 0, 4, 12 })); } + +TEST(TestManager, TestDeviceProperties) +{ + kp::Manager mgr; + const auto properties = mgr.getDeviceProperties(); + EXPECT_GT(properties.deviceName.size(), 0); +}