Device Properties

This commit is contained in:
alexander-g 2021-03-12 08:32:51 +01:00
parent 50366c6658
commit f52efcef0f
5 changed files with 198 additions and 107 deletions

View file

@ -217,7 +217,26 @@ 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::getDeviceProperties, "Return a struct containing information about the device");
py::class_<kp::DeviceProperties>(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";
});
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;