esiaccel 0.2.3.dev49__cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of esiaccel might be problematic. Click here for more details.
- esiaccel/__init__.py +31 -0
- esiaccel/accelerator.py +134 -0
- esiaccel/bin/esi-cosim.py +104 -0
- esiaccel/bin/esiquery +0 -0
- esiaccel/cmake/esiaccelConfig.cmake +49 -0
- esiaccel/codegen.py +197 -0
- esiaccel/cosim/Cosim_CycleCount.sv +84 -0
- esiaccel/cosim/Cosim_DpiPkg.sv +85 -0
- esiaccel/cosim/Cosim_Endpoint.sv +218 -0
- esiaccel/cosim/Cosim_Manifest.sv +32 -0
- esiaccel/cosim/driver.cpp +131 -0
- esiaccel/cosim/driver.sv +74 -0
- esiaccel/cosim/questa.py +141 -0
- esiaccel/cosim/simulator.py +383 -0
- esiaccel/cosim/verilator.py +92 -0
- esiaccel/esiCppAccel.cpython-314-x86_64-linux-gnu.so +0 -0
- esiaccel/esiCppAccel.pyi +337 -0
- esiaccel/include/esi/Accelerator.h +229 -0
- esiaccel/include/esi/CLI.h +77 -0
- esiaccel/include/esi/Common.h +182 -0
- esiaccel/include/esi/Context.h +82 -0
- esiaccel/include/esi/Design.h +132 -0
- esiaccel/include/esi/Engines.h +124 -0
- esiaccel/include/esi/Logging.h +231 -0
- esiaccel/include/esi/Manifest.h +70 -0
- esiaccel/include/esi/Ports.h +482 -0
- esiaccel/include/esi/Services.h +467 -0
- esiaccel/include/esi/Types.h +334 -0
- esiaccel/include/esi/Utils.h +102 -0
- esiaccel/include/esi/Values.h +313 -0
- esiaccel/include/esi/backends/Cosim.h +78 -0
- esiaccel/include/esi/backends/RpcClient.h +97 -0
- esiaccel/include/esi/backends/RpcServer.h +73 -0
- esiaccel/include/esi/backends/Trace.h +87 -0
- esiaccel/lib/libCosimBackend.so +0 -0
- esiaccel/lib/libCosimRpc.so +0 -0
- esiaccel/lib/libESICppRuntime.so +0 -0
- esiaccel/lib/libEsiCosimDpiServer.so +0 -0
- esiaccel/lib/libMtiPli.so +0 -0
- esiaccel/types.py +565 -0
- esiaccel/utils.py +54 -0
- esiaccel-0.2.3.dev49.dist-info/METADATA +254 -0
- esiaccel-0.2.3.dev49.dist-info/RECORD +47 -0
- esiaccel-0.2.3.dev49.dist-info/WHEEL +6 -0
- esiaccel-0.2.3.dev49.dist-info/entry_points.txt +4 -0
- esiaccel-0.2.3.dev49.dist-info/licenses/LICENSE +234 -0
- esiaccel-0.2.3.dev49.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,467 @@
|
|
|
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
|
+
|
|
30
|
+
namespace esi {
|
|
31
|
+
class AcceleratorConnection;
|
|
32
|
+
class Engine;
|
|
33
|
+
namespace services {
|
|
34
|
+
class 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.
|
|
41
|
+
using ServiceTable = std::map<std::string, services::Service *>;
|
|
42
|
+
|
|
43
|
+
namespace services {
|
|
44
|
+
|
|
45
|
+
/// Add a custom interface to a service client at a particular point in the
|
|
46
|
+
/// design hierarchy.
|
|
47
|
+
class ServicePort : public BundlePort {
|
|
48
|
+
public:
|
|
49
|
+
using BundlePort::BundlePort;
|
|
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'.
|
|
59
|
+
class Service {
|
|
60
|
+
public:
|
|
61
|
+
using Type = const std::type_info &;
|
|
62
|
+
Service(AcceleratorConnection &conn) : conn(conn) {}
|
|
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
|
+
|
|
85
|
+
AcceleratorConnection &getConnection() const { return conn; }
|
|
86
|
+
|
|
87
|
+
protected:
|
|
88
|
+
AcceleratorConnection &conn;
|
|
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.
|
|
94
|
+
class CustomService : public Service {
|
|
95
|
+
public:
|
|
96
|
+
CustomService(AppIDPath idPath, AcceleratorConnection &,
|
|
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
|
+
|
|
107
|
+
protected:
|
|
108
|
+
std::string serviceSymbol;
|
|
109
|
+
AppIDPath id;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/// Information about the Accelerator system.
|
|
113
|
+
class SysInfo : public Service {
|
|
114
|
+
public:
|
|
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
|
+
|
|
138
|
+
class MMIO : public Service {
|
|
139
|
+
public:
|
|
140
|
+
static constexpr std::string_view StdName = "esi.service.std.mmio";
|
|
141
|
+
|
|
142
|
+
/// Describe a region (slice) of MMIO space.
|
|
143
|
+
struct RegionDescriptor {
|
|
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
|
+
|
|
175
|
+
private:
|
|
176
|
+
/// MMIO base address table.
|
|
177
|
+
std::map<AppIDPath, RegionDescriptor> regions;
|
|
178
|
+
|
|
179
|
+
public:
|
|
180
|
+
/// A "slice" of some parent MMIO space.
|
|
181
|
+
class MMIORegion : public ServicePort {
|
|
182
|
+
friend class MMIO;
|
|
183
|
+
MMIORegion(AppID id, MMIO *parent, RegionDescriptor desc);
|
|
184
|
+
|
|
185
|
+
public:
|
|
186
|
+
/// Get the offset (and size) of the region in the parent (usually global)
|
|
187
|
+
/// MMIO address space.
|
|
188
|
+
virtual RegionDescriptor getDescriptor() const { return desc; };
|
|
189
|
+
/// Read a 64-bit value from this region, not the global address space.
|
|
190
|
+
virtual uint64_t read(uint32_t addr) const;
|
|
191
|
+
/// Write a 64-bit value to this region, not the global address space.
|
|
192
|
+
virtual void write(uint32_t addr, uint64_t data);
|
|
193
|
+
|
|
194
|
+
virtual std::optional<std::string>
|
|
195
|
+
toString(bool oneLine = false) const override {
|
|
196
|
+
return "MMIO region " + toHex(desc.base) + " - " +
|
|
197
|
+
toHex(desc.base + desc.size);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
MMIO *parent;
|
|
202
|
+
RegionDescriptor desc;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/// Implement the SysInfo API for a standard MMIO protocol.
|
|
207
|
+
class MMIOSysInfo final : public SysInfo {
|
|
208
|
+
public:
|
|
209
|
+
MMIOSysInfo(const MMIO *);
|
|
210
|
+
|
|
211
|
+
/// Get the ESI version number to check version compatibility.
|
|
212
|
+
uint32_t getEsiVersion() const override;
|
|
213
|
+
|
|
214
|
+
/// Get the current cycle count of the accelerator system's core clock.
|
|
215
|
+
std::optional<uint64_t> getCycleCount() const override;
|
|
216
|
+
/// Get the "core" clock frequency of the accelerator system in Hz. Returns
|
|
217
|
+
/// nullopt if the accelerator does not provide this information.
|
|
218
|
+
std::optional<uint64_t> getCoreClockFrequency() const override;
|
|
219
|
+
|
|
220
|
+
/// Return the zlib compressed JSON system manifest.
|
|
221
|
+
virtual std::vector<uint8_t> getCompressedManifest() const override;
|
|
222
|
+
|
|
223
|
+
private:
|
|
224
|
+
const MMIO *mmio;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
class HostMem : public Service {
|
|
228
|
+
public:
|
|
229
|
+
static constexpr std::string_view StdName = "esi.service.std.hostmem";
|
|
230
|
+
|
|
231
|
+
using Service::Service;
|
|
232
|
+
virtual ~HostMem() = default;
|
|
233
|
+
virtual std::string getServiceSymbol() const override;
|
|
234
|
+
|
|
235
|
+
/// RAII memory region for host memory. Automatically frees the memory when
|
|
236
|
+
/// deconstructed.
|
|
237
|
+
struct HostMemRegion {
|
|
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 functon 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
|
+
/// Flush the memory region to ensure that the device sees the latest
|
|
247
|
+
/// contents. Because some platforms require it before DMA transactions, it
|
|
248
|
+
/// is recommended to call this before any DMA on all platforms. On
|
|
249
|
+
/// platforms which don't require it, it is a cheap no-op virtual method
|
|
250
|
+
/// call.
|
|
251
|
+
virtual void flush() {}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/// Options for allocating host memory.
|
|
255
|
+
struct Options {
|
|
256
|
+
bool writeable = false;
|
|
257
|
+
bool useLargePages = false;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/// In cases where necessary, enable host memory services.
|
|
261
|
+
virtual void start() {}
|
|
262
|
+
|
|
263
|
+
/// Allocate a region of host memory in accelerator accessible address space.
|
|
264
|
+
virtual std::unique_ptr<HostMemRegion> allocate(std::size_t size,
|
|
265
|
+
Options opts) const = 0;
|
|
266
|
+
|
|
267
|
+
/// Try to make a region of host memory accessible to the accelerator. Returns
|
|
268
|
+
/// 'false' on failure. It is optional for an accelerator backend to implement
|
|
269
|
+
/// this, so client code needs to have a fallback for when this returns
|
|
270
|
+
/// 'false'. On success, it is the client's responsibility to ensure that the
|
|
271
|
+
/// memory eventually gets unmapped.
|
|
272
|
+
virtual bool mapMemory(void *ptr, std::size_t size, Options opts) const {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
/// Unmap memory which was previously mapped with 'mapMemory'. Undefined
|
|
276
|
+
/// behavior when called with a pointer which was not previously mapped.
|
|
277
|
+
virtual void unmapMemory(void *ptr) const {}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/// Service for calling functions.
|
|
281
|
+
class FuncService : public Service {
|
|
282
|
+
public:
|
|
283
|
+
FuncService(AppIDPath id, AcceleratorConnection &, ServiceImplDetails details,
|
|
284
|
+
HWClientDetails clients);
|
|
285
|
+
|
|
286
|
+
virtual std::string getServiceSymbol() const override;
|
|
287
|
+
virtual BundlePort *getPort(AppIDPath id,
|
|
288
|
+
const BundleType *type) const override;
|
|
289
|
+
|
|
290
|
+
/// A function call which gets attached to a service port.
|
|
291
|
+
class Function : public ServicePort {
|
|
292
|
+
friend class FuncService;
|
|
293
|
+
using ServicePort::ServicePort;
|
|
294
|
+
|
|
295
|
+
public:
|
|
296
|
+
static Function *get(AppID id, BundleType *type, WriteChannelPort &arg,
|
|
297
|
+
ReadChannelPort &result);
|
|
298
|
+
|
|
299
|
+
void connect();
|
|
300
|
+
std::future<MessageData> call(const MessageData &arg);
|
|
301
|
+
|
|
302
|
+
const esi::Type *getArgType() const {
|
|
303
|
+
return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
|
|
304
|
+
->getInner();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const esi::Type *getResultType() const {
|
|
308
|
+
return dynamic_cast<const ChannelType *>(
|
|
309
|
+
type->findChannel("result").first)
|
|
310
|
+
->getInner();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
virtual std::optional<std::string>
|
|
314
|
+
toString(bool oneLine = false) const override {
|
|
315
|
+
const esi::Type *argType = getArgType();
|
|
316
|
+
const esi::Type *resultType = getResultType();
|
|
317
|
+
return "function " + resultType->toString(oneLine) + "(" +
|
|
318
|
+
argType->toString(oneLine) + ")";
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private:
|
|
322
|
+
std::mutex callMutex;
|
|
323
|
+
WriteChannelPort *arg;
|
|
324
|
+
ReadChannelPort *result;
|
|
325
|
+
bool connected = false;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
private:
|
|
329
|
+
std::string symbol;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/// Service for servicing function calls from the accelerator.
|
|
333
|
+
class CallService : public Service {
|
|
334
|
+
public:
|
|
335
|
+
CallService(AcceleratorConnection &acc, AppIDPath id,
|
|
336
|
+
ServiceImplDetails details);
|
|
337
|
+
|
|
338
|
+
virtual std::string getServiceSymbol() const override;
|
|
339
|
+
virtual BundlePort *getPort(AppIDPath id,
|
|
340
|
+
const BundleType *type) const override;
|
|
341
|
+
|
|
342
|
+
/// A function call which gets attached to a service port.
|
|
343
|
+
class Callback : public ServicePort {
|
|
344
|
+
friend class CallService;
|
|
345
|
+
Callback(AcceleratorConnection &acc, AppID id, const BundleType *,
|
|
346
|
+
PortMap channels);
|
|
347
|
+
|
|
348
|
+
public:
|
|
349
|
+
static Callback *get(AcceleratorConnection &acc, AppID id,
|
|
350
|
+
const BundleType *type, WriteChannelPort &result,
|
|
351
|
+
ReadChannelPort &arg);
|
|
352
|
+
|
|
353
|
+
/// Connect a callback to code which will be executed when the accelerator
|
|
354
|
+
/// invokes the callback. The 'quick' flag indicates that the callback is
|
|
355
|
+
/// sufficiently fast that it could be called in the same thread as the
|
|
356
|
+
/// port callback.
|
|
357
|
+
void connect(std::function<MessageData(const MessageData &)> callback,
|
|
358
|
+
bool quick = false);
|
|
359
|
+
|
|
360
|
+
const esi::Type *getArgType() const {
|
|
361
|
+
return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
|
|
362
|
+
->getInner();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const esi::Type *getResultType() const {
|
|
366
|
+
return dynamic_cast<const ChannelType *>(
|
|
367
|
+
type->findChannel("result").first)
|
|
368
|
+
->getInner();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
virtual std::optional<std::string>
|
|
372
|
+
toString(bool oneLine = false) const override {
|
|
373
|
+
const esi::Type *argType = getArgType();
|
|
374
|
+
const esi::Type *resultType = getResultType();
|
|
375
|
+
return "callback " + resultType->toString(oneLine) + "(" +
|
|
376
|
+
argType->toString(oneLine) + ")";
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
private:
|
|
380
|
+
ReadChannelPort *arg;
|
|
381
|
+
WriteChannelPort *result;
|
|
382
|
+
AcceleratorConnection &acc;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
private:
|
|
386
|
+
std::string symbol;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
/// Service for retrieving telemetry data from the accelerator.
|
|
390
|
+
class TelemetryService : public Service {
|
|
391
|
+
public:
|
|
392
|
+
static constexpr std::string_view StdName = "esi.service.std.telemetry";
|
|
393
|
+
|
|
394
|
+
TelemetryService(AppIDPath id, AcceleratorConnection &,
|
|
395
|
+
ServiceImplDetails details, HWClientDetails clients);
|
|
396
|
+
|
|
397
|
+
virtual std::string getServiceSymbol() const override;
|
|
398
|
+
virtual BundlePort *getPort(AppIDPath id,
|
|
399
|
+
const BundleType *type) const override;
|
|
400
|
+
virtual Service *getChildService(Service::Type service, AppIDPath id = {},
|
|
401
|
+
std::string implName = {},
|
|
402
|
+
ServiceImplDetails details = {},
|
|
403
|
+
HWClientDetails clients = {}) override;
|
|
404
|
+
MMIO::MMIORegion *getMMIORegion() const;
|
|
405
|
+
|
|
406
|
+
/// A telemetry port which gets attached to a service port.
|
|
407
|
+
class Metric : public ServicePort {
|
|
408
|
+
friend class TelemetryService;
|
|
409
|
+
Metric(AppID id, const BundleType *type, PortMap channels,
|
|
410
|
+
const TelemetryService *telemetryService,
|
|
411
|
+
std::optional<uint64_t> offset);
|
|
412
|
+
|
|
413
|
+
public:
|
|
414
|
+
void connect();
|
|
415
|
+
std::future<MessageData> read();
|
|
416
|
+
uint64_t readInt();
|
|
417
|
+
|
|
418
|
+
virtual std::optional<std::string>
|
|
419
|
+
toString(bool oneLine = false) const override {
|
|
420
|
+
const esi::Type *dataType =
|
|
421
|
+
dynamic_cast<const ChannelType *>(type->findChannel("data").first)
|
|
422
|
+
->getInner();
|
|
423
|
+
return "telemetry " + dataType->toString(oneLine);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private:
|
|
427
|
+
const TelemetryService *telemetryService;
|
|
428
|
+
MMIO::MMIORegion *mmio;
|
|
429
|
+
std::optional<uint64_t> offset;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
std::map<AppIDPath, Metric *> getTelemetryPorts() {
|
|
433
|
+
std::map<AppIDPath, Metric *> ports;
|
|
434
|
+
getTelemetryPorts(ports);
|
|
435
|
+
return ports;
|
|
436
|
+
}
|
|
437
|
+
void getTelemetryPorts(std::map<AppIDPath, Metric *> &ports);
|
|
438
|
+
|
|
439
|
+
private:
|
|
440
|
+
AppIDPath id;
|
|
441
|
+
mutable MMIO::MMIORegion *mmio;
|
|
442
|
+
std::map<AppIDPath, uint64_t> portAddressAssignments;
|
|
443
|
+
mutable std::map<AppIDPath, Metric *> telemetryPorts;
|
|
444
|
+
std::list<TelemetryService *> children;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
/// Registry of services which can be instantiated directly by the Accelerator
|
|
448
|
+
/// class if the backend doesn't do anything special with a service.
|
|
449
|
+
class ServiceRegistry {
|
|
450
|
+
public:
|
|
451
|
+
/// Create a service instance from the given details. Returns nullptr if
|
|
452
|
+
/// 'svcType' isn't registered.
|
|
453
|
+
static Service *createService(AcceleratorConnection *acc,
|
|
454
|
+
Service::Type svcType, AppIDPath id,
|
|
455
|
+
std::string implName,
|
|
456
|
+
ServiceImplDetails details,
|
|
457
|
+
HWClientDetails clients);
|
|
458
|
+
|
|
459
|
+
/// Resolve a service type from a string. If the string isn't recognized,
|
|
460
|
+
/// default to CustomService.
|
|
461
|
+
static Service::Type lookupServiceType(const std::string &);
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
} // namespace services
|
|
465
|
+
} // namespace esi
|
|
466
|
+
|
|
467
|
+
#endif // ESI_RUNTIME_SERVICES_H
|