21 #ifndef ESI_ACCELERATOR_H
22 #define ESI_ACCELERATOR_H
38 class AcceleratorServiceThread;
65 std::vector<std::unique_ptr<Instance>>
children,
66 std::vector<services::Service *>
services,
67 std::vector<std::unique_ptr<BundlePort>> &
ports)
97 virtual std::map<std::string, ChannelPort &>
111 template <
typename ServiceClass>
115 return dynamic_cast<ServiceClass *
>(
116 getService(
typeid(ServiceClass),
id, implName, details, clients));
121 std::string implName = {},
127 Accelerator *
takeOwnership(std::unique_ptr<Accelerator> accel);
134 std::string implName,
159 const std::string &backend,
160 const std::string &connection);
170 template <
typename TAccelerator>
177 #define REGISTER_ACCELERATOR(Name, TAccelerator) \
178 static ::esi::registry::internal::RegisterAccelerator<TAccelerator> \
179 __register_accel____LINE__(Name)
194 addListener(std::initializer_list<ReadChannelPort *> listenPorts,
Abstract class representing a connection to an accelerator.
Context & getCtxt() const
virtual void disconnect()
Disconnect from the accelerator cleanly.
Logger & getLogger() const
services::Service Service
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).
ServiceClass * getService(AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Get a typed reference to a particular service type.
std::map< std::string, services::Service * > ServiceTable
Context & ctxt
ESI accelerator context.
std::map< ServiceCacheKey, std::unique_ptr< Service > > serviceCache
std::tuple< const std::type_info *, AppIDPath > ServiceCacheKey
Cache services via a unique_ptr so they get free'd automatically when Accelerator objects get deconst...
std::unique_ptr< AcceleratorServiceThread > serviceThread
virtual Service * createService(Service::Type service, AppIDPath idPath, std::string implName, const ServiceImplDetails &details, const HWClientDetails &clients)=0
Called by getServiceImpl exclusively.
std::vector< std::unique_ptr< Accelerator > > ownedAccelerators
List of accelerator objects owned by this connection.
virtual ~AcceleratorConnection()
AcceleratorServiceThread * getServiceThread()
Return a pointer to the accelerator 'service' thread (or threads).
AcceleratorConnection(Context &ctxt)
Accelerator * takeOwnership(std::unique_ptr< Accelerator > accel)
Assume ownership of an accelerator object.
Background thread which services various requests.
void stop()
Instruct the service thread to stop running.
void addListener(std::initializer_list< ReadChannelPort * > listenPorts, std::function< void(ReadChannelPort *, MessageData)> callback)
When there's data on any of the listenPorts, call the callback.
AcceleratorServiceThread()
std::unique_ptr< Impl > impl
void addPoll(HWModule &module)
Poll this module.
~AcceleratorServiceThread()
Top level accelerator class.
Accelerator(std::optional< ModuleInfo > info, std::vector< std::unique_ptr< Instance >> children, std::vector< services::Service * > services, std::vector< std::unique_ptr< BundlePort >> &ports)
Accelerator(const Accelerator &)=delete
Bundles represent a collection of channels.
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Represents either the top level or an instance of a hardware module.
const std::optional< ModuleInfo > info
const std::vector< std::unique_ptr< BundlePort > > ports
const std::vector< std::unique_ptr< Instance > > children
const std::vector< services::Service * > services
A logical chunk of data representing serialized data.
A ChannelPort which reads data from the accelerator.
Parent class of all APIs modeled as 'services'.
const std::type_info & Type
void registerBackend(const std::string &name, BackendCreate create)
std::function< std::unique_ptr< AcceleratorConnection >(Context &, std::string)> BackendCreate
Backends can register themselves to be connected via a connection string.
std::unique_ptr< AcceleratorConnection > connect(Context &ctxt, const std::string &backend, const std::string &connection)
constexpr uint64_t MagicNumber
std::map< std::string, std::any > ServiceImplDetails
constexpr uint64_t MagicNumberHi
constexpr uint32_t ExpectedVersionNumber
constexpr uint32_t MetadataOffset
constexpr uint64_t MagicNumberLo
std::vector< HWClientDetail > HWClientDetails
RegisterAccelerator(const char *name)