mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-03-23 08:37:46 +00:00
Rename nanobind-exposed C++ types to Cpp* Replace MSCCLPP_EXECUTION_PLAN_DIR / MSCCLPP_NATIVE_CACHE_DIR with MSCCLPP_CACHE_DIR across C++ and Python.
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include <nanobind/nanobind.h>
|
|
|
|
#include <mscclpp/fifo.hpp>
|
|
|
|
namespace nb = nanobind;
|
|
using namespace mscclpp;
|
|
|
|
void register_fifo(nb::module_& m) {
|
|
nb::class_<ProxyTrigger>(m, "CppProxyTrigger")
|
|
.def_prop_rw(
|
|
"fst", [](const ProxyTrigger& self) { return self.fst; },
|
|
[](ProxyTrigger& self, uint64_t v) { self.fst = v; })
|
|
.def_prop_rw(
|
|
"snd", [](const ProxyTrigger& self) { return self.snd; },
|
|
[](ProxyTrigger& self, uint64_t v) { self.snd = v; });
|
|
|
|
nb::class_<FifoDeviceHandle>(m, "CppFifoDeviceHandle")
|
|
.def_rw("triggers", &FifoDeviceHandle::triggers)
|
|
.def_rw("tail", &FifoDeviceHandle::tail)
|
|
.def_rw("head", &FifoDeviceHandle::head)
|
|
.def_rw("size", &FifoDeviceHandle::size)
|
|
.def_prop_ro("raw", [](const FifoDeviceHandle& self) -> nb::bytes {
|
|
return nb::bytes(reinterpret_cast<const char*>(&self), sizeof(self));
|
|
});
|
|
|
|
nb::class_<Fifo>(m, "CppFifo")
|
|
.def(nb::init<int>(), nb::arg("size") = DEFAULT_FIFO_SIZE)
|
|
.def("poll", &Fifo::poll)
|
|
.def("pop", &Fifo::pop)
|
|
.def("size", &Fifo::size)
|
|
.def("device_handle", &Fifo::deviceHandle);
|
|
}
|