20 #include "experimental/xrt_bo.h"
21 #include "experimental/xrt_device.h"
22 #include "experimental/xrt_ip.h"
23 #include "experimental/xrt_xclbin.h"
37 std::unique_ptr<AcceleratorConnection>
40 std::string device_id;
42 size_t colon = connectionString.find(
':');
43 if (colon == std::string::npos) {
44 xclbin = connectionString;
46 xclbin = connectionString.substr(0, colon);
47 device_id = connectionString.substr(colon + 1);
50 return make_unique<XrtAccelerator>(
ctxt, xclbin, device_id);
54 constexpr
static char kernel[] =
"esi_kernel";
56 Impl(std::string xclbin, std::string device_id) {
57 if (device_id.empty())
58 device = ::xrt::device(0);
60 device = ::xrt::device(device_id);
62 auto uuid = device.load_xclbin(xclbin);
63 ip = ::xrt::ip(device, uuid, kernel);
68 throw std::runtime_error(
"XRT does not support channel communication yet");
76 XrtAccelerator::XrtAccelerator(
Context &
ctxt, std::string xclbin,
77 std::string device_id)
79 impl = make_unique<Impl>(xclbin, device_id);
84 class XrtMMIO :
public MMIO {
86 XrtMMIO(::xrt::ip &ip) : ip(ip) {}
88 uint64_t read(uint32_t addr)
const override {
89 auto lo =
static_cast<uint64_t
>(ip.read_register(addr));
90 auto hi =
static_cast<uint64_t
>(ip.read_register(addr + 0x4));
91 return (hi << 32) | lo;
93 void write(uint32_t addr, uint64_t data)
override {
94 ip.write_register(addr, data);
95 ip.write_register(addr + 0x4, data >> 32);
105 return impl->requestChannelsFor(idPath, bundleType);
109 std::string implName,
112 if (svcType ==
typeid(
MMIO))
113 return new XrtMMIO(
impl->ip);
114 else if (svcType ==
typeid(
SysInfo))
REGISTER_ACCELERATOR("xrt", backends::xrt::XrtAccelerator)
Abstract class representing a connection to an accelerator.
virtual void disconnect()
Disconnect from the accelerator cleanly.
std::map< std::string, services::Service * > ServiceTable
Bundles represent a collection of channels.
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Connect to an ESI simulation.
std::map< std::string, ChannelPort & > requestChannelsFor(AppIDPath, const BundleType *, const ServiceTable &) override
Request the host side channel ports for a particular instance (identified by the AppID path).
std::unique_ptr< Impl > impl
virtual Service * createService(Service::Type service, AppIDPath path, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients) override
Called by getServiceImpl exclusively.
Implement the SysInfo API for a standard MMIO protocol.
Parent class of all APIs modeled as 'services'.
const std::type_info & Type
Information about the Accelerator system.
def connect(destination, source)
std::map< std::string, std::any > ServiceImplDetails
std::vector< HWClientDetail > HWClientDetails
std::map< std::string, ChannelPort & > requestChannelsFor(AppIDPath, const BundleType *)
Impl(std::string xclbin, std::string device_id)