CIRCT 21.0.0git
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
esi::AcceleratorConnection Class Referenceabstract

Abstract class representing a connection to an accelerator. More...

#include <Accelerator.h>

Inheritance diagram for esi::AcceleratorConnection:
Inheritance graph
[legend]
Collaboration diagram for esi::AcceleratorConnection:
Collaboration graph
[legend]

Public Types

using ServiceTable = std::map< std::string, services::Service * >
 
using Service = services::Service
 

Public Member Functions

 AcceleratorConnection (Context &ctxt)
 
virtual ~AcceleratorConnection ()
 
ContextgetCtxt () const
 
LoggergetLogger () const
 
virtual void disconnect ()
 Disconnect from the accelerator cleanly.
 
AcceleratorServiceThreadgetServiceThread ()
 Return a pointer to the accelerator 'service' thread (or threads).
 
template<typename ServiceClass >
ServiceClass * getService (AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
 Get a typed reference to a particular service type.
 
virtual ServicegetService (Service::Type service, AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
 Calls createService and caches the result.
 
AcceleratortakeOwnership (std::unique_ptr< Accelerator > accel)
 Assume ownership of an accelerator object.
 
virtual void createEngine (const std::string &engineTypeName, AppIDPath idPath, const ServiceImplDetails &details, const HWClientDetails &clients)
 Create a new engine for channel communication with the accelerator.
 
virtual const BundleEngineMapgetEngineMapFor (AppIDPath id)
 

Protected Member Functions

void registerEngine (AppIDPath idPath, std::unique_ptr< Engine > engine, const HWClientDetails &clients)
 If createEngine is overridden, this method should be called to register the engine and all of the channels it services.
 
virtual ServicecreateService (Service::Type service, AppIDPath idPath, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients)=0
 Called by getServiceImpl exclusively.
 

Protected Attributes

std::map< AppIDPath, std::unique_ptr< Engine > > ownedEngines
 Collection of owned engines.
 
std::map< AppIDPath, BundleEngineMapclientEngines
 Mapping of clients to their servicing engines.
 

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.
 

Private Attributes

Contextctxt
 ESI accelerator context.
 
std::map< ServiceCacheKey, std::unique_ptr< Service > > serviceCache
 
std::unique_ptr< AcceleratorServiceThreadserviceThread
 
std::vector< std::unique_ptr< Accelerator > > ownedAccelerators
 List of accelerator objects owned by this connection.
 

Detailed Description

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 79 of file Accelerator.h.

Member Typedef Documentation

◆ Service

Definition at line 103 of file Accelerator.h.

◆ ServiceCacheKey

using esi::AcceleratorConnection::ServiceCacheKey = std::tuple<const std::type_info *, AppIDPath>
private

Cache services via a unique_ptr so they get free'd automatically when Accelerator objects get deconstructed.

Definition at line 161 of file Accelerator.h.

◆ ServiceTable

Definition at line 94 of file Accelerator.h.

Constructor & Destructor Documentation

◆ AcceleratorConnection()

esi::AcceleratorConnection::AcceleratorConnection ( Context ctxt)

Definition at line 36 of file Accelerator.cpp.

◆ ~AcceleratorConnection()

esi::AcceleratorConnection::~AcceleratorConnection ( )
virtual

Definition at line 38 of file Accelerator.cpp.

References disconnect().

Member Function Documentation

◆ createEngine()

void esi::AcceleratorConnection::createEngine ( const std::string &  engineTypeName,
AppIDPath  idPath,
const ServiceImplDetails details,
const HWClientDetails clients 
)
virtual

Create a new engine for channel communication with the accelerator.

The default is to call the global createEngine to get an engine which has registered itself. Individual accelerator connection backends can override this to customize behavior.

Reimplemented in esi::backends::cosim::CosimAccelerator, and esi::backends::trace::TraceAccelerator.

Definition at line 45 of file Accelerator.cpp.

References esi::registry::createEngine(), and registerEngine().

◆ createService()

virtual Service * esi::AcceleratorConnection::createService ( Service::Type  service,
AppIDPath  idPath,
std::string  implName,
const ServiceImplDetails details,
const HWClientDetails clients 
)
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::trace::TraceAccelerator, esi::backends::cosim::CosimAccelerator, and esi::backends::xrt::XrtAccelerator.

Referenced by getService().

◆ disconnect()

void AcceleratorConnection::disconnect ( )
virtual

◆ getCtxt()

Context & esi::AcceleratorConnection::getCtxt ( ) const
inline

Definition at line 83 of file Accelerator.h.

References ctxt.

Referenced by esi::backends::cosim::CosimAccelerator::createService(), printHier(), and printInfo().

◆ getEngineMapFor()

virtual const BundleEngineMap & esi::AcceleratorConnection::getEngineMapFor ( AppIDPath  id)
inlinevirtual

◆ getLogger()

Logger & esi::AcceleratorConnection::getLogger ( ) const
inline

Definition at line 84 of file Accelerator.h.

References ctxt, and esi::Context::getLogger().

Referenced by registerCallbacks().

◆ getService() [1/2]

template<typename ServiceClass >
ServiceClass * esi::AcceleratorConnection::getService ( AppIDPath  id = {},
std::string  implName = {},
ServiceImplDetails  details = {},
HWClientDetails  clients = {} 
)
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 108 of file Accelerator.h.

Referenced by dmaTest(), esi::services::Service::getChildService(), printHier(), printInfo(), and PYBIND11_MODULE().

◆ getService() [2/2]

services::Service * esi::AcceleratorConnection::getService ( Service::Type  service,
AppIDPath  id = {},
std::string  implName = {},
ServiceImplDetails  details = {},
HWClientDetails  clients = {} 
)
virtual

Calls createService and caches the result.

Subclasses can override if they want to use their own caching mechanism.

Definition at line 75 of file Accelerator.cpp.

References esi::services::ServiceRegistry::createService(), createService(), and serviceCache.

◆ getServiceThread()

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().

◆ registerEngine()

void esi::AcceleratorConnection::registerEngine ( AppIDPath  idPath,
std::unique_ptr< Engine engine,
const HWClientDetails clients 
)
protected

If createEngine is overridden, this method should be called to register the engine and all of the channels it services.

Definition at line 54 of file Accelerator.cpp.

References assert(), clientEngines, and ownedEngines.

Referenced by createEngine(), esi::backends::cosim::CosimAccelerator::createEngine(), and esi::backends::trace::TraceAccelerator::createEngine().

◆ takeOwnership()

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 94 of file Accelerator.cpp.

References ownedAccelerators.

Member Data Documentation

◆ clientEngines

std::map<AppIDPath, BundleEngineMap> esi::AcceleratorConnection::clientEngines
protected

Mapping of clients to their servicing engines.

Definition at line 153 of file Accelerator.h.

Referenced by getEngineMapFor(), and registerEngine().

◆ ctxt

Context& esi::AcceleratorConnection::ctxt
private

◆ ownedAccelerators

std::vector<std::unique_ptr<Accelerator> > esi::AcceleratorConnection::ownedAccelerators
private

List of accelerator objects owned by this connection.

These are destroyed when the connection dies or is shutdown.

Definition at line 168 of file Accelerator.h.

Referenced by takeOwnership().

◆ ownedEngines

std::map<AppIDPath, std::unique_ptr<Engine> > esi::AcceleratorConnection::ownedEngines
protected

Collection of owned engines.

Definition at line 151 of file Accelerator.h.

Referenced by registerEngine().

◆ serviceCache

std::map<ServiceCacheKey, std::unique_ptr<Service> > esi::AcceleratorConnection::serviceCache
private

Definition at line 162 of file Accelerator.h.

Referenced by getService().

◆ serviceThread

std::unique_ptr<AcceleratorServiceThread> esi::AcceleratorConnection::serviceThread
private

Definition at line 164 of file Accelerator.h.

Referenced by disconnect(), and getServiceThread().


The documentation for this class was generated from the following files: