CIRCT
19.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 void | connect (std::function< bool(MessageData)> callback) |
virtual void | connect () override |
Connect to the channel in polling mode. More... | |
virtual std::future< MessageData > | readAsync () |
Asynchronous read. More... | |
virtual void | read (MessageData &outData) |
Specify a buffer to read into. More... | |
void | setMaxDataQueueMsgs (uint64_t maxMsgs) |
Set maximum number of messages to store in the dataQueue. More... | |
![]() | |
ChannelPort (const Type *type) | |
virtual | ~ChannelPort () |
const Type * | getType () const |
Static Public Attributes | |
static constexpr uint64_t | DefaultMaxDataQueueMsgs = 32 |
Default max data queue size set at connect time. More... | |
Protected Types | |
enum | Mode { Disconnected , Callback , Polling } |
Indicates the current mode of the channel. More... | |
Protected Attributes | |
Mode | mode |
std::function< bool(MessageData)> | callback |
Backends call this callback when new data is available. More... | |
std::mutex | pollingM |
Mutex to protect the two queues used for polling. More... | |
std::queue< MessageData > | dataQueue |
Store incoming data here if there are no outstanding promises to be fulfilled. More... | |
uint64_t | maxDataQueueMsgs |
Maximum number of messages to store in dataQueue. 0 means no limit. More... | |
std::queue< std::promise< MessageData > > | promiseQueue |
Promises to be fulfilled when data is available. More... | |
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.
Reimplemented from esi::ChannelPort.
Definition at line 52 of file Ports.cpp.
References assert(), callback, esi::ChannelPort::connect(), dataQueue, DefaultMaxDataQueueMsgs, maxDataQueueMsgs, mode, pollingM, and promiseQueue.
|
virtual |
Definition at line 44 of file Ports.cpp.
References callback, esi::ChannelPort::connect(), and mode.
|
inlineoverridevirtual |
|
inlinevirtual |
Specify a buffer to read into.
Blocking. Basic API, will likely change for performance and functionality reasons.
Definition at line 100 of file Ports.h.
References readAsync().
|
virtual |
Asynchronous read.
Definition at line 76 of file Ports.cpp.
References assert(), dataQueue, mode, pollingM, and promiseQueue.
Referenced by PYBIND11_MODULE(), read(), sv2cCosimserverEpRegister(), and sv2cCosimserverEpTryGet().
|
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.
Definition at line 109 of file Ports.h.
References maxDataQueueMsgs.
|
protected |
|
protected |
Store incoming data here if there are no outstanding promises to be fulfilled.
Definition at line 127 of file Ports.h.
Referenced by connect(), and readAsync().
|
staticconstexpr |
|
protected |
Maximum number of messages to store in dataQueue. 0 means no limit.
Definition at line 129 of file Ports.h.
Referenced by connect(), and setMaxDataQueueMsgs().
|
protected |
Definition at line 114 of file Ports.h.
Referenced by connect(), disconnect(), and readAsync().
|
protected |
Mutex to protect the two queues used for polling.
Definition at line 124 of file Ports.h.
Referenced by connect(), and readAsync().
|
protected |
Promises to be fulfilled when data is available.
Definition at line 131 of file Ports.h.
Referenced by connect(), and readAsync().