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)
89 virtual std::map<std::string, ChannelPort &>
98 template <
typename ServiceClass>
102 return dynamic_cast<ServiceClass *
>(
103 getService(
typeid(ServiceClass),
id, implName, details, clients));
108 std::string implName = {},
117 std::string implName,
137 std::unique_ptr<AcceleratorConnection>
148 template <
typename TAccelerator>
155 #define REGISTER_ACCELERATOR(Name, TAccelerator) \
156 static ::esi::registry::internal::RegisterAccelerator<TAccelerator> \
157 __register_accel____LINE__(Name)
172 addListener(std::initializer_list<ReadChannelPort *> listenPorts,
Abstract class representing a connection to an accelerator.
Context & getCtxt() const
void disconnect()
Disconnect from the accelerator cleanly.
services::Service Service
ServiceClass * getService(AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Get a typed reference to a particular service type.
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.
virtual std::map< std::string, ChannelPort & > requestChannelsFor(AppIDPath, const BundleType *)=0
Request the host side channel ports for a particular instance (identified by the AppID path).
AcceleratorConnection(Context &ctxt)
virtual ~AcceleratorConnection()=default
AcceleratorServiceThread * getServiceThread()
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
~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(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, std::string backend, 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)