-
Notifications
You must be signed in to change notification settings - Fork 158
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
Device Properties #184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have actually been thinking of convert a lot of the Manager functions related to vulkan resource creation into static functions, mainly as the creation of the Device, etc could be quite useful for the unit tests to test Tensors / other components in isolation without having to create a manager, so I think this is an interesting approach.
I added a couple of comments, the main one is to avoid creating structs and instead returning the vk:: objects instead in the C++, and returning a python Dict in the bindings instead of creating a new class binding
src/Manager.cpp
Outdated
DeviceProperties Manager::getDeviceProperties() const | ||
{ | ||
const vk::PhysicalDeviceProperties properties = this->mPhysicalDevice->getProperties(); | ||
const DeviceProperties output{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a new struct when we can just return a vk::PhysicalDeviceProperties? The PhysicalDeviceLimits object itself has a very long list of limits so it's a slippery slope exposing only a subset of these, as later on more will be required to the extent it's better to just expose the object itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it because creating a PyBind binding to the object is harder? Perhaps the subset of properties exposed can just be on the Python binding as opposed to the underlying component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it because creating a PyBind binding to the object is harder? Perhaps the subset of properties exposed can just be on the Python binding as opposed to the underlying component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was that most of the properties are not relevant for Kompute. Moreover, some of the properties could be post-processed for easier access by the user, e.g. amount of device memory: Using the raw vk::
struct one would need to find the correct memory type first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand, what would be the requirements to find the correct memory type? I can see that you read for example properties.limits.maxComputeWorkGroupCount
, is the memory type whether it's not of type Compute? I agree that there is a large number of options on the device properties, I'm just thinking that having a struct in between may result in more abstractions to maintain and potentially people requesting more to be exposed - what about the suggestion on having it in the python binding as a python dict? It could be buitl as a single-level python dict, where the key could just be limits_max_compute_work_group_count, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not yet implemented. I mean that the the user would need to iterate over the memory types as in Tensor::allocateBindMemory
to find the correct memory heap that is used for the buffers.
uint32_t size() { | ||
return this->mSize; | ||
} | ||
uint32_t size() { return this->mSize; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run make format
? or why is the kompute.hpp modifying the format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the version of your CLIs / dependencies related to the creation of the single header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make format
uses hardcoded paths. I've manually run clang-format
as in the Makefile, didn't help.
Versions:
clang-format 10.0
quom 1.2.0
python/src/main.cpp
Outdated
@@ -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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - thanks for the pr.
I have actually been thinking of converting a lot of the Manager functions related to vulkan resource creation into static functions, mainly as the creation of the Device, etc could be quite useful for the unit tests to test Tensors / other components in isolation without having to create a manager, so I think this is an interesting approach.
I added a couple of comments, the main one is to avoid creating structs and instead returning the vk:: objects instead in the C++, and returning a python Dict in the bindings instead of creating a new class binding
Modified to return raw mgr.get_device_properties()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alexander-g, python dictionaries look great in C++ with the pybind literals
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], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
Added
Manager::getDeviceProperties()
which exposes some device parameters that are relevant for Kompute(Single Include header changed more than I want, not sure why.)