|
CIRCT 22.0.0git
|
A ChannelPort which reads data from the accelerator. More...
#include <Ports.h>


Public Member Functions | |
| ReadChannelPort (const Type *type) | |
| virtual void | disconnect () override |
| virtual bool | isConnected () const override |
| virtual void | connect (std::function< bool(MessageData)> callback, const ConnectOptions &options={}) |
| virtual void | connect (const ConnectOptions &options={}) override |
| Connect to the channel in polling mode. | |
| virtual std::future< MessageData > | readAsync () |
| Asynchronous read. | |
| virtual void | read (MessageData &outData) |
| Specify a buffer to read into. | |
| void | setMaxDataQueueMsgs (uint64_t maxMsgs) |
| Set maximum number of messages to store in the dataQueue. | |
Public Member Functions inherited from esi::ChannelPort | |
| ChannelPort (const Type *type) | |
| virtual | ~ChannelPort () |
| bool | poll () |
| Poll for incoming data. | |
| const Type * | getType () const |
Static Public Attributes | |
| static constexpr uint64_t | DefaultMaxDataQueueMsgs = 32 |
| Default max data queue size set at connect time. | |
Protected Types | |
| enum | Mode { Disconnected , Callback , Polling } |
| Indicates the current mode of the channel. More... | |
Protected Member Functions | |
| void | resetTranslationState () |
| Reset translation state buffers and indices. | |
| bool | translateIncoming (MessageData &data) |
| Translate incoming data if the port type is a window type. | |
Protected Member Functions inherited from esi::ChannelPort | |
| virtual bool | pollImpl () |
| Method called by poll() to actually poll the channel if the channel is connected. | |
| virtual void | connectImpl (const ConnectOptions &options) |
| Called by all connect methods to let backends initiate the underlying connections. | |
Protected Attributes | |
| volatile Mode | mode |
| std::function< bool(MessageData)> | callback |
| Backends call this callback when new data is available. | |
| std::vector< uint8_t > | translationBuffer |
| Window translation support. | |
| size_t | nextFrameIndex = 0 |
| Index of the next expected frame (for multi-frame windows). | |
| std::vector< uint8_t > | listDataBuffer |
| For list fields: accumulated list data across frames. | |
| bool | accumulatingListData = false |
| Flag to track whether we're in the middle of accumulating list data. | |
| std::mutex | pollingM |
| Mutex to protect the two queues used for polling. | |
| std::queue< MessageData > | dataQueue |
| Store incoming data here if there are no outstanding promises to be fulfilled. | |
| uint64_t | maxDataQueueMsgs |
| Maximum number of messages to store in dataQueue. 0 means no limit. | |
| std::queue< std::promise< MessageData > > | promiseQueue |
| Promises to be fulfilled when data is available. | |
Protected Attributes inherited from esi::ChannelPort | |
| const Type * | type |
| std::unique_ptr< TranslationInfo > | translationInfo |
A ChannelPort which reads data from the accelerator.
It has two modes: Callback and Polling which cannot be used at the same time. The mode is set at connect() time. To change the mode, disconnect() and then connect() again.
|
protected |
|
inline |
|
overridevirtual |
Connect to the channel in polling mode.
Implements esi::ChannelPort.
Reimplemented in esi::UnknownReadChannelPort.
Definition at line 90 of file Ports.cpp.
References assert(), callback, esi::ChannelPort::connectImpl(), dataQueue, DefaultMaxDataQueueMsgs, maxDataQueueMsgs, mode, Polling, pollingM, promiseQueue, resetTranslationState(), translateIncoming(), esi::ChannelPort::ConnectOptions::translateMessage, translationBuffer, and esi::ChannelPort::translationInfo.
|
virtual |
Reimplemented in esi::UnknownReadChannelPort.
Definition at line 69 of file Ports.cpp.
References Callback, callback, esi::ChannelPort::connectImpl(), Disconnected, mode, resetTranslationState(), translateIncoming(), esi::ChannelPort::ConnectOptions::translateMessage, translationBuffer, and esi::ChannelPort::translationInfo.
Referenced by bandwidthReadTest(), dmaReadTest(), streamingAddTest(), streamingAddTranslatedTest(), and sv2cCosimserverEpRegister().
|
inlineoverridevirtual |
Implements esi::ChannelPort.
Definition at line 323 of file Ports.h.
References Disconnected, and mode.
Referenced by dmaReadTest(), streamingAddTest(), and streamingAddTranslatedTest().
|
inlineoverridevirtual |
Implements esi::ChannelPort.
Definition at line 324 of file Ports.h.
References Disconnected, and mode.
|
inlinevirtual |
Specify a buffer to read into.
Blocking. Basic API, will likely change for performance and functionality reasons.
Definition at line 358 of file Ports.h.
References readAsync().
Referenced by bandwidthReadTest(), dmaReadTest(), streamingAddTest(), and streamingAddTranslatedTest().
|
virtual |
Asynchronous read.
Reimplemented in esi::UnknownReadChannelPort.
Definition at line 126 of file Ports.cpp.
References assert(), Callback, dataQueue, mode, pollingM, and promiseQueue.
Referenced by NB_MODULE(), read(), sv2cCosimserverEpRegister(), and sv2cCosimserverEpTryGet().
|
protected |
Reset translation state buffers and indices.
Definition at line 62 of file Ports.cpp.
References accumulatingListData, listDataBuffer, nextFrameIndex, and translationBuffer.
|
inline |
Set maximum number of messages to store in the dataQueue.
0 means no limit. This is only used in polling mode and is set to default of 32 upon connect. While it may seem redundant to have this and bufferSize, there may be (and are) backends which have a very small amount of memory which are accelerator accessible and want to move messages out as quickly as possible.
Definition at line 370 of file Ports.h.
References maxDataQueueMsgs.
|
protected |
|
protected |
Flag to track whether we're in the middle of accumulating list data.
Definition at line 387 of file Ports.h.
Referenced by resetTranslationState().
|
protected |
|
protected |
Store incoming data here if there are no outstanding promises to be fulfilled.
Definition at line 402 of file Ports.h.
Referenced by connect(), and readAsync().
|
staticconstexpr |
|
protected |
For list fields: accumulated list data across frames.
Definition at line 385 of file Ports.h.
Referenced by resetTranslationState().
|
protected |
Maximum number of messages to store in dataQueue. 0 means no limit.
Definition at line 404 of file Ports.h.
Referenced by connect(), and setMaxDataQueueMsgs().
|
protected |
Definition at line 375 of file Ports.h.
Referenced by connect(), connect(), disconnect(), isConnected(), and readAsync().
|
protected |
Index of the next expected frame (for multi-frame windows).
Definition at line 383 of file Ports.h.
Referenced by resetTranslationState().
|
protected |
Mutex to protect the two queues used for polling.
Definition at line 399 of file Ports.h.
Referenced by connect(), and readAsync().
|
protected |
Promises to be fulfilled when data is available.
Definition at line 406 of file Ports.h.
Referenced by connect(), and readAsync().
|
protected |
Window translation support.
Definition at line 381 of file Ports.h.
Referenced by connect(), connect(), and resetTranslationState().