Added list_devices function and separated new utils function

This commit is contained in:
Alejandro Saucedo 2021-03-20 08:49:51 +00:00
parent d23ea95e64
commit a6457ee1ec
3 changed files with 49 additions and 14 deletions

26
python/src/utils.hpp Normal file
View file

@ -0,0 +1,26 @@
#include <kompute/Kompute.hpp>
#include <pybind11/pybind11.h>
using namespace pybind11::literals; // for the `_a` literal
namespace kp {
namespace py {
static pybind11::dict vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) {
pybind11::dict pyDict(
"device_name"_a = std::string(properties.deviceName.data()),
"max_work_group_count"_a = pybind11::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 = pybind11::make_tuple(properties.limits.maxComputeWorkGroupSize[0],
properties.limits.maxComputeWorkGroupSize[1],
properties.limits.maxComputeWorkGroupSize[2]),
"timestamps_supported"_a = (bool)properties.limits.timestampComputeAndGraphics
);
return pyDict;
}
}
}