CIRCT 23.0.0git
Loading...
Searching...
No Matches
Ports.h
Go to the documentation of this file.
1//===- Ports.h - ESI communication channels ---------------------*- 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// 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//
13//===----------------------------------------------------------------------===//
14
15// NOLINTNEXTLINE(llvm-header-guard)
16#ifndef ESI_PORTS_H
17#define ESI_PORTS_H
18
19#include "esi/Common.h"
20#include "esi/Types.h"
21#include "esi/Utils.h"
22
23#include <cassert>
24#include <future>
25
26namespace esi {
27
28class ChannelPort;
29using PortMap = std::map<std::string, ChannelPort &>;
30
31/// Unidirectional channels are the basic communication primitive between the
32/// host and accelerator. A 'ChannelPort' is the host side of a channel. It can
33/// be either read or write but not both. At this level, channels are untyped --
34/// just streams of bytes. They are not intended to be used directly by users
35/// but used by higher level APIs which add types.
37public:
38 ChannelPort(const Type *type);
39 virtual ~ChannelPort() {}
40
42 /// The buffer size is optional and should be considered merely a hint.
43 /// Individual implementations use it however they like. The unit is number
44 /// of messages of the port type.
45 std::optional<unsigned> bufferSize = std::nullopt;
46
47 /// If the type of this port is a window, translate the incoming/outgoing
48 /// data into its underlying ('into') type. For 'into' types without lists,
49 /// just re-arranges the data fields from the lowered type to the 'into'
50 /// type.
51 ///
52 /// If this option is false, no translation is done and the data is
53 /// passed through as-is. Same is true for non-windowed types.
54 ///
55 /// For messages with lists, only two types are supported:
56 /// 1) Parallel encoding includes any 'header' data with each frame. Said
57 /// header data is the same across all frames, so this encoding is
58 /// inefficient but is commonly used for on-chip streaming interfaces.
59 /// Each frame contains a 'last' field to indicate the end of the list.
60 /// In cases where 'numItems' is greater than 1, a field named
61 /// '<listField>_size' indicates the number of valid items in that
62 /// frame.
63 /// 2) Serial (bulk transfer) encoding, where a 'header' frame precedes
64 /// the list data frame. Said header frame contains a 'count' field
65 /// indicating the number of items in the list. Importantly, the
66 /// header frame is always re-transmitted after the specified number of
67 /// list items have been sent. If the 'count' field is zero, the end of
68 /// the list has been reached. If it is non-zero, the message has not
69 /// been completely transmitted and reading should continue until a
70 /// 'count' of zero is received.
71 ///
72 /// In both cases, the host-side MessageData contains the complete header
73 /// followed by the list data. In other words, header data is not duplicated
74 /// in the returned message. So for a windowed type with header fields and
75 /// a list of (x,y) coordinates, the host memory layout would be:
76 /// ```
77 /// struct ExampleList {
78 /// uint32_t headerField2; // SystemVerilog ordering
79 /// uint32_t headerField1;
80 /// size_t list_length; // Number list items
81 /// struct { uint16_t y, x; } list_data[];
82 /// }
83 /// ```
84 ///
85 /// In a parallel encoding, each frame's wire format (from hardware) is:
86 /// ```
87 /// struct ExampleListFrame {
88 /// uint8_t list_last; // Non-zero indicates last item in list
89 /// struct { uint16_t y, x; } list_data[numItems]; // SV field ordering
90 /// uint32_t headerField2; // SV struct ordering (reversed)
91 /// uint32_t headerField1;
92 /// }
93 /// ```
94 ///
95 /// Important note: for consistency, preserves SystemVerilog struct field
96 /// ordering! So it's the opposite of C struct ordering.
97 ///
98 /// Implementation status:
99 /// - Only parallel list encoding is supported.
100 /// - Fields must be byte-aligned.
101 ///
102 /// See the CIRCT documentation (or td files) for more details on windowed
103 /// messages.
104 bool translateMessage = true;
105
106 ConnectOptions(std::optional<unsigned> bufferSize = std::nullopt,
107 bool translateMessage = true)
109 };
110
111 /// Set up a connection to the accelerator.
112 virtual void connect(const ConnectOptions &options = ConnectOptions()) = 0;
113 virtual void disconnect() = 0;
114 virtual bool isConnected() const = 0;
115
116 /// Poll for incoming data. Returns true if data was read or written into a
117 /// buffer as a result of the poll. Calling the call back could (will) also
118 /// happen in that case. Some backends need this to be called periodically. In
119 /// the usual case, this will be called by a background thread, but the ESI
120 /// runtime does not want to assume that the host processes use standard
121 /// threads. If the user wants to provide their own threads, they need to call
122 /// this on each port occasionally. This is also called from the 'master' poll
123 /// method in the Accelerator class.
124 bool poll() {
125 if (isConnected())
126 return pollImpl();
127 return false;
128 }
129
130 /// Get the size of each frame in bytes. For windowed types, this is the
131 /// lowered type's width; otherwise, the port type's width.
132 size_t getFrameSizeBytes() const {
133 if (translationInfo)
134 return translationInfo->frameBytes;
136 }
137 const Type *getType() const { return type; }
138
139protected:
140 const Type *type;
141
142 /// Instructions for translating windowed types. Precomputes and optimizes a
143 /// list of copy operations.
146
147 /// Precompute and optimize the copy operations for translating frames.
148 void precomputeFrameInfo();
149
150 /// The window type being translated.
152
153 /// A copy operation for translating between frame data and the translation.
154 /// Run this during the translation.
155 struct CopyOp {
156 /// Offset in the incoming/outgoing frame data.
158 /// Offset in the translation buffer.
160 /// Number of bytes to copy.
161 size_t size;
162 };
163
164 /// Information about a list field within a frame (for parallel encoding).
165 /// Note: Currently only numItems == 1 is supported (one list element per
166 /// frame).
168 /// Name of the list field.
169 std::string fieldName;
170 /// Offset of the list data array in the frame.
172 /// Size of each list element in bytes.
174 /// Offset of the 'last' field in the frame.
176 /// Offset in the translation buffer where list length is stored.
178 /// Offset in the translation buffer where list data starts.
180 };
181
182 /// Information about each frame in the windowed type.
183 struct FrameInfo {
184 /// The total size of a frame in bytes.
186 /// Precomputed copy operations for translating this frame (non-list
187 /// fields).
188 std::vector<CopyOp> copyOps;
189 /// Information about list fields in this frame (parallel encoding).
190 /// Currently only one list field per frame is supported.
191 std::optional<ListFieldInfo> listField;
192 };
193 /// Precomputed information about each frame.
194 std::vector<FrameInfo> frames;
195 /// Size of the 'into' type in bytes (for fixed-size types).
196 /// For types with lists, this is the size of the fixed header portion.
197 size_t intoTypeBytes = 0;
198 /// Number of bytes per wire frame (from the lowered type's bit width).
199 size_t frameBytes = 0;
200 /// True if the window contains a list field (variable-size message).
201 bool hasListField = false;
202 };
203 std::unique_ptr<TranslationInfo> translationInfo;
204
205 /// Method called by poll() to actually poll the channel if the channel is
206 /// connected.
207 virtual bool pollImpl() { return false; }
208
209 /// Called by all connect methods to let backends initiate the underlying
210 /// connections.
211 virtual void connectImpl(const ConnectOptions &options) {}
212};
213
214/// A ChannelPort which sends data to the accelerator.
216public:
218
219 virtual void connect(const ConnectOptions &options = {}) override {
220 translateMessages = options.translateMessage && translationInfo;
221 if (translationInfo)
222 translationInfo->precomputeFrameInfo();
223 connectImpl(options);
224 connected = true;
225 }
226 virtual void disconnect() override { connected = false; }
227 virtual bool isConnected() const override { return connected; }
228
229 /// A very basic blocking write API. Will likely change for performance
230 /// reasons.
231 void write(const MessageData &data) {
232 if (translateMessages) {
233 assert(translationBuffer.empty() &&
234 "Cannot call write() with pending translated messages");
235 translateOutgoing(data);
236 for (auto &msg : translationBuffer)
237 writeImpl(msg);
238 translationBuffer.clear();
239 } else {
240 writeImpl(data);
241 }
242 }
243
244 /// Write a multi-segment message. Takes ownership so the backend can hold
245 /// the message across partial writes / async completions. Default flattens
246 /// and calls the regular write(). Backends override for scatter-gather /
247 /// chunked-DMA support.
248 virtual void write(std::unique_ptr<SegmentedMessageData> msg) {
249 if (!msg)
250 throw std::runtime_error(
251 "WriteChannelPort::write: null SegmentedMessageData");
252 write(msg->toMessageData());
253 }
254
255 /// A basic non-blocking write API. Returns true if any of the data was queued
256 /// and/or sent. If the data type is a window a 'true' return does not
257 /// indicate that the message has been completely written. The 'flush' method
258 /// can be used to check that the entire buffer has been written. It is
259 /// invalid for backends to always return false (i.e. backends must eventually
260 /// ensure that writes may succeed).
261 bool tryWrite(const MessageData &data) {
262 if (translateMessages) {
263 // Do not accept a new message if there are pending messages to flush.
264 if (!flush())
265 return false;
266 assert(translationBuffer.empty() &&
267 "Translation buffer should be empty after successful flush");
268 translateOutgoing(data);
269 flush();
270 return true;
271 } else {
272 return tryWriteImpl(data);
273 }
274 }
275 /// Flush any buffered data. Returns true if all data was flushed.
276 ///
277 /// If `translateMessages` is false, calling `flush()` will immediately return
278 /// true and perform no action, as there is no buffered data to flush.
279 bool flush() {
280 while (translationBufferIdx < translationBuffer.size()) {
282 return false;
284 }
285 translationBuffer.clear();
287 return true;
288 }
289
290protected:
291 /// Implementation for write(). Subclasses must implement this.
292 virtual void writeImpl(const MessageData &) = 0;
293
294 /// Implementation for tryWrite(). Subclasses must implement this.
295 virtual bool tryWriteImpl(const MessageData &data) = 0;
296
297 /// Break a message into its frames.
298 std::vector<MessageData> getMessageFrames(const MessageData &data);
299
300 /// Whether to translate outgoing data if the port type is a window type. Set
301 /// by the connect() method.
302 bool translateMessages = false;
303 /// If tryWrite cannot write all the messages of a windowed type at once, it
304 /// stores them here and writes them out one by one on subsequent calls.
305 std::vector<MessageData> translationBuffer;
306 /// Index of the next message to write in translationBuffer.
308 /// Translate outgoing data if the port type is a window type. Append the new
309 /// message 'chunks' to translationBuffer.
310 void translateOutgoing(const MessageData &data);
311
312private:
313 volatile bool connected = false;
314};
315
316/// Instantiated when a backend does not know how to create a write channel.
318public:
321
322 void connect(const ConnectOptions &options = {}) override {
323 throw std::runtime_error(errmsg);
324 }
325
326protected:
327 void writeImpl(const MessageData &) override {
328 throw std::runtime_error(errmsg);
329 }
330 bool tryWriteImpl(const MessageData &) override {
331 throw std::runtime_error(errmsg);
332 }
333
334 std::string errmsg;
335};
336
337/// A ChannelPort which reads data from the accelerator. It has two modes:
338/// Callback and Polling which cannot be used at the same time. The mode is set
339/// at connect() time. To change the mode, disconnect() and then connect()
340/// again.
342
343public:
346 virtual void disconnect() override { mode = Mode::Disconnected; }
347 virtual bool isConnected() const override {
348 return mode != Mode::Disconnected;
349 }
350
351 //===--------------------------------------------------------------------===//
352 // Callback mode: To use a callback, connect with a callback function which
353 // will get called with incoming data. This function can be called from any
354 // thread. It shall return true to indicate that the data was consumed. False
355 // if it could not accept the data and should be tried again at some point in
356 // the future. Callback is not allowed to block and needs to execute quickly.
357 //
358 // TODO: Have the callback return something upon which the caller can check,
359 // wait, and be notified.
360 //===--------------------------------------------------------------------===//
361
362 virtual void connect(std::function<bool(MessageData)> callback,
363 const ConnectOptions &options = {});
364
365 //===--------------------------------------------------------------------===//
366 // Polling mode methods: To use futures or blocking reads, connect without any
367 // arguments. You will then be able to use readAsync() or read().
368 //===--------------------------------------------------------------------===//
369
370 /// Default max data queue size set at connect time.
371 static constexpr uint64_t DefaultMaxDataQueueMsgs = 32;
372
373 /// Connect to the channel in polling mode.
374 virtual void connect(const ConnectOptions &options = {}) override;
375
376 /// Asynchronous read.
377 virtual std::future<MessageData> readAsync();
378
379 /// Specify a buffer to read into. Blocking. Basic API, will likely change
380 /// for performance and functionality reasons.
381 virtual void read(MessageData &outData) {
382 std::future<MessageData> f = readAsync();
383 f.wait();
384 outData = std::move(f.get());
385 }
386
387 /// Set maximum number of messages to store in the dataQueue. 0 means no
388 /// limit. This is only used in polling mode and is set to default of 32 upon
389 /// connect. While it may seem redundant to have this and bufferSize, there
390 /// may be (and are) backends which have a very small amount of memory which
391 /// are accelerator accessible and want to move messages out as quickly as
392 /// possible.
393 void setMaxDataQueueMsgs(uint64_t maxMsgs) { maxDataQueueMsgs = maxMsgs; }
394
395protected:
396 /// Indicates the current mode of the channel.
398 volatile Mode mode;
399
400 /// Backends call this callback when new data is available.
401 std::function<bool(MessageData)> callback;
402
403 /// Window translation support.
404 std::vector<uint8_t> translationBuffer;
405 /// Index of the next expected frame (for multi-frame windows).
406 size_t nextFrameIndex = 0;
407 /// For list fields: accumulated list data across frames.
408 std::vector<uint8_t> listDataBuffer;
409 /// Flag to track whether we're in the middle of accumulating list data.
411 /// Reset translation state buffers and indices.
413 /// Translate incoming data if the port type is a window type. Returns true if
414 /// the message has been completely received.
415 bool translateIncoming(MessageData &data);
416
417 //===--------------------------------------------------------------------===//
418 // Polling mode members.
419 //===--------------------------------------------------------------------===//
420
421 /// Mutex to protect the two queues used for polling.
422 std::mutex pollingM;
423 /// Store incoming data here if there are no outstanding promises to be
424 /// fulfilled.
425 std::queue<MessageData> dataQueue;
426 /// Maximum number of messages to store in dataQueue. 0 means no limit.
428 /// Promises to be fulfilled when data is available.
429 std::queue<std::promise<MessageData>> promiseQueue;
430};
431
432/// Instantiated when a backend does not know how to create a read channel.
434public:
437
438 void connect(std::function<bool(MessageData)> callback,
439 const ConnectOptions &options = ConnectOptions()) override {
440 throw std::runtime_error(errmsg);
441 }
442 void connect(const ConnectOptions &options = ConnectOptions()) override {
443 throw std::runtime_error(errmsg);
444 }
445 std::future<MessageData> readAsync() override {
446 throw std::runtime_error(errmsg);
447 }
448
449protected:
450 std::string errmsg;
451};
452
453/// Services provide connections to 'bundles' -- collections of named,
454/// unidirectional communication channels. This class provides access to those
455/// ChannelPorts.
457public:
458 /// Compute the direction of a channel given the bundle direction and the
459 /// bundle port's direction.
460 static bool isWrite(BundleType::Direction bundleDir) {
461 return bundleDir == BundleType::Direction::To;
462 }
463
464 /// Construct a port.
466 virtual ~BundlePort() = default;
467
468 /// Get the ID of the port.
469 AppID getID() const { return id; }
470
471 /// Get access to the raw byte streams of a channel. Intended for internal
472 /// usage and binding to other languages (e.g. Python) which have their own
473 /// message serialization code. Exposed publicly as an escape hatch, but
474 /// ordinary users should not use. You have been warned.
475 WriteChannelPort &getRawWrite(const std::string &name) const;
476 ReadChannelPort &getRawRead(const std::string &name) const;
477 const PortMap &getChannels() const { return channels; }
478
479 /// Cast this Bundle port to a subclass which is actually useful. Returns
480 /// nullptr if the cast fails.
481 // TODO: this probably shouldn't be 'const', but bundle ports' user access are
482 // const. Change that.
483 template <typename T>
484 T *getAs() const {
485 return const_cast<T *>(dynamic_cast<const T *>(this));
486 }
487
488 /// Calls `poll` on all channels in the bundle and returns true if any of them
489 /// returned true.
490 bool poll() {
491 bool result = false;
492 for (auto &channel : channels)
493 result |= channel.second.poll();
494 return result;
495 }
496
497protected:
501};
502
503} // namespace esi
504
505#endif // ESI_PORTS_H
assert(baseType &&"element must be base type")
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
Definition Ports.h:456
virtual ~BundlePort()=default
T * getAs() const
Cast this Bundle port to a subclass which is actually useful.
Definition Ports.h:484
PortMap channels
Definition Ports.h:500
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 PortMap & getChannels() const
Definition Ports.h:477
bool poll()
Calls poll on all channels in the bundle and returns true if any of them returned true.
Definition Ports.h:490
const BundleType * type
Definition Ports.h:499
static bool isWrite(BundleType::Direction bundleDir)
Compute the direction of a channel given the bundle direction and the bundle port's direction.
Definition Ports.h:460
AppID getID() const
Get the ID of the port.
Definition Ports.h:469
Bundles represent a collection of channels.
Definition Types.h:104
Unidirectional channels are the basic communication primitive between the host and accelerator.
Definition Ports.h:36
const Type * getType() const
Definition Ports.h:137
virtual void connect(const ConnectOptions &options=ConnectOptions())=0
Set up a connection to the accelerator.
virtual void disconnect()=0
virtual bool pollImpl()
Method called by poll() to actually poll the channel if the channel is connected.
Definition Ports.h:207
const Type * type
Definition Ports.h:140
size_t getFrameSizeBytes() const
Get the size of each frame in bytes.
Definition Ports.h:132
virtual void connectImpl(const ConnectOptions &options)
Called by all connect methods to let backends initiate the underlying connections.
Definition Ports.h:211
ChannelPort(const Type *type)
Definition Ports.cpp:26
virtual ~ChannelPort()
Definition Ports.h:39
std::unique_ptr< TranslationInfo > translationInfo
Definition Ports.h:203
bool poll()
Poll for incoming data.
Definition Ports.h:124
virtual bool isConnected() const =0
A logical chunk of data representing serialized data.
Definition Common.h:113
A ChannelPort which reads data from the accelerator.
Definition Ports.h:341
volatile Mode mode
Definition Ports.h:398
virtual std::future< MessageData > readAsync()
Asynchronous read.
Definition Ports.cpp:126
size_t nextFrameIndex
Index of the next expected frame (for multi-frame windows).
Definition Ports.h:406
virtual bool isConnected() const override
Definition Ports.h:347
virtual void connect(std::function< bool(MessageData)> callback, const ConnectOptions &options={})
Definition Ports.cpp:69
std::vector< uint8_t > translationBuffer
Window translation support.
Definition Ports.h:404
std::mutex pollingM
Mutex to protect the two queues used for polling.
Definition Ports.h:422
bool accumulatingListData
Flag to track whether we're in the middle of accumulating list data.
Definition Ports.h:410
void resetTranslationState()
Reset translation state buffers and indices.
Definition Ports.cpp:62
std::function< bool(MessageData)> callback
Backends call this callback when new data is available.
Definition Ports.h:401
Mode
Indicates the current mode of the channel.
Definition Ports.h:397
std::queue< MessageData > dataQueue
Store incoming data here if there are no outstanding promises to be fulfilled.
Definition Ports.h:425
static constexpr uint64_t DefaultMaxDataQueueMsgs
Default max data queue size set at connect time.
Definition Ports.h:371
bool translateIncoming(MessageData &data)
Translate incoming data if the port type is a window type.
Definition Ports.cpp:376
std::queue< std::promise< MessageData > > promiseQueue
Promises to be fulfilled when data is available.
Definition Ports.h:429
void setMaxDataQueueMsgs(uint64_t maxMsgs)
Set maximum number of messages to store in the dataQueue.
Definition Ports.h:393
uint64_t maxDataQueueMsgs
Maximum number of messages to store in dataQueue. 0 means no limit.
Definition Ports.h:427
virtual void disconnect() override
Definition Ports.h:346
std::vector< uint8_t > listDataBuffer
For list fields: accumulated list data across frames.
Definition Ports.h:408
virtual void read(MessageData &outData)
Specify a buffer to read into.
Definition Ports.h:381
ReadChannelPort(const Type *type)
Definition Ports.h:344
Root class of the ESI type system.
Definition Types.h:36
virtual std::ptrdiff_t getBitWidth() const
Definition Types.h:43
Instantiated when a backend does not know how to create a read channel.
Definition Ports.h:433
void connect(std::function< bool(MessageData)> callback, const ConnectOptions &options=ConnectOptions()) override
Definition Ports.h:438
void connect(const ConnectOptions &options=ConnectOptions()) override
Connect to the channel in polling mode.
Definition Ports.h:442
std::future< MessageData > readAsync() override
Asynchronous read.
Definition Ports.h:445
UnknownReadChannelPort(const Type *type, std::string errmsg)
Definition Ports.h:435
Instantiated when a backend does not know how to create a write channel.
Definition Ports.h:317
void connect(const ConnectOptions &options={}) override
Set up a connection to the accelerator.
Definition Ports.h:322
void writeImpl(const MessageData &) override
Implementation for write(). Subclasses must implement this.
Definition Ports.h:327
UnknownWriteChannelPort(const Type *type, std::string errmsg)
Definition Ports.h:319
bool tryWriteImpl(const MessageData &) override
Implementation for tryWrite(). Subclasses must implement this.
Definition Ports.h:330
Windows represent a fixed-size sliding window over a stream of data.
Definition Types.h:314
A ChannelPort which sends data to the accelerator.
Definition Ports.h:215
virtual void write(std::unique_ptr< SegmentedMessageData > msg)
Write a multi-segment message.
Definition Ports.h:248
virtual bool isConnected() const override
Definition Ports.h:227
virtual void disconnect() override
Definition Ports.h:226
size_t translationBufferIdx
Index of the next message to write in translationBuffer.
Definition Ports.h:307
virtual bool tryWriteImpl(const MessageData &data)=0
Implementation for tryWrite(). Subclasses must implement this.
volatile bool connected
Definition Ports.h:313
bool translateMessages
Whether to translate outgoing data if the port type is a window type.
Definition Ports.h:302
void write(const MessageData &data)
A very basic blocking write API.
Definition Ports.h:231
bool flush()
Flush any buffered data.
Definition Ports.h:279
bool tryWrite(const MessageData &data)
A basic non-blocking write API.
Definition Ports.h:261
virtual void connect(const ConnectOptions &options={}) override
Set up a connection to the accelerator.
Definition Ports.h:219
void translateOutgoing(const MessageData &data)
Translate outgoing data if the port type is a window type.
Definition Ports.cpp:473
std::vector< MessageData > getMessageFrames(const MessageData &data)
Break a message into its frames.
Definition Ports.cpp:567
std::vector< MessageData > translationBuffer
If tryWrite cannot write all the messages of a windowed type at once, it stores them here and writes ...
Definition Ports.h:305
virtual void writeImpl(const MessageData &)=0
Implementation for write(). Subclasses must implement this.
uint64_t bitsToBytes(uint64_t bits)
Compute ceil(bits/8).
Definition Utils.h:101
Definition esi.py:1
std::map< std::string, ChannelPort & > PortMap
Definition Ports.h:29
ConnectOptions(std::optional< unsigned > bufferSize=std::nullopt, bool translateMessage=true)
Definition Ports.h:106
std::optional< unsigned > bufferSize
The buffer size is optional and should be considered merely a hint.
Definition Ports.h:45
bool translateMessage
If the type of this port is a window, translate the incoming/outgoing data into its underlying ('into...
Definition Ports.h:104
A copy operation for translating between frame data and the translation.
Definition Ports.h:155
size_t bufferOffset
Offset in the translation buffer.
Definition Ports.h:159
size_t frameOffset
Offset in the incoming/outgoing frame data.
Definition Ports.h:157
size_t size
Number of bytes to copy.
Definition Ports.h:161
Information about each frame in the windowed type.
Definition Ports.h:183
std::vector< CopyOp > copyOps
Precomputed copy operations for translating this frame (non-list fields).
Definition Ports.h:188
std::optional< ListFieldInfo > listField
Information about list fields in this frame (parallel encoding).
Definition Ports.h:191
size_t expectedSize
The total size of a frame in bytes.
Definition Ports.h:185
Information about a list field within a frame (for parallel encoding).
Definition Ports.h:167
size_t listLengthBufferOffset
Offset in the translation buffer where list length is stored.
Definition Ports.h:177
size_t dataOffset
Offset of the list data array in the frame.
Definition Ports.h:171
std::string fieldName
Name of the list field.
Definition Ports.h:169
size_t lastFieldOffset
Offset of the 'last' field in the frame.
Definition Ports.h:175
size_t elementSize
Size of each list element in bytes.
Definition Ports.h:173
size_t listDataBufferOffset
Offset in the translation buffer where list data starts.
Definition Ports.h:179
Instructions for translating windowed types.
Definition Ports.h:144
void precomputeFrameInfo()
Precompute and optimize the copy operations for translating frames.
Definition Ports.cpp:154
TranslationInfo(const WindowType *windowType)
Definition Ports.h:145
bool hasListField
True if the window contains a list field (variable-size message).
Definition Ports.h:201
const WindowType * windowType
The window type being translated.
Definition Ports.h:151
size_t intoTypeBytes
Size of the 'into' type in bytes (for fixed-size types).
Definition Ports.h:197
size_t frameBytes
Number of bytes per wire frame (from the lowered type's bit width).
Definition Ports.h:199
std::vector< FrameInfo > frames
Precomputed information about each frame.
Definition Ports.h:194