CIRCT
20.0.0git
|
Abstract class representing a connection to an accelerator. More...
#include <Accelerator.h>
Public Types | |
using | ServiceTable = std::map< std::string, services::Service * > |
using | Service = services::Service |
Public Member Functions | |
AcceleratorConnection (Context &ctxt) | |
virtual | ~AcceleratorConnection () |
Context & | getCtxt () const |
Logger & | getLogger () const |
virtual void | disconnect () |
Disconnect from the accelerator cleanly. More... | |
virtual std::map< std::string, ChannelPort & > | requestChannelsFor (AppIDPath, const BundleType *, const ServiceTable &)=0 |
Request the host side channel ports for a particular instance (identified by the AppID path). More... | |
AcceleratorServiceThread * | getServiceThread () |
Return a pointer to the accelerator 'service' thread (or threads). More... | |
template<typename ServiceClass > | |
ServiceClass * | getService (AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={}) |
Get a typed reference to a particular service type. More... | |
virtual Service * | getService (Service::Type service, AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={}) |
Calls createService and caches the result. More... | |
Accelerator * | takeOwnership (std::unique_ptr< Accelerator > accel) |
Assume ownership of an accelerator object. More... | |
Protected Member Functions | |
virtual Service * | createService (Service::Type service, AppIDPath idPath, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients)=0 |
Called by getServiceImpl exclusively. More... | |
Private Types | |
using | ServiceCacheKey = std::tuple< const std::type_info *, AppIDPath > |
Cache services via a unique_ptr so they get free'd automatically when Accelerator objects get deconstructed. More... | |
Private Attributes | |
Context & | ctxt |
ESI accelerator context. More... | |
std::map< ServiceCacheKey, std::unique_ptr< Service > > | serviceCache |
std::unique_ptr< AcceleratorServiceThread > | serviceThread |
std::vector< std::unique_ptr< Accelerator > > | ownedAccelerators |
List of accelerator objects owned by this connection. More... | |
Abstract class representing a connection to an accelerator.
Actual connections (e.g. to a co-simulation or actual device) are implemented by subclasses. No methods in here are thread safe.
Definition at line 78 of file Accelerator.h.
Definition at line 107 of file Accelerator.h.
|
private |
Cache services via a unique_ptr so they get free'd automatically when Accelerator objects get deconstructed.
Definition at line 144 of file Accelerator.h.
using esi::AcceleratorConnection::ServiceTable = std::map<std::string, services::Service *> |
Definition at line 93 of file Accelerator.h.
esi::AcceleratorConnection::AcceleratorConnection | ( | Context & | ctxt | ) |
Definition at line 36 of file Accelerator.cpp.
|
virtual |
Definition at line 38 of file Accelerator.cpp.
References disconnect().
|
protectedpure virtual |
Called by getServiceImpl
exclusively.
It wraps the pointer returned by this in a unique_ptr and caches it. Separate this from the wrapping/caching since wrapping/caching is an implementation detail.
Implemented in esi::backends::xrt::XrtAccelerator, esi::backends::cosim::CosimAccelerator, and esi::backends::trace::TraceAccelerator.
Referenced by getService().
|
virtual |
Disconnect from the accelerator cleanly.
Definition at line 377 of file Accelerator.cpp.
References serviceThread.
Referenced by ~AcceleratorConnection(), esi::backends::cosim::CosimAccelerator::~CosimAccelerator(), esi::backends::trace::TraceAccelerator::~TraceAccelerator(), and esi::backends::xrt::XrtAccelerator::~XrtAccelerator().
|
inline |
Definition at line 82 of file Accelerator.h.
References ctxt.
Referenced by esi::backends::cosim::CosimAccelerator::createService(), esi::services::MMIO::getChildService(), printHier(), and printInfo().
|
inline |
Definition at line 83 of file Accelerator.h.
References ctxt, and esi::Context::getLogger().
Referenced by registerCallbacks().
|
inline |
Get a typed reference to a particular service type.
Caller does not take ownership of the returned pointer – the Accelerator object owns it. Pointer lifetime ends with the Accelerator lifetime.
Definition at line 112 of file Accelerator.h.
Referenced by dmaTest(), esi::services::Service::getChildService(), printHier(), printInfo(), and PYBIND11_MODULE().
|
virtual |
Calls createService
and caches the result.
Subclasses can override if they want to use their own caching mechanism.
Definition at line 46 of file Accelerator.cpp.
References createService(), and serviceCache.
AcceleratorServiceThread * esi::AcceleratorConnection::getServiceThread | ( | ) |
Return a pointer to the accelerator 'service' thread (or threads).
If the thread(s) are not running, they will be started when this method is called. std::thread
is used. If users don't want the runtime to spin up threads, don't call this method. AcceleratorServiceThread
is owned by AcceleratorConnection and governed by the lifetime of the this object.
Definition at line 40 of file Accelerator.cpp.
References serviceThread.
Referenced by PYBIND11_MODULE().
|
pure virtual |
Request the host side channel ports for a particular instance (identified by the AppID path).
For convenience, provide the bundle type.
Implemented in esi::backends::xrt::XrtAccelerator, esi::backends::trace::TraceAccelerator, and esi::backends::cosim::CosimAccelerator.
Accelerator * esi::AcceleratorConnection::takeOwnership | ( | std::unique_ptr< Accelerator > | accel | ) |
Assume ownership of an accelerator object.
Ties the lifetime of the accelerator to this connection. Returns a raw pointer to the object.
Definition at line 65 of file Accelerator.cpp.
References ownedAccelerators.
|
private |
ESI accelerator context.
Definition at line 140 of file Accelerator.h.
Referenced by getCtxt(), and getLogger().
|
private |
List of accelerator objects owned by this connection.
These are destroyed when the connection dies or is shutdown.
Definition at line 151 of file Accelerator.h.
Referenced by takeOwnership().
|
private |
Definition at line 145 of file Accelerator.h.
Referenced by getService().
|
private |
Definition at line 147 of file Accelerator.h.
Referenced by disconnect(), and getServiceThread().