diff --git a/python/src/main.cpp b/python/src/main.cpp index 33f9d02ae..acf4308aa 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; @@ -218,25 +220,23 @@ PYBIND11_MODULE(kp, m) { py::arg("workgroup") = kp::Workgroup(), py::arg("spec_consts") = kp::Constants(), py::arg("push_consts") = kp::Constants()) - .def("get_device_properties", &kp::Manager::getDeviceProperties, "Return a struct containing information about the device"); - - py::class_(m, "DeviceProperties") - .def_readonly("device_name", &kp::DeviceProperties::deviceName) - .def_readonly("max_work_group_count", &kp::DeviceProperties::maxWorkGroupCount) - .def_readonly("max_work_group_invocations", &kp::DeviceProperties::maxWorkGroupInvocations) - .def_readonly("max_work_group_size", &kp::DeviceProperties::maxWorkGroupSize) - .def_readonly("timestamps_supported", &kp::DeviceProperties::timestampsSupported) - .def("__repr__", [](const kp::DeviceProperties &p) { - return "Device Name: " + p.deviceName + "\n" - +"Maximum Workgroup Count: " + std::to_string(p.maxWorkGroupCount[0]) + ", " - + std::to_string(p.maxWorkGroupCount[1]) + ", " - + std::to_string(p.maxWorkGroupCount[2]) + "\n" - +"Maximum Workgroup Invocations: " + std::to_string(p.maxWorkGroupInvocations) + "\n" - +"Maximum Workgroup Size: " + std::to_string(p.maxWorkGroupSize[0]) + ", " - + std::to_string(p.maxWorkGroupSize[1]) + ", " - + std::to_string(p.maxWorkGroupSize[2]) + "\n" - +"Timestamps Supported: " + (p.timestampsSupported? "True" : "False") + "\n"; - }); + .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 474faee14..44689d868 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1949,21 +1949,6 @@ class Sequence : public std::enable_shared_from_this namespace kp { -struct DeviceProperties -{ - //Name of the device - const std::string deviceName; - //Maximum number of workgroups that can be dispatched per shader - const std::array maxWorkGroupCount; - //Maximum number of shader invocations per local workgroup - //i.e. the product of maxWorkGroupSize must not exceed this value - const uint32_t maxWorkGroupInvocations; - //Maximum number of shader invocations per local workgroup - const std::array maxWorkGroupSize; - //Whether timestamping is supported by this device or not - const bool timestampsSupported; -}; - /** Base orchestrator which creates and manages device and child components */ @@ -2109,7 +2094,7 @@ class Manager /** * Return a struct containing information about the device. **/ - DeviceProperties getDeviceProperties() const; + vk::PhysicalDeviceProperties getDeviceProperties() const; private: // -------------- OPTIONALLY OWNED RESOURCES diff --git a/src/Manager.cpp b/src/Manager.cpp index 996548db3..807d4832f 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -447,17 +447,10 @@ Manager::sequence(uint32_t queueIndex, uint32_t totalTimestamps) return sq; } -DeviceProperties Manager::getDeviceProperties() const +vk::PhysicalDeviceProperties +Manager::getDeviceProperties() const { - const vk::PhysicalDeviceProperties properties = this->mPhysicalDevice->getProperties(); - const DeviceProperties output{ - std::string(properties.deviceName.data()), - properties.limits.maxComputeWorkGroupCount, - properties.limits.maxComputeWorkGroupInvocations, - properties.limits.maxComputeWorkGroupSize, - properties.limits.timestampComputeAndGraphics, - }; - return output; + return this->mPhysicalDevice->getProperties(); } } diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index b168e3727..e9e284155 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -11,23 +11,6 @@ namespace kp { - -struct DeviceProperties -{ - //Name of the device - const std::string deviceName; - //Maximum number of workgroups that can be dispatched per shader - const std::array maxWorkGroupCount; - //Maximum number of shader invocations per local workgroup - //i.e. the product of maxWorkGroupSize must not exceed this value - const uint32_t maxWorkGroupInvocations; - //Maximum number of shader invocations per local workgroup - const std::array maxWorkGroupSize; - //Whether timestamping is supported by this device or not - const bool timestampsSupported; -}; - - /** Base orchestrator which creates and manages device and child components */ @@ -173,7 +156,7 @@ class Manager /** * Return a struct containing information about the device. **/ - DeviceProperties getDeviceProperties() const; + vk::PhysicalDeviceProperties getDeviceProperties() const; private: // -------------- OPTIONALLY OWNED RESOURCES @@ -207,5 +190,4 @@ class Manager const std::vector& desiredExtensions = {}); }; - } // End namespace kp diff --git a/test/TestManager.cpp b/test/TestManager.cpp index 608bb8dfc..6d6756d41 100644 --- a/test/TestManager.cpp +++ b/test/TestManager.cpp @@ -67,6 +67,5 @@ TEST(TestManager, TestDeviceProperties) { kp::Manager mgr; const auto properties = mgr.getDeviceProperties(); - EXPECT_GT(properties.deviceName.size(), 0); }