CIRCT 23.0.0git
Loading...
Searching...
No Matches
Services.cpp
Go to the documentation of this file.
1//===- StdServices.cpp - implementations of std services ------------------===//
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// DO NOT EDIT!
10// This file is distributed as part of an ESI package. The source for this file
11// should always be modified within CIRCT
12// (lib/dialect/ESI/runtime/cpp/lib/backends/Cosim.cpp).
13//
14//===----------------------------------------------------------------------===//
15
16#include "esi/Services.h"
17#include "esi/Accelerator.h"
18#include "esi/Engines.h"
19
20#include "zlib.h"
21
22#include <cassert>
23#include <stdexcept>
24
25using namespace esi;
26using namespace esi::services;
27
29 std::string implName,
30 ServiceImplDetails details,
31 HWClientDetails clients) {
32 return conn.getService(service, id, implName, details, clients);
33}
34
35std::string SysInfo::getServiceSymbol() const { return "__builtin_SysInfo"; }
36
37// Allocate 10MB for the uncompressed manifest. This should be plenty.
38constexpr uint32_t MAX_MANIFEST_SIZE = 10 << 20;
39/// Get the compressed manifest, uncompress, and return it.
40std::string SysInfo::getJsonManifest() const {
41 std::vector<uint8_t> compressed = getCompressedManifest();
42 std::vector<Bytef> dst(MAX_MANIFEST_SIZE);
43 uLongf dstSize = MAX_MANIFEST_SIZE;
44 int rc =
45 uncompress(dst.data(), &dstSize, compressed.data(), compressed.size());
46 if (rc != Z_OK)
47 throw std::runtime_error("zlib uncompress failed with rc=" +
48 std::to_string(rc));
49 return std::string(reinterpret_cast<char *>(dst.data()), dstSize);
50}
51
52//===----------------------------------------------------------------------===//
53// MMIO class implementations.
54//===----------------------------------------------------------------------===//
55
57 const HWClientDetails &clients)
58 : Service(conn) {
59 AppIDPath idParent = idPath.parent();
60 for (const HWClientDetail &client : clients) {
61 auto offsetIter = client.implOptions.find("offset");
62 if (offsetIter == client.implOptions.end())
63 throw std::runtime_error("MMIO client missing 'offset' option");
64 const Constant *offset = std::any_cast<Constant>(&offsetIter->second);
65 if (!offset)
66 throw std::runtime_error(
67 "MMIO client 'offset' option must be a constant");
68 const uint64_t *offsetVal = std::any_cast<uint64_t>(&offset->value);
69 if (!offsetVal)
70 throw std::runtime_error(
71 "MMIO client 'offset' option must be an integer");
72 if (*offsetVal >= 1ull << 32)
73 throw std::runtime_error("MMIO client offset mustn't exceed 32 bits");
74
75 auto sizeIter = client.implOptions.find("size");
76 if (sizeIter == client.implOptions.end())
77 throw std::runtime_error("MMIO client missing 'size' option");
78 const Constant *size = std::any_cast<Constant>(&sizeIter->second);
79 if (!size)
80 throw std::runtime_error("MMIO client 'size' option must be a constant");
81 const uint64_t *sizeVal = std::any_cast<uint64_t>(&size->value);
82 if (!sizeVal)
83 throw std::runtime_error("MMIO client 'size' option must be an integer");
84 if (*sizeVal >= 1ull << 32)
85 throw std::runtime_error("MMIO client size mustn't exceed 32 bits");
86 regions[client.relPath] = RegionDescriptor{
87 static_cast<uint32_t>(*offsetVal), static_cast<uint32_t>(*sizeVal)};
88 }
89}
90
91std::string MMIO::getServiceSymbol() const {
92 return std::string(MMIO::StdName);
93}
95 auto regionIter = regions.find(id);
96 if (regionIter == regions.end())
97 return nullptr;
98 return new MMIORegion(id.back(), const_cast<MMIO *>(this),
99 regionIter->second);
100}
101
102namespace {
103class MMIOPassThrough : public MMIO {
104public:
105 MMIOPassThrough(const HWClientDetails &clients, const AppIDPath &idPath,
106 MMIO *parent)
107 : MMIO(parent->getConnection(), idPath, clients), parent(parent) {}
108 uint64_t read(uint32_t addr) const override { return parent->read(addr); }
109 void write(uint32_t addr, uint64_t data) override {
110 parent->write(addr, data);
111 }
112
113private:
114 MMIO *parent;
115};
116} // namespace
117
119 std::string implName, ServiceImplDetails details,
120 HWClientDetails clients) {
121 if (service != typeid(MMIO))
122 return Service::getChildService(service, id, implName, details, clients);
123 return new MMIOPassThrough(clients, id, this);
124}
125
126//===----------------------------------------------------------------------===//
127// MMIO Region service port class implementations.
128//===----------------------------------------------------------------------===//
129
131 : ServicePort(id, nullptr, {}), parent(parent), desc(desc) {}
132uint64_t MMIO::MMIORegion::read(uint32_t addr) const {
133 if (addr >= desc.size)
134 throw std::runtime_error("MMIO read out of bounds: " + toHex(addr));
135 return parent->read(desc.base + addr);
136}
137void MMIO::MMIORegion::write(uint32_t addr, uint64_t data) {
138 if (addr >= desc.size)
139 throw std::runtime_error("MMIO write out of bounds: " + toHex(addr));
140 parent->write(desc.base + addr, data);
141}
142
144 : SysInfo(mmio->getConnection()), mmio(mmio) {}
145
147 uint64_t reg;
149 throw std::runtime_error("Invalid magic number: " + toHex(reg));
151}
152
153std::optional<uint64_t> MMIOSysInfo::getCycleCount() const {
155}
156
157std::optional<uint64_t> MMIOSysInfo::getCoreClockFrequency() const {
158 uint64_t freq = mmio->read(MetadataOffset + CoreFreqOffset);
159 if (freq == 0)
160 return std::nullopt;
161 return freq;
162}
163
164std::vector<uint8_t> MMIOSysInfo::getCompressedManifest() const {
165 uint64_t version = getEsiVersion();
166 if (version != 0)
167 throw std::runtime_error("Unsupported ESI header version: " +
168 std::to_string(version));
169 uint64_t manifestPtr = mmio->read(MetadataOffset + ManifestPtrOffset);
170 uint64_t size = mmio->read(manifestPtr);
171 uint64_t numWords = (size + 7) / 8;
172 std::vector<uint64_t> manifestWords(numWords);
173 for (size_t i = 0; i < numWords; ++i)
174 manifestWords[i] = mmio->read(manifestPtr + 8 + (i * 8));
175
176 std::vector<uint8_t> manifest;
177 for (size_t i = 0; i < size; ++i) {
178 uint64_t word = manifestWords[i / 8];
179 manifest.push_back(word >> (8 * (i % 8)));
180 }
181 return manifest;
182}
183
184std::string HostMem::getServiceSymbol() const { return "__builtin_HostMem"; }
185
187 const ServiceImplDetails &details,
188 const HWClientDetails &clients)
189 : Service(conn), id(idPath) {
190 if (auto f = details.find("service"); f != details.end()) {
191 serviceSymbol = std::any_cast<std::string>(f->second);
192 // Strip off initial '@'.
193 serviceSymbol = serviceSymbol.substr(1);
194 }
195}
196
198 return new BundlePort(id.back(), type,
199 conn.getEngineMapFor(id).requestPorts(id, type));
200}
201
203 ServiceImplDetails details,
204 HWClientDetails clients)
205 : Service(conn) {
206 if (auto f = details.find("service"); f != details.end())
207 // Strip off initial '@'.
208 symbol = std::any_cast<std::string>(f->second).substr(1);
209}
210
211std::string ChannelService::getServiceSymbol() const { return symbol; }
212
214 const BundleType *type) const {
215 auto dataChan = type->findChannel("data");
216 PortMap ports = conn.getEngineMapFor(id).requestPorts(id, type);
217 if (dataChan.second == BundleType::Direction::From)
218 return new ToHost(id.back(), type, ports);
219 return new FromHost(id.back(), type, ports);
220}
221
223 const BundleType *type,
224 ReadChannelPort &data) {
225 return new ToHost(id, type, {{std::string("data"), data}});
226}
227
229 if (connected)
230 throw std::runtime_error("ToHost channel is already connected");
231 if (channels.size() != 1)
232 throw std::runtime_error("ChannelService ToHost must have exactly one "
233 "channel");
234 dataPort = &getRawRead("data");
235 dataPort->connect();
236 connected = true;
237}
238
239std::future<MessageData> ChannelService::ToHost::read() {
240 if (!connected)
241 throw std::runtime_error(
242 "ToHost channel must be 'connect'ed before reading");
243 return dataPort->readAsync();
244}
245
248 WriteChannelPort &data) {
249 return new FromHost(id, type, {{std::string("data"), data}});
250}
251
253 if (connected)
254 throw std::runtime_error("FromHost channel is already connected");
255 if (channels.size() != 1)
256 throw std::runtime_error("ChannelService FromHost must have exactly one "
257 "channel");
258 dataPort = &getRawWrite("data");
259 dataPort->connect();
260 connected = true;
261}
262
264 if (!connected)
265 throw std::runtime_error(
266 "FromHost channel must be 'connect'ed before writing");
267 dataPort->write(data);
268}
269
271 ServiceImplDetails details, HWClientDetails clients)
272 : Service(conn) {
273
274 if (auto f = details.find("service"); f != details.end())
275 // Strip off initial '@'.
276 symbol = std::any_cast<std::string>(f->second).substr(1);
277}
278
279std::string FuncService::getServiceSymbol() const { return symbol; }
280
282 return new Function(id.back(), type,
283 conn.getEngineMapFor(id).requestPorts(id, type));
284}
285
287 WriteChannelPort &arg,
288 ReadChannelPort &result) {
289 return new Function(
290 id, type, {{std::string("arg"), arg}, {std::string("result"), result}});
291 return nullptr;
292}
293
295 if (connected)
296 throw std::runtime_error("Function is already connected");
297 if (channels.size() != 2)
298 throw std::runtime_error("FuncService must have exactly two channels");
299 arg = &getRawWrite("arg");
300 arg->connect();
301 result = &getRawRead("result");
302 result->connect();
303 connected = true;
304}
305
306std::future<MessageData>
308 if (!connected)
309 throw std::runtime_error("Function must be 'connect'ed before calling");
310 std::scoped_lock<std::mutex> lock(callMutex);
311 arg->write(argData);
312 return result->readAsync();
313}
314
316 ServiceImplDetails details)
317 : Service(acc) {
318 if (auto f = details.find("service"); f != details.end())
319 // Strip off initial '@'.
320 symbol = std::any_cast<std::string>(f->second).substr(1);
321}
322
323std::string CallService::getServiceSymbol() const { return symbol; }
324
326 return new Callback(conn, id.back(), type,
327 conn.getEngineMapFor(id).requestPorts(id, type));
328}
329
331 const BundleType *type, PortMap channels)
332 : ServicePort(id, type, channels), acc(acc) {}
333
335 AppID id,
336 const BundleType *type,
337 WriteChannelPort &result,
338 ReadChannelPort &arg) {
339 return new Callback(acc, id, type, {{"arg", arg}, {"result", result}});
340}
341
343 std::function<MessageData(const MessageData &)> callback, bool quick) {
344 if (channels.size() != 2)
345 throw std::runtime_error("CallService must have exactly two channels");
346 result = &getRawWrite("result");
347 result->connect();
348 arg = &getRawRead("arg");
349 if (quick) {
350 // If it's quick, we can just call the callback directly.
351 arg->connect([this, callback](MessageData argMsg) -> bool {
352 MessageData resultMsg = callback(std::move(argMsg));
353 this->result->write(std::move(resultMsg));
354 return true;
355 });
356 } else {
357 // If it's not quick, we need to use the service thread.
358 arg->connect();
359 acc.getServiceThread()->addListener(
360 {arg}, [this, callback](ReadChannelPort *, MessageData argMsg) -> void {
361 MessageData resultMsg = callback(std::move(argMsg));
362 this->result->write(std::move(resultMsg));
363 });
364 }
365}
366
369 ServiceImplDetails details,
370 HWClientDetails clients)
371 : Service(conn), id(idPath), mmio(nullptr) {
372 // Compute our parents idPath path.
373 AppIDPath prefix = std::move(idPath);
374 if (prefix.size() > 0)
375 prefix.pop_back();
376 for (const HWClientDetail &client : clients) {
377 if (client.implOptions.contains("type") &&
378 std::any_cast<std::string>(client.implOptions.at("type")) != "mmio")
379 continue; // Not an MMIO assignment.
380 AppIDPath fullClientPath = prefix + client.relPath;
381 auto offsetIter = client.implOptions.find("offset");
382 if (offsetIter == client.implOptions.end()) {
383 conn.getLogger().warning("Telemetry",
384 "mmio client " + fullClientPath.toStr() +
385 " missing 'offset' option, skipping");
386 continue;
387 }
388 const Constant *offset = std::any_cast<Constant>(&offsetIter->second);
389 if (offset == nullptr) {
391 "Telemetry", "mmio client " + fullClientPath.toStr() +
392 " 'offset' option must be a constant, skipping");
393 continue;
394 }
395 const uint64_t *offsetVal = std::any_cast<uint64_t>(&offset->value);
396 if (offsetVal == nullptr) {
398 "Telemetry", "mmio client " + fullClientPath.toStr() +
399 " 'offset' option must be an integer, skipping");
400 continue;
401 }
402 portAddressAssignments.emplace(fullClientPath, *offsetVal);
403 }
404}
405
407 return std::string(TelemetryService::StdName);
408}
409
411 if (!mmio) {
412 AppIDPath lastPath;
413 AppIDPath mmioPath = id;
414 mmioPath.pop_back();
415 mmioPath.push_back(AppID("__telemetry_mmio"));
416 auto port = conn.getAccelerator().resolvePort(mmioPath, lastPath);
417 if (!port)
418 throw std::runtime_error("TelemetryService: could not resolve port " +
419 id.toStr() + ". Got as far as " +
420 lastPath.toStr());
421 mmio = dynamic_cast<MMIO::MMIORegion *>(port);
422 if (!mmio)
423 throw std::runtime_error("TelemetryService: port " + id.toStr() +
424 " is not a MMIO region");
425 }
426 return mmio;
427}
428
430 const BundleType *type) const {
431 auto offsetIter = portAddressAssignments.find(id);
432 auto *port = new Metric(id.back(), type, {}, this,
433 offsetIter != portAddressAssignments.end()
434 ? std::optional<uint64_t>(offsetIter->second)
435 : std::nullopt);
436 telemetryPorts.insert(std::make_pair(id, port));
437 return port;
438}
439
441 std::string implName,
442 ServiceImplDetails details,
443 HWClientDetails clients) {
444 TelemetryService *child = new TelemetryService(id, conn, details, clients);
445 children.push_back(child);
446 return child;
447}
448
450 PortMap channels,
451 const TelemetryService *telemetryService,
452 std::optional<uint64_t> offset)
453 : ServicePort(id, type, channels), telemetryService(telemetryService),
454 mmio(nullptr), offset(offset) {}
455
456/// Connect to a particular telemetry port. Offset should be non-nullopt.
458 if (!offset.has_value())
459 throw std::runtime_error("Telemetry offset not found for " + id.toString());
460 mmio = telemetryService->getMMIORegion();
461 assert(mmio && "TelemetryService: MMIO region not found");
462}
463
464std::future<MessageData> TelemetryService::Metric::read() {
465 return std::async(std::launch::async, [this]() {
466 uint64_t data = readInt();
467 return MessageData::from(data);
468 });
469}
470
472 assert(offset.has_value() &&
473 "Telemetry offset must be set. Checked in connect().");
474 assert(mmio && "TelemetryService: MMIO region not set");
475 return mmio->read(*offset);
476}
477
478void TelemetryService::getTelemetryPorts(std::map<AppIDPath, Metric *> &ports) {
479 for (const auto &entry : telemetryPorts)
480 ports[entry.first] = entry.second;
481 for (TelemetryService *child : children)
482 child->getTelemetryPorts(ports);
483}
484
486 Service::Type svcType, AppIDPath id,
487 std::string implName,
488 ServiceImplDetails details,
489 HWClientDetails clients) {
490 // TODO: Add a proper registration mechanism.
491 if (svcType == typeid(FuncService))
492 return new FuncService(id, *acc, details, clients);
493 if (svcType == typeid(CallService))
494 return new CallService(*acc, id, details);
495 if (svcType == typeid(ChannelService))
496 return new ChannelService(id, *acc, details, clients);
497 if (svcType == typeid(TelemetryService))
498 return new TelemetryService(id, *acc, details, clients);
499 if (svcType == typeid(CustomService))
500 return new CustomService(id, *acc, details, clients);
501 return nullptr;
502}
503
505 // TODO: Add a proper registration mechanism.
506 if (svcName == "esi.service.std.func")
507 return typeid(FuncService);
508 if (svcName == "esi.service.std.call")
509 return typeid(CallService);
510 if (svcName == "esi.service.std.channel")
511 return typeid(ChannelService);
512 if (svcName == MMIO::StdName)
513 return typeid(MMIO);
514 if (svcName == HostMem::StdName)
515 return typeid(HostMem);
516 if (svcName == TelemetryService::StdName)
517 return typeid(TelemetryService);
518 return typeid(CustomService);
519}
assert(baseType &&"element must be base type")
constexpr uint32_t MAX_MANIFEST_SIZE
Definition Services.cpp:38
Abstract class representing a connection to an accelerator.
Definition Accelerator.h:89
ServiceClass * getService(AppIDPath id={}, std::string implName={}, ServiceImplDetails details={}, HWClientDetails clients={})
Get a typed reference to a particular service type.
Accelerator & getAccelerator()
virtual const BundleEngineMap & getEngineMapFor(AppIDPath id)
Logger & getLogger() const
Definition Accelerator.h:94
std::string toStr() const
Definition Manifest.cpp:799
AppIDPath parent() const
Definition Manifest.cpp:792
PortMap requestPorts(const AppIDPath &idPath, const BundleType *bundleType) const
Request ports for all the channels in a bundle.
Definition Engines.cpp:470
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
Definition Ports.h:433
const BundleType * type
Definition Ports.h:476
Bundles represent a collection of channels.
Definition Types.h:99
std::pair< const Type *, Direction > findChannel(std::string name) const
Definition Types.cpp:110
BundlePort * resolvePort(const AppIDPath &path, AppIDPath &lastLookup) const
Attempt to resolve a path to a port.
Definition Design.cpp:72
virtual void warning(const std::string &subsystem, const std::string &msg, const std::map< std::string, std::any > *details=nullptr)
Report a warning.
Definition Logging.h:70
A logical chunk of data representing serialized data.
Definition Common.h:113
static MessageData from(T &t)
Cast from a type to its raw bytes.
Definition Common.h:158
A ChannelPort which reads data from the accelerator.
Definition Ports.h:318
A ChannelPort which sends data to the accelerator.
Definition Ports.h:206
A function call which gets attached to a service port.
Definition Services.h:405
static Callback * get(AcceleratorConnection &acc, AppID id, const BundleType *type, WriteChannelPort &result, ReadChannelPort &arg)
Definition Services.cpp:334
Callback(AcceleratorConnection &acc, AppID id, const BundleType *, PortMap channels)
Definition Services.cpp:330
void connect(std::function< MessageData(const MessageData &)> callback, bool quick=false)
Connect a callback to code which will be executed when the accelerator invokes the callback.
Definition Services.cpp:342
Service for servicing function calls from the accelerator.
Definition Services.h:395
virtual std::string getServiceSymbol() const override
Definition Services.cpp:323
CallService(AcceleratorConnection &acc, AppIDPath id, ServiceImplDetails details)
Definition Services.cpp:315
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:325
A port which writes data to the accelerator (from_host).
Definition Services.h:315
static FromHost * get(AppID id, const BundleType *type, WriteChannelPort &dataPort)
Definition Services.cpp:247
void write(const MessageData &data)
Definition Services.cpp:263
A port which reads data from the accelerator (to_host).
Definition Services.h:291
std::future< MessageData > read()
Definition Services.cpp:239
static ToHost * get(AppID id, const BundleType *type, ReadChannelPort &dataPort)
Definition Services.cpp:222
Service for raw communication channels to/from the accelerator.
Definition Services.h:281
virtual std::string getServiceSymbol() const override
Definition Services.cpp:211
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:213
ChannelService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:202
A service for which there are no standard services registered.
Definition Services.h:94
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:197
CustomService(AppIDPath idPath, AcceleratorConnection &, const ServiceImplDetails &details, const HWClientDetails &clients)
Definition Services.cpp:186
A function call which gets attached to a service port.
Definition Services.h:353
std::future< MessageData > call(const MessageData &arg)
Definition Services.cpp:307
static Function * get(AppID id, BundleType *type, WriteChannelPort &arg, ReadChannelPort &result)
Definition Services.cpp:286
Service for calling functions.
Definition Services.h:343
virtual std::string getServiceSymbol() const override
Definition Services.cpp:279
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:281
FuncService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:270
virtual std::string getServiceSymbol() const override
Definition Services.cpp:184
static constexpr std::string_view StdName
Definition Services.h:229
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:181
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
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 uint64_t read(uint32_t addr) const =0
Read a 64-bit value from 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:177
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
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
static Service::Type lookupServiceType(const std::string &)
Resolve a service type from a string.
Definition Services.cpp:504
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:485
Parent class of all APIs modeled as 'services'.
Definition Services.h:59
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
AcceleratorConnection & conn
Definition Services.h:88
Information about the Accelerator system.
Definition Services.h:113
virtual std::string getJsonManifest() const
Return the JSON-formatted system manifest.
Definition Services.cpp:40
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
A telemetry port which gets attached to a service port.
Definition Services.h:469
void connect()
Connect to a particular telemetry port. Offset should be non-nullopt.
Definition Services.cpp:457
std::future< MessageData > read()
Definition Services.cpp:464
Metric(AppID id, const BundleType *type, PortMap channels, const TelemetryService *telemetryService, std::optional< uint64_t > offset)
Definition Services.cpp:449
Service for retrieving telemetry data from the accelerator.
Definition Services.h:452
std::list< TelemetryService * > children
Definition Services.h:506
std::map< AppIDPath, Metric * > getTelemetryPorts()
Definition Services.h:494
MMIO::MMIORegion * mmio
Definition Services.h:503
MMIO::MMIORegion * getMMIORegion() const
Definition Services.cpp:410
std::map< AppIDPath, Metric * > telemetryPorts
Definition Services.h:505
std::map< AppIDPath, uint64_t > portAddressAssignments
Definition Services.h:504
static constexpr std::string_view StdName
Definition Services.h:454
TelemetryService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details, HWClientDetails clients)
Definition Services.cpp:367
virtual std::string getServiceSymbol() const override
Definition Services.cpp:406
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:429
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:440
Definition esi.py:1
std::string toString(const std::any &a)
'Stringify' a std::any. This is used to log std::any values by some loggers.
Definition Logging.cpp:132
constexpr uint32_t CoreFreqOffset
Definition Accelerator.h:59
constexpr uint64_t MagicNumber
Definition Accelerator.h:50
std::map< std::string, std::any > ServiceImplDetails
Definition Common.h:108
std::string toHex(void *val)
Definition Common.cpp:37
constexpr uint64_t MagicNumberOffset
Definition Accelerator.h:51
constexpr uint32_t MetadataOffset
Definition Accelerator.h:46
constexpr uint32_t CycleCountOffset
Definition Accelerator.h:58
constexpr uint32_t ManifestPtrOffset
Definition Accelerator.h:56
std::map< std::string, ChannelPort & > PortMap
Definition Ports.h:29
constexpr uint64_t VersionNumberOffset
Definition Accelerator.h:54
std::vector< HWClientDetail > HWClientDetails
Definition Common.h:107
std::any value
Definition Common.h:68
A description of a hardware client.
Definition Common.h:101
Describe a region (slice) of MMIO space.
Definition Services.h:143