CIRCT 24.0.0git
Loading...
Searching...
No Matches
Services.h
Go to the documentation of this file.
1//===- StdServices.h - ESI standard services C++ API ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// The APIs in this backend are all optionally implemented. The lower level
10// ones, however, are strongly recommended. 'Services' here refers to ESI
11// services. These are standard APIs into the standard ESI services.
12//
13// DO NOT EDIT!
14// This file is distributed as part of an ESI package. The source for this file
15// should always be modified within CIRCT.
16//
17//===----------------------------------------------------------------------===//
18
19// NOLINTNEXTLINE(llvm-header-guard)
20#ifndef ESI_RUNTIME_SERVICES_H
21#define ESI_RUNTIME_SERVICES_H
22
23#include "esi/Common.h"
24#include "esi/Context.h"
25#include "esi/Ports.h"
26
27#include <cstdint>
28#include <list>
29
30namespace esi {
32class Engine;
33namespace services {
34class Service;
35}
36
37// While building the design, keep around a std::map of active services indexed
38// by the service name. When a new service is encountered during descent, add it
39// to the table (perhaps overwriting one). Modifications to the table only apply
40// to the current branch, so copy this and update it at each level of the tree.
41using ServiceTable = std::map<std::string, services::Service *>;
42
43namespace services {
44
45/// Add a custom interface to a service client at a particular point in the
46/// design hierarchy.
47class ServicePort : public BundlePort {
48public:
50 virtual ~ServicePort() = default;
51 // Get a description of the service port.
52 virtual std::optional<std::string> toString(bool oneLine = false) const {
53 return std::nullopt;
54 }
55};
56
57/// Parent class of all APIs modeled as 'services'. May or may not map to a
58/// hardware side 'service'.
59class Service {
60public:
61 using Type = const std::type_info &;
63 virtual ~Service() = default;
64
65 virtual std::string getServiceSymbol() const = 0;
66
67 /// Create a "child" service of this service. Does not have to be the same
68 /// service type, but typically is. Used when a service already exists in the
69 /// active services table, but a new one wants to replace it. Useful for cases
70 /// where the child service needs to use the parent service. Defaults to
71 /// calling the `getService` method on `AcceleratorConnection` to get the
72 /// global service, implying that the child service does not need to use the
73 /// service it is replacing.
74 virtual Service *getChildService(Service::Type service, AppIDPath id = {},
75 std::string implName = {},
76 ServiceImplDetails details = {},
77 HWClientDetails clients = {});
78
79 /// Get specialized port for this service to attach to the given appid path.
80 /// Null returns mean nothing to attach.
81 virtual BundlePort *getPort(AppIDPath id, const BundleType *type) const {
82 return nullptr;
83 }
84
86
87protected:
89};
90
91/// A service for which there are no standard services registered. Requires
92/// ports be added to the design hierarchy instead of high level interfaces like
93/// the ones in StdServices.h.
94class CustomService : public Service {
95public:
97 const ServiceImplDetails &details,
98 const HWClientDetails &clients);
99 virtual ~CustomService() = default;
100
101 virtual std::string getServiceSymbol() const override {
102 return serviceSymbol;
103 }
104 virtual BundlePort *getPort(AppIDPath id,
105 const BundleType *type) const override;
106
107protected:
108 std::string serviceSymbol;
110};
111
112/// Information about the Accelerator system.
113class SysInfo : public Service {
114public:
115 using Service::Service;
116 virtual ~SysInfo() = default;
117
118 virtual std::string getServiceSymbol() const override;
119
120 /// Get the ESI version number to check version compatibility.
121 virtual uint32_t getEsiVersion() const = 0;
122
123 /// Get the current cycle count of the accelerator system.
124 virtual std::optional<uint64_t> getCycleCount() const { return std::nullopt; }
125 /// Get the "core" clock frequency of the accelerator system in Hz. Returns
126 /// nullopt if the accelerator does not provide this information.
127 virtual std::optional<uint64_t> getCoreClockFrequency() const {
128 return std::nullopt;
129 }
130
131 /// Return the JSON-formatted system manifest.
132 virtual std::string getJsonManifest() const;
133
134 /// Return the zlib compressed JSON system manifest.
135 virtual std::vector<uint8_t> getCompressedManifest() const = 0;
136};
137
138class MMIO : public Service {
139public:
140 static constexpr std::string_view StdName = "esi.service.std.mmio";
141
142 /// Describe a region (slice) of MMIO space.
144 uint32_t base;
145 uint32_t size;
146 };
147
148 MMIO(AcceleratorConnection &, const AppIDPath &idPath,
149 const HWClientDetails &clients);
150 virtual ~MMIO() = default;
151
152 /// Read a 64-bit value from the global MMIO space.
153 virtual uint64_t read(uint32_t addr) const = 0;
154 /// Write a 64-bit value to the global MMIO space.
155 virtual void write(uint32_t addr, uint64_t data) = 0;
156 /// Get the regions of MMIO space that this service manages. Otherwise known
157 /// as the base address table.
158 const std::map<AppIDPath, RegionDescriptor> &getRegions() const {
159 return regions;
160 }
161
162 /// If the service is a MMIO service, return a region of the MMIO space which
163 /// peers into ours.
164 virtual Service *getChildService(Service::Type service, AppIDPath id = {},
165 std::string implName = {},
166 ServiceImplDetails details = {},
167 HWClientDetails clients = {}) override;
168
169 virtual std::string getServiceSymbol() const override;
170
171 /// Get a MMIO region port for a particular region descriptor.
172 virtual BundlePort *getPort(AppIDPath id,
173 const BundleType *type) const override;
174
175protected:
176 // The current ESI hardware implementations only support one MMIO command at a
177 // time but don't enforce it. So we must grab a lock to enforce it on the
178 // software side.
179 mutable std::mutex mmioCmdLock;
180
181private:
182 /// MMIO base address table.
183 std::map<AppIDPath, RegionDescriptor> regions;
184
185public:
186 /// A "slice" of some parent MMIO space.
187 class MMIORegion : public ServicePort {
188 friend class MMIO;
190
191 public:
192 /// Get the offset (and size) of the region in the parent (usually global)
193 /// MMIO address space.
194 virtual RegionDescriptor getDescriptor() const { return desc; };
195 /// Read a 64-bit value from this region, not the global address space.
196 virtual uint64_t read(uint32_t addr) const;
197 /// Write a 64-bit value to this region, not the global address space.
198 virtual void write(uint32_t addr, uint64_t data);
199
200 virtual std::optional<std::string>
201 toString(bool oneLine = false) const override {
202 return "MMIO region " + toHex(desc.base) + " - " +
203 toHex(desc.base + desc.size);
204 }
205
206 private:
209 };
210};
211
212/// Implement the SysInfo API for a standard MMIO protocol.
213class MMIOSysInfo final : public SysInfo {
214public:
215 MMIOSysInfo(const MMIO *);
216
217 /// Get the ESI version number to check version compatibility.
218 uint32_t getEsiVersion() const override;
219
220 /// Get the current cycle count of the accelerator system's core clock.
221 std::optional<uint64_t> getCycleCount() const override;
222 /// Get the "core" clock frequency of the accelerator system in Hz. Returns
223 /// nullopt if the accelerator does not provide this information.
224 std::optional<uint64_t> getCoreClockFrequency() const override;
225
226 /// Return the zlib compressed JSON system manifest.
227 virtual std::vector<uint8_t> getCompressedManifest() const override;
228
229private:
230 const MMIO *mmio;
231};
232
233/// RAII memory region for host memory in accelerator-accessible address space.
234/// Automatically frees the memory when deconstructed. Allocated via
235/// HostMem::allocate() and also available as HostMem::HostMemRegion. Defined at
236/// namespace scope so that Common.h can forward declare it.
238 virtual ~HostMemRegion() = default;
239 /// Get a pointer to the host memory.
240 virtual void *getPtr() const = 0;
241 /// Sometimes the pointer the device sees is different from the pointer the
242 /// host sees. Call this function to get the device pointer.
243 virtual void *getDevicePtr() const { return getPtr(); }
244 operator void *() const { return getPtr(); }
245 virtual std::size_t getSize() const = 0;
246 /// Device address of the host range [ptr, ptr + size) if that range lies
247 /// entirely inside this region; std::nullopt otherwise (including when
248 /// size == 0 or the range would overflow the host or device address space).
249 std::optional<uint64_t> getDeviceAddress(const void *ptr,
250 std::size_t size) const;
251 /// Flush the memory region to ensure that the device sees the latest
252 /// contents. Because some platforms require it before DMA transactions, it
253 /// is recommended to call this before any DMA on all platforms. On
254 /// platforms which don't require it, it is a cheap no-op virtual method
255 /// call.
256 virtual void flush() {}
257};
258
259/// Interface for anything which can allocate HostMemRegions. Implemented by the
260/// HostMem service; also lets code which only needs to allocate regions (e.g.
261/// message types which keep their data in HostMem) accept other allocators,
262/// such as pools.
264public:
265 virtual ~HostMemAllocator() = default;
266
267 /// Options for allocating host memory.
268 struct Options {
269 bool writeable = false;
270 bool useLargePages = false;
271 };
272
273 /// Allocate a region of host memory in accelerator accessible address space.
274 /// Returns nullptr if the region cannot be allocated. Implementations MUST
275 /// return nullptr when `size` is 0.
276 virtual std::unique_ptr<HostMemRegion> allocate(std::size_t size,
277 Options opts) const = 0;
278};
279
280class HostMem : public Service, public HostMemAllocator {
281public:
282 static constexpr std::string_view StdName = "esi.service.std.hostmem";
283
284 using Service::Service;
285 virtual ~HostMem() = default;
286 virtual std::string getServiceSymbol() const override;
287
288 /// RAII memory region for host memory. See services::HostMemRegion.
290
291 /// In cases where necessary, enable host memory services.
292 virtual void start() {}
293
294 /// Allocate a region of host memory in accelerator accessible address space.
295 /// Returns nullptr on failure, and always when `size` is 0.
296 virtual std::unique_ptr<HostMemRegion>
297 allocate(std::size_t size, Options opts) const override = 0;
298
299 /// Try to make a region of host memory accessible to the accelerator. Returns
300 /// 'false' on failure. It is optional for an accelerator backend to implement
301 /// this, so client code needs to have a fallback for when this returns
302 /// 'false'. On success, it is the client's responsibility to ensure that the
303 /// memory eventually gets unmapped.
304 virtual bool mapMemory(void *ptr, std::size_t size, Options opts) const {
305 return false;
306 }
307 /// Unmap memory which was previously mapped with 'mapMemory'. Undefined
308 /// behavior when called with a pointer which was not previously mapped.
309 virtual void unmapMemory(void *ptr) const {}
310};
311
312/// Service for raw communication channels to/from the accelerator.
313class ChannelService : public Service {
314public:
316 ServiceImplDetails details, HWClientDetails clients);
317
318 virtual std::string getServiceSymbol() const override;
319 virtual BundlePort *getPort(AppIDPath id,
320 const BundleType *type) const override;
321
322 /// A port which reads data from the accelerator (to_host).
323 class ToHost : public ServicePort {
324 friend class ChannelService;
325 using ServicePort::ServicePort;
326
327 public:
328 static ToHost *get(AppID id, const BundleType *type,
330 void connect();
331 std::future<MessageData> read();
332
333 virtual std::optional<std::string>
334 toString(bool oneLine = false) const override {
335 const esi::Type *dataType =
336 dynamic_cast<const ChannelType *>(type->findChannel("data").first)
337 ->getInner();
338 return "channel to_host " + dataType->toString(oneLine);
339 }
340
341 private:
343 bool connected = false;
344 };
345
346 /// A port which writes data to the accelerator (from_host).
347 class FromHost : public ServicePort {
348 friend class ChannelService;
349 using ServicePort::ServicePort;
350
351 public:
352 static FromHost *get(AppID id, const BundleType *type,
354 void connect();
355 void write(const MessageData &data);
356
357 virtual std::optional<std::string>
358 toString(bool oneLine = false) const override {
359 const esi::Type *dataType =
360 dynamic_cast<const ChannelType *>(type->findChannel("data").first)
361 ->getInner();
362 return "channel from_host " + dataType->toString(oneLine);
363 }
364
365 private:
367 bool connected = false;
368 };
369
370private:
371 std::string symbol;
372};
373
374/// Service for calling functions.
375class FuncService : public Service {
376public:
378 HWClientDetails clients);
379
380 virtual std::string getServiceSymbol() const override;
381 virtual BundlePort *getPort(AppIDPath id,
382 const BundleType *type) const override;
383
384 /// A function call which gets attached to a service port.
385 class Function : public ServicePort {
386 friend class FuncService;
387 using ServicePort::ServicePort;
388
389 public:
392
393 void connect(const ChannelPort::ConnectOptions &options = {});
394 std::future<MessageData> call(const MessageData &arg);
395
396 const esi::Type *getArgType() const {
397 return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
398 ->getInner();
399 }
400
401 const esi::Type *getResultType() const {
402 return dynamic_cast<const ChannelType *>(
403 type->findChannel("result").first)
404 ->getInner();
405 }
406
407 virtual std::optional<std::string>
408 toString(bool oneLine = false) const override {
409 const esi::Type *argType = getArgType();
410 const esi::Type *resultType = getResultType();
411 return "function " + resultType->toString(oneLine) + "(" +
412 argType->toString(oneLine) + ")";
413 }
414
415 private:
416 std::mutex callMutex;
419 bool connected = false;
420 };
421
422private:
423 std::string symbol;
424};
425
426/// Service for servicing function calls from the accelerator.
427class CallService : public Service {
428public:
430 ServiceImplDetails details);
431
432 virtual std::string getServiceSymbol() const override;
433 virtual BundlePort *getPort(AppIDPath id,
434 const BundleType *type) const override;
435
436 /// A function call which gets attached to a service port.
437 class Callback : public ServicePort {
438 friend class CallService;
441
442 public:
446
447 /// Connect a callback to code which will be executed when the accelerator
448 /// invokes the callback. The 'quick' flag indicates that the callback is
449 /// sufficiently fast that it could be called in the same thread as the
450 /// port callback.
451 void connect(std::function<MessageData(const MessageData &)> callback,
452 bool quick = false,
453 const ChannelPort::ConnectOptions &options = {});
454
455 const esi::Type *getArgType() const {
456 return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
457 ->getInner();
458 }
459
460 const esi::Type *getResultType() const {
461 return dynamic_cast<const ChannelType *>(
462 type->findChannel("result").first)
463 ->getInner();
464 }
465
466 virtual std::optional<std::string>
467 toString(bool oneLine = false) const override {
468 const esi::Type *argType = getArgType();
469 const esi::Type *resultType = getResultType();
470 return "callback " + resultType->toString(oneLine) + "(" +
471 argType->toString(oneLine) + ")";
472 }
473
474 private:
478 };
479
480private:
481 std::string symbol;
482};
483
484/// Service for retrieving telemetry data from the accelerator.
485class TelemetryService : public Service {
486public:
487 static constexpr std::string_view StdName = "esi.service.std.telemetry";
488
490 ServiceImplDetails details, HWClientDetails clients);
491
492 virtual std::string getServiceSymbol() const override;
493 virtual BundlePort *getPort(AppIDPath id,
494 const BundleType *type) const override;
495 virtual Service *getChildService(Service::Type service, AppIDPath id = {},
496 std::string implName = {},
497 ServiceImplDetails details = {},
498 HWClientDetails clients = {}) override;
499 MMIO::MMIORegion *getMMIORegion() const;
500
501 /// A telemetry port which gets attached to a service port.
502 class Metric : public ServicePort {
503 friend class TelemetryService;
506 std::optional<uint64_t> offset);
507
508 public:
509 void connect();
510 std::future<MessageData> read();
511 uint64_t readInt();
512
513 virtual std::optional<std::string>
514 toString(bool oneLine = false) const override {
515 const esi::Type *dataType =
516 dynamic_cast<const ChannelType *>(type->findChannel("data").first)
517 ->getInner();
518 return "telemetry " + dataType->toString(oneLine);
519 }
520
521 private:
524 std::optional<uint64_t> offset;
525 };
526
527 std::map<AppIDPath, Metric *> getTelemetryPorts() {
528 std::map<AppIDPath, Metric *> ports;
529 getTelemetryPorts(ports);
530 return ports;
531 }
532 void getTelemetryPorts(std::map<AppIDPath, Metric *> &ports);
533
534private:
537 std::map<AppIDPath, uint64_t> portAddressAssignments;
538 mutable std::map<AppIDPath, Metric *> telemetryPorts;
539 std::list<TelemetryService *> children;
540};
541
542/// Registry of services which can be instantiated directly by the Accelerator
543/// class if the backend doesn't do anything special with a service.
545public:
546 /// Create a service instance from the given details. Returns nullptr if
547 /// 'svcType' isn't registered.
549 Service::Type svcType, AppIDPath id,
550 std::string implName,
551 ServiceImplDetails details,
552 HWClientDetails clients);
553
554 /// Resolve a service type from a string. If the string isn't recognized,
555 /// default to CustomService.
556 static Service::Type lookupServiceType(const std::string &);
557};
558
559} // namespace services
560} // namespace esi
561
562#endif // ESI_RUNTIME_SERVICES_H
Abstract class representing a connection to an accelerator.
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
Definition Ports.h:637
PortMap channels
Definition Ports.h:681
const BundleType * type
Definition Ports.h:680
BundlePort(AppID id, const BundleType *type, PortMap channels)
Construct a port.
Definition Ports.cpp:39
Bundles represent a collection of channels.
Definition Types.h:104
Channels are the basic communication primitives.
Definition Types.h:125
const Type * getInner() const
Definition Types.h:129
Engines implement the actual channel communication between the host and the accelerator.
Definition Engines.h:42
A concrete flat message backed by a single vector of bytes.
Definition Common.h:197
A ChannelPort which reads data from the accelerator.
Definition Ports.h:479
Root class of the ESI type system.
Definition Types.h:36
std::string toString(bool oneLine=false) const
Definition Types.cpp:120
A ChannelPort which sends data to the accelerator.
Definition Ports.h:308
static Callback * get(AcceleratorConnection &acc, AppID id, const BundleType *type, WriteChannelPort &result, ReadChannelPort &arg)
Definition Services.cpp:357
const esi::Type * getArgType() const
Definition Services.h:455
const esi::Type * getResultType() const
Definition Services.h:460
Callback(AcceleratorConnection &acc, AppID id, const BundleType *, PortMap channels)
Definition Services.cpp:353
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:467
AcceleratorConnection & acc
Definition Services.h:477
void connect(std::function< MessageData(const MessageData &)> callback, bool quick=false, const ChannelPort::ConnectOptions &options={})
Connect a callback to code which will be executed when the accelerator invokes the callback.
Definition Services.cpp:365
virtual std::string getServiceSymbol() const override
Definition Services.cpp:346
CallService(AcceleratorConnection &acc, AppIDPath id, ServiceImplDetails details)
Definition Services.cpp:338
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get specialized port for this service to attach to the given appid path.
Definition Services.cpp:348
A port which writes data to the accelerator (from_host).
Definition Services.h:347
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:358
static FromHost * get(AppID id, const BundleType *type, WriteChannelPort &dataPort)
Definition Services.cpp:269
void write(const MessageData &data)
Definition Services.cpp:285
A port which reads data from the accelerator (to_host).
Definition Services.h:323
std::future< MessageData > read()
Definition Services.cpp:261
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:334
static ToHost * get(AppID id, const BundleType *type, ReadChannelPort &dataPort)
Definition Services.cpp:244
virtual std::string getServiceSymbol() const override
Definition Services.cpp:233
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get specialized port for this service to attach to the given appid path.
Definition Services.cpp:235
ChannelService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:224
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get specialized port for this service to attach to the given appid path.
Definition Services.cpp:219
virtual ~CustomService()=default
virtual std::string getServiceSymbol() const override
Definition Services.h:101
CustomService(AppIDPath idPath, AcceleratorConnection &, const ServiceImplDetails &details, const HWClientDetails &clients)
Definition Services.cpp:208
A function call which gets attached to a service port.
Definition Services.h:385
const esi::Type * getArgType() const
Definition Services.h:396
const esi::Type * getResultType() const
Definition Services.h:401
std::future< MessageData > call(const MessageData &arg)
Definition Services.cpp:330
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:408
static Function * get(AppID id, BundleType *type, WriteChannelPort &arg, ReadChannelPort &result)
Definition Services.cpp:308
void connect(const ChannelPort::ConnectOptions &options={})
Definition Services.cpp:316
virtual std::string getServiceSymbol() const override
Definition Services.cpp:301
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get specialized port for this service to attach to the given appid path.
Definition Services.cpp:303
FuncService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:292
Interface for anything which can allocate HostMemRegions.
Definition Services.h:263
virtual ~HostMemAllocator()=default
virtual std::unique_ptr< HostMemRegion > allocate(std::size_t size, Options opts) const =0
Allocate a region of host memory in accelerator accessible address space.
virtual ~HostMem()=default
virtual std::string getServiceSymbol() const override
Definition Services.cpp:184
virtual void start()
In cases where necessary, enable host memory services.
Definition Services.h:292
Service(AcceleratorConnection &conn)
Definition Services.h:62
static constexpr std::string_view StdName
Definition Services.h:282
services::HostMemRegion HostMemRegion
RAII memory region for host memory. See services::HostMemRegion.
Definition Services.h:289
virtual void unmapMemory(void *ptr) const
Unmap memory which was previously mapped with 'mapMemory'.
Definition Services.h:309
virtual std::unique_ptr< HostMemRegion > allocate(std::size_t size, Options opts) const override=0
Allocate a region of host memory in accelerator accessible address space.
virtual bool mapMemory(void *ptr, std::size_t size, Options opts) const
Try to make a region of host memory accessible to the accelerator.
Definition Services.h:304
std::optional< uint64_t > getCycleCount() const override
Get the current cycle count of the accelerator system's core clock.
Definition Services.cpp:153
virtual std::vector< uint8_t > getCompressedManifest() const override
Return the zlib compressed JSON system manifest.
Definition Services.cpp:164
std::optional< uint64_t > getCoreClockFrequency() const override
Get the "core" clock frequency of the accelerator system in Hz.
Definition Services.cpp:157
uint32_t getEsiVersion() const override
Get the ESI version number to check version compatibility.
Definition Services.cpp:146
A "slice" of some parent MMIO space.
Definition Services.h:187
virtual uint64_t read(uint32_t addr) const
Read a 64-bit value from this region, not the global address space.
Definition Services.cpp:132
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:201
MMIORegion(AppID id, MMIO *parent, RegionDescriptor desc)
Definition Services.cpp:130
virtual void write(uint32_t addr, uint64_t data)
Write a 64-bit value to this region, not the global address space.
Definition Services.cpp:137
virtual RegionDescriptor getDescriptor() const
Get the offset (and size) of the region in the parent (usually global) MMIO address space.
Definition Services.h:194
virtual uint64_t read(uint32_t addr) const =0
Read a 64-bit value from the global MMIO space.
virtual ~MMIO()=default
virtual void write(uint32_t addr, uint64_t data)=0
Write a 64-bit value to the global MMIO space.
MMIO(AcceleratorConnection &, const AppIDPath &idPath, const HWClientDetails &clients)
Definition Services.cpp:56
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get a MMIO region port for a particular region descriptor.
Definition Services.cpp:94
std::map< AppIDPath, RegionDescriptor > regions
MMIO base address table.
Definition Services.h:183
static constexpr std::string_view StdName
Definition Services.h:140
virtual Service * getChildService(Service::Type service, AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={}) override
If the service is a MMIO service, return a region of the MMIO space which peers into ours.
Definition Services.cpp:118
const std::map< AppIDPath, RegionDescriptor > & getRegions() const
Get the regions of MMIO space that this service manages.
Definition Services.h:158
std::mutex mmioCmdLock
Definition Services.h:179
virtual std::string getServiceSymbol() const override
Definition Services.cpp:91
Add a custom interface to a service client at a particular point in the design hierarchy.
Definition Services.h:47
virtual ~ServicePort()=default
BundlePort(AppID id, const BundleType *type, PortMap channels)
Construct a port.
Definition Ports.cpp:39
virtual std::optional< std::string > toString(bool oneLine=false) const
Definition Services.h:52
Registry of services which can be instantiated directly by the Accelerator class if the backend doesn...
Definition Services.h:544
static Service::Type lookupServiceType(const std::string &)
Resolve a service type from a string.
Definition Services.cpp:528
static Service * createService(AcceleratorConnection *acc, Service::Type svcType, AppIDPath id, std::string implName, ServiceImplDetails details, HWClientDetails clients)
Create a service instance from the given details.
Definition Services.cpp:509
Parent class of all APIs modeled as 'services'.
Definition Services.h:59
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const
Get specialized port for this service to attach to the given appid path.
Definition Services.h:81
virtual std::string getServiceSymbol() const =0
AcceleratorConnection & getConnection() const
Definition Services.h:85
const std::type_info & Type
Definition Services.h:61
virtual Service * getChildService(Service::Type service, AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Create a "child" service of this service.
Definition Services.cpp:28
Service(AcceleratorConnection &conn)
Definition Services.h:62
virtual ~Service()=default
AcceleratorConnection & conn
Definition Services.h:88
Information about the Accelerator system.
Definition Services.h:113
virtual std::optional< uint64_t > getCoreClockFrequency() const
Get the "core" clock frequency of the accelerator system in Hz.
Definition Services.h:127
Service(AcceleratorConnection &conn)
Definition Services.h:62
virtual std::string getJsonManifest() const
Return the JSON-formatted system manifest.
Definition Services.cpp:40
virtual uint32_t getEsiVersion() const =0
Get the ESI version number to check version compatibility.
virtual std::vector< uint8_t > getCompressedManifest() const =0
Return the zlib compressed JSON system manifest.
virtual std::string getServiceSymbol() const override
Definition Services.cpp:35
virtual std::optional< uint64_t > getCycleCount() const
Get the current cycle count of the accelerator system.
Definition Services.h:124
virtual ~SysInfo()=default
std::optional< uint64_t > offset
Definition Services.h:524
virtual std::optional< std::string > toString(bool oneLine=false) const override
Definition Services.h:514
void connect()
Connect to a particular telemetry port. Offset should be non-nullopt.
Definition Services.cpp:481
std::future< MessageData > read()
Definition Services.cpp:488
Metric(AppID id, const BundleType *type, PortMap channels, const TelemetryService *telemetryService, std::optional< uint64_t > offset)
Definition Services.cpp:473
const TelemetryService * telemetryService
Definition Services.h:522
std::list< TelemetryService * > children
Definition Services.h:539
std::map< AppIDPath, Metric * > getTelemetryPorts()
Definition Services.h:527
MMIO::MMIORegion * mmio
Definition Services.h:536
MMIO::MMIORegion * getMMIORegion() const
Definition Services.cpp:434
std::map< AppIDPath, Metric * > telemetryPorts
Definition Services.h:538
std::map< AppIDPath, uint64_t > portAddressAssignments
Definition Services.h:537
static constexpr std::string_view StdName
Definition Services.h:487
TelemetryService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:391
virtual std::string getServiceSymbol() const override
Definition Services.cpp:430
virtual BundlePort * getPort(AppIDPath id, const BundleType *type) const override
Get specialized port for this service to attach to the given appid path.
Definition Services.cpp:453
virtual Service * getChildService(Service::Type service, AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={}) override
Create a "child" service of this service.
Definition Services.cpp:464
Definition esi.py:1
std::map< std::string, services::Service * > ServiceTable
Definition Services.h:41
std::string toHex(void *val)
Definition Common.cpp:38
std::map< std::string, ChannelPort & > PortMap
Definition Ports.h:33
std::vector< HWClientDetail > HWClientDetails
Definition Common.h:108
std::map< std::string, std::any > ServiceImplDetails
Definition Common.h:109
Options for allocating host memory.
Definition Services.h:268
RAII memory region for host memory in accelerator-accessible address space.
Definition Services.h:237
virtual std::size_t getSize() const =0
virtual void * getPtr() const =0
Get a pointer to the host memory.
virtual ~HostMemRegion()=default
virtual void flush()
Flush the memory region to ensure that the device sees the latest contents.
Definition Services.h:256
std::optional< uint64_t > getDeviceAddress(const void *ptr, std::size_t size) const
Device address of the host range [ptr, ptr + size) if that range lies entirely inside this region; st...
Definition Services.cpp:187
virtual void * getDevicePtr() const
Sometimes the pointer the device sees is different from the pointer the host sees.
Definition Services.h:243
Describe a region (slice) of MMIO space.
Definition Services.h:143