Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device Properties #184

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion python/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to just return the device properties as a Dict instead of a new class? Conscious if we start exposing Vk classes it could lead into more vk classes being requested


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;
Expand Down
Loading