CIRCT 24.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
145
147 uint64_t reg;
148 if ((reg = mmio->read(MetadataOffset + MagicNumberOffset)) != MagicNumber)
149 throw std::runtime_error("Invalid magic number: " + toHex(reg));
151}
152
153std::optional<uint64_t> MMIOSysInfo::getCycleCount() const {
154 return mmio->read(MetadataOffset + CycleCountOffset);
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 != ExpectedVersionNumber)
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
186std::optional<uint64_t>
187HostMemRegion::getDeviceAddress(const void *ptr, std::size_t size) const {
188 if (size == 0)
189 return std::nullopt;
190 uintptr_t base = reinterpret_cast<uintptr_t>(getPtr());
191 uintptr_t p = reinterpret_cast<uintptr_t>(ptr);
192 std::size_t regionSize = getSize();
193 // Check bounds with subtractions only so nothing can overflow.
194 if (p < base)
195 return std::nullopt;
196 uintptr_t offset = p - base;
197 if (offset >= regionSize || size > regionSize - offset)
198 return std::nullopt;
199 uint64_t devBase = reinterpret_cast<uintptr_t>(getDevicePtr());
200 // The whole device range [devBase + offset, devBase + offset + size - 1]
201 // must be representable.
202 uint64_t devHeadroom = UINT64_MAX - devBase;
203 if (offset > devHeadroom || size - 1 > devHeadroom - offset)
204 return std::nullopt;
205 return devBase + offset;
206}
207
209 const ServiceImplDetails &details,
210 const HWClientDetails &clients)
211 : Service(conn), id(idPath) {
212 if (auto f = details.find("service"); f != details.end()) {
213 serviceSymbol = std::any_cast<std::string>(f->second);
214 // Strip off initial '@'.
215 serviceSymbol = serviceSymbol.substr(1);
216 }
217}
218
220 return new BundlePort(id.back(), type,
221 conn.getEngineMapFor(id).requestPorts(id, type));
222}
223
225 ServiceImplDetails details,
226 HWClientDetails clients)
227 : Service(conn) {
228 if (auto f = details.find("service"); f != details.end())
229 // Strip off initial '@'.
230 symbol = std::any_cast<std::string>(f->second).substr(1);
231}
232
233std::string ChannelService::getServiceSymbol() const { return symbol; }
234
236 const BundleType *type) const {
237 auto dataChan = type->findChannel("data");
238 PortMap ports = conn.getEngineMapFor(id).requestPorts(id, type);
239 if (dataChan.second == BundleType::Direction::From)
240 return new ToHost(id.back(), type, ports);
241 return new FromHost(id.back(), type, ports);
242}
243
245 const BundleType *type,
246 ReadChannelPort &data) {
247 return new ToHost(id, type, {{std::string("data"), data}});
248}
249
251 if (connected)
252 throw std::runtime_error("ToHost channel is already connected");
253 if (channels.size() != 1)
254 throw std::runtime_error("ChannelService ToHost must have exactly one "
255 "channel");
256 dataPort = &getRawRead("data");
257 dataPort->connect();
258 connected = true;
259}
260
261std::future<MessageData> ChannelService::ToHost::read() {
262 if (!connected)
263 throw std::runtime_error(
264 "ToHost channel must be 'connect'ed before reading");
265 return dataPort->readAsync();
266}
267
270 WriteChannelPort &data) {
271 return new FromHost(id, type, {{std::string("data"), data}});
272}
273
275 if (connected)
276 throw std::runtime_error("FromHost channel is already connected");
277 if (channels.size() != 1)
278 throw std::runtime_error("ChannelService FromHost must have exactly one "
279 "channel");
280 dataPort = &getRawWrite("data");
281 dataPort->connect();
282 connected = true;
283}
284
286 if (!connected)
287 throw std::runtime_error(
288 "FromHost channel must be 'connect'ed before writing");
289 dataPort->write(data);
290}
291
293 ServiceImplDetails details, HWClientDetails clients)
294 : Service(conn) {
295
296 if (auto f = details.find("service"); f != details.end())
297 // Strip off initial '@'.
298 symbol = std::any_cast<std::string>(f->second).substr(1);
299}
300
301std::string FuncService::getServiceSymbol() const { return symbol; }
302
304 return new Function(id.back(), type,
305 conn.getEngineMapFor(id).requestPorts(id, type));
306}
307
311 return new Function(
312 id, type, {{std::string("arg"), arg}, {std::string("result"), result}});
313 return nullptr;
314}
315
317 const ChannelPort::ConnectOptions &options) {
318 if (connected)
319 throw std::runtime_error("Function is already connected");
320 if (channels.size() != 2)
321 throw std::runtime_error("FuncService must have exactly two channels");
322 arg = &getRawWrite("arg");
323 arg->connect(options);
324 result = &getRawRead("result");
325 result->connect(options);
326 connected = true;
327}
328
329std::future<MessageData>
331 if (!connected)
332 throw std::runtime_error("Function must be 'connect'ed before calling");
333 std::scoped_lock<std::mutex> lock(callMutex);
334 arg->write(argData);
335 return result->readAsync();
336}
337
339 ServiceImplDetails details)
340 : Service(acc) {
341 if (auto f = details.find("service"); f != details.end())
342 // Strip off initial '@'.
343 symbol = std::any_cast<std::string>(f->second).substr(1);
344}
345
346std::string CallService::getServiceSymbol() const { return symbol; }
347
349 return new Callback(conn, id.back(), type,
350 conn.getEngineMapFor(id).requestPorts(id, type));
351}
352
356
364
366 std::function<MessageData(const MessageData &)> callback, bool quick,
367 const ChannelPort::ConnectOptions &options) {
368 if (channels.size() != 2)
369 throw std::runtime_error("CallService must have exactly two channels");
370 result = &getRawWrite("result");
371 result->connect(options);
372 arg = &getRawRead("arg");
373 if (quick) {
374 // If it's quick, we can just call the callback directly.
375 arg->connect([this, callback](MessageData argMsg) -> bool {
376 MessageData resultMsg = callback(std::move(argMsg));
377 this->result->write(std::move(resultMsg));
378 return true;
379 });
380 } else {
381 // If it's not quick, we need to use the service thread.
382 arg->connect(options);
383 acc.getServiceThread()->addListener(
384 {arg}, [this, callback](ReadChannelPort *, MessageData argMsg) -> void {
385 MessageData resultMsg = callback(std::move(argMsg));
386 this->result->write(std::move(resultMsg));
387 });
388 }
389}
390
393 ServiceImplDetails details,
394 HWClientDetails clients)
395 : Service(conn), id(idPath), mmio(nullptr) {
396 // Compute our parents idPath path.
397 AppIDPath prefix = std::move(idPath);
398 if (prefix.size() > 0)
399 prefix.pop_back();
400 for (const HWClientDetail &client : clients) {
401 if (client.implOptions.contains("type") &&
402 std::any_cast<std::string>(client.implOptions.at("type")) != "mmio")
403 continue; // Not an MMIO assignment.
404 AppIDPath fullClientPath = prefix + client.relPath;
405 auto offsetIter = client.implOptions.find("offset");
406 if (offsetIter == client.implOptions.end()) {
407 conn.getLogger().warning("Telemetry",
408 "mmio client " + fullClientPath.toStr() +
409 " missing 'offset' option, skipping");
410 continue;
411 }
412 const Constant *offset = std::any_cast<Constant>(&offsetIter->second);
413 if (offset == nullptr) {
414 conn.getLogger().warning(
415 "Telemetry", "mmio client " + fullClientPath.toStr() +
416 " 'offset' option must be a constant, skipping");
417 continue;
418 }
419 const uint64_t *offsetVal = std::any_cast<uint64_t>(&offset->value);
420 if (offsetVal == nullptr) {
421 conn.getLogger().warning(
422 "Telemetry", "mmio client " + fullClientPath.toStr() +
423 " 'offset' option must be an integer, skipping");
424 continue;
425 }
426 portAddressAssignments.emplace(fullClientPath, *offsetVal);
427 }
428}
429
431 return std::string(TelemetryService::StdName);
432}
433
435 if (!mmio) {
436 AppIDPath lastPath;
437 AppIDPath mmioPath = id;
438 mmioPath.pop_back();
439 mmioPath.push_back(AppID("__telemetry_mmio"));
440 auto port = conn.getAccelerator().resolvePort(mmioPath, lastPath);
441 if (!port)
442 throw std::runtime_error("TelemetryService: could not resolve port " +
443 id.toStr() + ". Got as far as " +
444 lastPath.toStr());
445 mmio = dynamic_cast<MMIO::MMIORegion *>(port);
446 if (!mmio)
447 throw std::runtime_error("TelemetryService: port " + id.toStr() +
448 " is not a MMIO region");
449 }
450 return mmio;
451}
452
454 const BundleType *type) const {
455 auto offsetIter = portAddressAssignments.find(id);
456 auto *port = new Metric(id.back(), type, {}, this,
457 offsetIter != portAddressAssignments.end()
458 ? std::optional<uint64_t>(offsetIter->second)
459 : std::nullopt);
460 telemetryPorts.insert(std::make_pair(id, port));
461 return port;
462}
463
465 std::string implName,
466 ServiceImplDetails details,
467 HWClientDetails clients) {
468 TelemetryService *child = new TelemetryService(id, conn, details, clients);
469 children.push_back(child);
470 return child;
471}
472
479
480/// Connect to a particular telemetry port. Offset should be non-nullopt.
482 if (!offset.has_value())
483 throw std::runtime_error("Telemetry offset not found for " + id.toString());
484 mmio = telemetryService->getMMIORegion();
485 assert(mmio && "TelemetryService: MMIO region not found");
486}
487
488std::future<MessageData> TelemetryService::Metric::read() {
489 return std::async(std::launch::async, [this]() {
490 uint64_t data = readInt();
491 return MessageData::from(data);
492 });
493}
494
496 assert(offset.has_value() &&
497 "Telemetry offset must be set. Checked in connect().");
498 assert(mmio && "TelemetryService: MMIO region not set");
499 return mmio->read(*offset);
500}
501
502void TelemetryService::getTelemetryPorts(std::map<AppIDPath, Metric *> &ports) {
503 for (const auto &entry : telemetryPorts)
504 ports[entry.first] = entry.second;
505 for (TelemetryService *child : children)
506 child->getTelemetryPorts(ports);
507}
508
510 Service::Type svcType, AppIDPath id,
511 std::string implName,
512 ServiceImplDetails details,
513 HWClientDetails clients) {
514 // TODO: Add a proper registration mechanism.
515 if (svcType == typeid(FuncService))
516 return new FuncService(id, *acc, details, clients);
517 if (svcType == typeid(CallService))
518 return new CallService(*acc, id, details);
519 if (svcType == typeid(ChannelService))
520 return new ChannelService(id, *acc, details, clients);
521 if (svcType == typeid(TelemetryService))
522 return new TelemetryService(id, *acc, details, clients);
523 if (svcType == typeid(CustomService))
524 return new CustomService(id, *acc, details, clients);
525 return nullptr;
526}
527
529 // TODO: Add a proper registration mechanism.
530 if (svcName == "esi.service.std.func")
531 return typeid(FuncService);
532 if (svcName == "esi.service.std.call")
533 return typeid(CallService);
534 if (svcName == "esi.service.std.channel")
535 return typeid(ChannelService);
536 if (svcName == MMIO::StdName)
537 return typeid(MMIO);
538 if (svcName == HostMem::StdName)
539 return typeid(HostMem);
540 if (svcName == TelemetryService::StdName)
541 return typeid(TelemetryService);
542 return typeid(CustomService);
543}
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.
std::string toStr() const
Definition Manifest.cpp:816
AppIDPath parent() const
Definition Manifest.cpp:809
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
Definition Ports.h:637
PortMap channels
Definition Ports.h:681
ReadChannelPort & getRawRead(const std::string &name) const
Definition Ports.cpp:52
WriteChannelPort & getRawWrite(const std::string &name) const
Get access to the raw byte streams of a channel.
Definition Ports.cpp:42
const BundleType * type
Definition Ports.h:680
Bundles represent a collection of channels.
Definition Types.h:104
std::pair< const Type *, Direction > findChannel(std::string name) const
Definition Types.cpp:127
A concrete flat message backed by a single vector of bytes.
Definition Common.h:197
static MessageData from(T &t)
Cast from a type to its raw bytes.
Definition Common.h:242
A ChannelPort which reads data from the accelerator.
Definition Ports.h:479
A ChannelPort which sends data to the accelerator.
Definition Ports.h:308
A function call which gets attached to a service port.
Definition Services.h:437
static Callback * get(AcceleratorConnection &acc, AppID id, const BundleType *type, WriteChannelPort &result, ReadChannelPort &arg)
Definition Services.cpp:357
Callback(AcceleratorConnection &acc, AppID id, const BundleType *, PortMap channels)
Definition Services.cpp:353
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
Service for servicing function calls from the accelerator.
Definition Services.h:427
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
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
static ToHost * get(AppID id, const BundleType *type, ReadChannelPort &dataPort)
Definition Services.cpp:244
Service for raw communication channels to/from the accelerator.
Definition Services.h:313
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
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:219
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
std::future< MessageData > call(const MessageData &arg)
Definition Services.cpp:330
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
Service for calling functions.
Definition Services.h:375
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
virtual std::string getServiceSymbol() const override
Definition Services.cpp:184
static constexpr std::string_view StdName
Definition Services.h:282
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
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
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
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: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
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
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:502
std::optional< uint64_t > offset
Definition Services.h:524
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
Service for retrieving telemetry data from the accelerator.
Definition Services.h:485
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::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:67
constexpr uint64_t MagicNumber
Definition Accelerator.h:57
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
constexpr uint32_t ExpectedVersionNumber
Keep in sync with circt::esi::esiApiVersion and the PyCDE BSP.
Definition Accelerator.h:61
constexpr uint64_t MagicNumberOffset
Definition Accelerator.h:58
constexpr uint32_t MetadataOffset
Definition Accelerator.h:53
std::map< std::string, std::any > ServiceImplDetails
Definition Common.h:109
constexpr uint32_t CycleCountOffset
Definition Accelerator.h:66
constexpr uint32_t ManifestPtrOffset
Definition Accelerator.h:64
constexpr uint64_t VersionNumberOffset
Definition Accelerator.h:62
std::any value
Definition Common.h:69
A description of a hardware client.
Definition Common.h:102
virtual std::size_t getSize() const =0
virtual void * getPtr() const =0
Get a pointer to the host memory.
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