Fixed building Python package

Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
Fabian Sauter 2022-07-26 12:36:46 +02:00
parent 00cc533f80
commit 4b7e3b13f8
8 changed files with 35 additions and 22 deletions

View file

@ -2,9 +2,8 @@
pybind11_add_module(kp src/main.cpp)
include_directories(
${PROJECT_SOURCE_DIR}/single_include/)
${PROJECT_SOURCE_DIR}/include/)
target_link_libraries(
kp PRIVATE
kompute::kompute)
kp PRIVATE
kompute::kompute)

View file

@ -2,6 +2,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <memory>
#include <kompute/Kompute.hpp>
#include "docstrings.hpp"
@ -53,7 +55,8 @@ PYBIND11_MODULE(kp, m)
// The logging modules are used in the Kompute.hpp file
py::module_ logging = py::module_::import("logging");
py::object kp_logger = logging.attr("getLogger")("kp");
kp_trace = kp_logger.attr("trace");
kp_trace = kp_logger.attr(
"debug"); // Same as for debug since python has no trace logging level
kp_debug = kp_logger.attr("debug");
kp_info = kp_logger.attr("info");
kp_warning = kp_logger.attr("warning");

View file

@ -1,24 +1,30 @@
#include <kompute/Kompute.hpp>
#include <pybind11/pybind11.h>
#include <vulkan/vulkan.hpp>
using namespace pybind11::literals; // for the `_a` literal
namespace kp {
namespace py {
static pybind11::dict vkPropertiesToDict(const vk::PhysicalDeviceProperties& properties) {
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
);
"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;
}