|
CIRCT 24.0.0git
|
Instantiated when a backend does not know how to create a write channel. More...
#include <Ports.h>


Public Member Functions | |
| UnknownWriteChannelPort (const Type *type, std::string errmsg) | |
| void | connect (const ConnectOptions &options={}) override |
| Connect in sync mode. Throws if connected in callback mode. | |
| void | connect (DataFetchCallback fetch, WriteErrorCallback onError, const ConnectOptions &options={}) override |
| Connect in callback mode. | |
| Public Member Functions inherited from esi::WriteChannelPort | |
| ~WriteChannelPort () override | |
| Stops the default callback mode implementation, if in use, dropping a fetched message which hasn't been completely written. | |
| virtual void | disconnect () override |
| Disconnect the port. | |
| virtual bool | isConnected () const override |
| void | write (const MessageData &data) |
| A very basic blocking write API. | |
| void | write (std::unique_ptr< SegmentedMessageData > msg) |
| Write a multi-segment message. | |
| bool | tryWrite (const MessageData &data) |
| A basic non-blocking write API. | |
| bool | tryWrite (std::unique_ptr< SegmentedMessageData > &msg) |
| Non-blocking write of a multi-segment message. | |
| bool | flush () |
| Flush any buffered data. | |
| virtual void | notifyAsyncDataAvailable () |
| Notify the port that the DataFetchCallback has data again. | |
| ChannelPort (const Type *type) | |
| Public Member Functions inherited from esi::ChannelPort | |
| ChannelPort (const Type *type) | |
| virtual | ~ChannelPort () |
| bool | poll () |
| Poll for incoming data. | |
| size_t | getFrameSizeBytes () const |
| Get the size of each frame in bytes. | |
| const Type * | getType () const |
| const WindowType * | getWindowType () const |
| If this port carries a windowed type, return the original WindowType (whose intoType is what getType() returns). | |
Protected Member Functions | |
| void | writeImpl (const MessageData &) override |
| Implementation for write(). Subclasses must implement this. | |
| bool | tryWriteImpl (const MessageData &) override |
| Implementation for tryWrite(). Subclasses must implement this. | |
| Protected Member Functions inherited from esi::WriteChannelPort | |
| bool | pollImpl () final |
| If the default callback mode implementation is in use, write fetched data (see connect()). | |
| virtual bool | pollWriteImpl () |
| Backend-specific polling. | |
| void | connectCallbackMode (const ConnectOptions &options) |
| For backends which override connect(DataFetchCallback, ...): check that the port is disconnected, set up message translation, call connectImpl(), and enter callback mode, in which the sync write APIs throw. | |
| const MessageData & | maybePadEmptyMessage (const MessageData &data) |
| Pad an empty payload with a single zero byte if the port type has a zero-width logical width (e.g. | |
| virtual void | writeSegmentedImpl (std::unique_ptr< SegmentedMessageData > msg) |
| Implementation for the segmented write(). | |
| virtual bool | tryWriteSegmentedImpl (std::unique_ptr< SegmentedMessageData > &msg) |
| Implementation for the segmented tryWrite(), also used by the default callback mode implementation. | |
| std::vector< MessageData > | getMessageFrames (const MessageData &data) |
| Break a message into its frames. | |
| void | translateOutgoing (const MessageData &data) |
| Translate outgoing data if the port type is a window type. | |
| Protected Member Functions inherited from esi::ChannelPort | |
| virtual void | connectImpl (const ConnectOptions &options) |
| Called by all connect methods to let backends initiate the underlying connections. | |
Protected Attributes | |
| std::string | errmsg |
| Protected Attributes inherited from esi::WriteChannelPort | |
| std::atomic< Mode > | mode = Mode::Disconnected |
| bool | translateMessages = false |
| Whether to translate outgoing data if the port type is a window type. | |
| std::vector< MessageData > | translationBuffer |
| If tryWrite cannot write all the messages of a windowed type at once, it stores them here and writes them out one by one on subsequent calls. | |
| size_t | translationBufferIdx = 0 |
| Index of the next message to write in translationBuffer. | |
| Protected Attributes inherited from esi::ChannelPort | |
| const Type * | type |
| std::unique_ptr< TranslationInfo > | translationInfo |
Additional Inherited Members | |
| Public Types inherited from esi::WriteChannelPort | |
| using | DataFetchCallback |
| Callback mode data source. | |
| using | WriteErrorCallback = std::function<void(std::exception_ptr)> |
| Callback mode error handler. | |
| Static Public Attributes inherited from esi::WriteChannelPort | |
| static constexpr size_t | kMaxAsyncWritesPerCall = 64 |
| The most messages the default callback mode implementation writes per call to notifyAsyncDataAvailable() or poll(). | |
| Protected Types inherited from esi::WriteChannelPort | |
| enum | Mode { Disconnected , Sync , Callback } |
| Indicates the current mode of the channel. More... | |
| Static Protected Attributes inherited from esi::WriteChannelPort | |
| static const MessageData | transportPad0Bytes = MessageData({0}) |
| Backing storage for maybePadEmptyMessage return so that the returned reference outlives the call. | |
Instantiated when a backend does not know how to create a write channel.
|
inline |
Definition at line 569 of file Ports.h.
References errmsg, and esi::ChannelPort::type.
|
inlineoverridevirtual |
Connect in sync mode. Throws if connected in callback mode.
Reimplemented from esi::WriteChannelPort.
|
inlineoverridevirtual |
Connect in callback mode.
Throws if already connected, if either callback is null, or if frames of a windowed message written in sync mode haven't all been sent yet (reconnect in sync mode and flush() them first). Must not be called concurrently with connect() or disconnect() on another thread. Callbacks may be invoked from any thread, but never concurrently with each other, and must return quickly. Exceptions thrown by fetch are reported to onError; those thrown by onError propagate out of whichever call invoked it (e.g. notifyAsyncDataAvailable() or poll(); the accelerator's service thread logs them). They may call notifyAsyncDataAvailable() and disconnect() (and then connect()), but must not wait on another thread which uses the port.
Default implementation: the port calls fetch and writes what it returns with tryWriteSegmentedImpl() (so backends which override that for scatter-gather support receive messages as-is), until fetch returns nullptr or the backend backpressures. It does so from notifyAsyncDataAvailable() and from poll() (e.g. called by the accelerator's service thread via AcceleratorServiceThread::addPoll()), which also retries the one fetched message the backend didn't accept. Each call writes at most kMaxAsyncWritesPerCall messages, so that it returns even if fetch always has data; poll() writes the rest. fetch is first called by the first of either after connecting. Its state is only allocated while it is in use.
Backends which override this must also override notifyAsyncDataAvailable(), uphold the callback contracts, and call connectCallbackMode().
Reimplemented from esi::WriteChannelPort.
|
inlineoverrideprotectedvirtual |
Implementation for tryWrite(). Subclasses must implement this.
Implements esi::WriteChannelPort.
Definition at line 584 of file Ports.h.
References errmsg.
|
inlineoverrideprotectedvirtual |
Implementation for write(). Subclasses must implement this.
Implements esi::WriteChannelPort.
Definition at line 581 of file Ports.h.
References errmsg.
|
protected |
Definition at line 588 of file Ports.h.
Referenced by tryWriteImpl(), UnknownWriteChannelPort(), and writeImpl().