CIRCT 24.0.0git
Loading...
Searching...
No Matches
esi::WriteChannelPort Class Referenceabstract

A ChannelPort which sends data to the accelerator. More...

#include <Ports.h>

Inheritance diagram for esi::WriteChannelPort:
Collaboration diagram for esi::WriteChannelPort:

Public Member Functions

virtual void connect (const ConnectOptions &options={}) override
 Set up a connection to the accelerator.
virtual void disconnect () override
virtual bool isConnected () const override
void write (const MessageData &data)
 A very basic blocking write API.
virtual void write (std::unique_ptr< SegmentedMessageData > msg)
 Write a multi-segment message.
bool tryWrite (const MessageData &data)
 A basic non-blocking write API.
virtual bool tryWrite (std::unique_ptr< SegmentedMessageData > &msg)
 Non-blocking write of a multi-segment message.
bool flush ()
 Flush any buffered data.
 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

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 writeImpl (const MessageData &)=0
 Implementation for write(). Subclasses must implement this.
virtual bool tryWriteImpl (const MessageData &data)=0
 Implementation for tryWrite(). Subclasses must implement this.
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 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

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

Static Protected Attributes

static const MessageData transportPad0Bytes = MessageData({0})
 Backing storage for maybePadEmptyMessage return so that the returned reference outlives the call.

Private Attributes

volatile bool connected = false

Detailed Description

A ChannelPort which sends data to the accelerator.

Definition at line 308 of file Ports.h.

Member Function Documentation

◆ ChannelPort()

ChannelPort::ChannelPort ( const Type * type)

Definition at line 117 of file Ports.cpp.

References esi::ChannelPort::type.

◆ connect()

virtual void esi::WriteChannelPort::connect ( const ConnectOptions & options = {})
inlineoverridevirtual

Set up a connection to the accelerator.

Implements esi::ChannelPort.

Reimplemented in esi::UnknownWriteChannelPort.

Definition at line 312 of file Ports.h.

Referenced by bandwidthWriteTest(), dmaWriteTest(), runLoopbackI8(), streamingAddTest(), streamingAddTranslatedTest(), and sv2cCosimserverEpRegister().

◆ disconnect()

virtual void esi::WriteChannelPort::disconnect ( )
inlineoverridevirtual

Implements esi::ChannelPort.

Definition at line 322 of file Ports.h.

References connected.

Referenced by bandwidthWriteTest(), dmaWriteTest(), streamingAddTest(), and streamingAddTranslatedTest().

◆ flush()

bool esi::WriteChannelPort::flush ( )
inline

Flush any buffered data.

Returns true if all data was flushed.

If translateMessages is false, calling flush() will immediately return true and perform no action, as there is no buffered data to flush.

Definition at line 401 of file Ports.h.

References maybePadEmptyMessage(), translationBuffer, translationBufferIdx, and tryWriteImpl().

Referenced by tryWrite().

◆ getMessageFrames()

std::vector< MessageData > WriteChannelPort::getMessageFrames ( const MessageData & data)
protected

Break a message into its frames.

Definition at line 680 of file Ports.cpp.

References assert(), esi::ChannelPort::getFrameSizeBytes(), and esi::ChannelPort::type.

◆ isConnected()

virtual bool esi::WriteChannelPort::isConnected ( ) const
inlineoverridevirtual

Implements esi::ChannelPort.

Definition at line 323 of file Ports.h.

References connected.

◆ maybePadEmptyMessage()

const MessageData & esi::WriteChannelPort::maybePadEmptyMessage ( const MessageData & data)
inlineprotected

Pad an empty payload with a single zero byte if the port type has a zero-width logical width (e.g.

VoidType). Transports (DMA engines, cosim, etc.) require every message to carry at least one byte.

Definition at line 417 of file Ports.h.

References transportPad0Bytes, and esi::ChannelPort::type.

Referenced by flush(), tryWrite(), and write().

◆ translateOutgoing()

void WriteChannelPort::translateOutgoing ( const MessageData & data)
protected

Translate outgoing data if the port type is a window type.

Append the new message 'chunks' to translationBuffer.

Definition at line 586 of file Ports.cpp.

References assert(), translationBuffer, and esi::ChannelPort::translationInfo.

Referenced by tryWrite(), and write().

◆ tryWrite() [1/2]

bool esi::WriteChannelPort::tryWrite ( const MessageData & data)
inline

A basic non-blocking write API.

Returns true if any of the data was sent; false means none of it was, and the write should be retried. If the data type is a window a 'true' return does not indicate that the message has been completely written. The 'flush' method can be used to check that the entire buffer has been written. It is invalid for backends to always return false (i.e. backends must eventually ensure that writes may succeed).

Definition at line 358 of file Ports.h.

References assert(), flush(), maybePadEmptyMessage(), translateMessages, translateOutgoing(), translationBuffer, translationBufferIdx, and tryWriteImpl().

Referenced by dmaWriteTest(), NB_MODULE(), sv2cCosimserverEpTryPut(), and tryWrite().

◆ tryWrite() [2/2]

virtual bool esi::WriteChannelPort::tryWrite ( std::unique_ptr< SegmentedMessageData > & msg)
inlinevirtual

Non-blocking write of a multi-segment message.

On success, takes ownership of msg (leaving it null) and returns true. On failure, returns false and leaves msg untouched so the caller can retry with the same message. Same completion semantics as tryWrite(const MessageData &). Default flattens and calls the regular tryWrite(). Backends override for scatter-gather / chunked-DMA support.

Definition at line 387 of file Ports.h.

References tryWrite().

◆ tryWriteImpl()

virtual bool esi::WriteChannelPort::tryWriteImpl ( const MessageData & data)
protectedpure virtual

Implementation for tryWrite(). Subclasses must implement this.

Implemented in esi::UnknownWriteChannelPort.

Referenced by flush(), and tryWrite().

◆ write() [1/2]

void esi::WriteChannelPort::write ( const MessageData & data)
inline

A very basic blocking write API.

Will likely change for performance reasons.

Definition at line 327 of file Ports.h.

References assert(), maybePadEmptyMessage(), translateMessages, translateOutgoing(), translationBuffer, and writeImpl().

Referenced by bandwidthWriteTest(), NB_MODULE(), runLoopbackI8(), streamingAddTest(), streamingAddTranslatedTest(), and write().

◆ write() [2/2]

virtual void esi::WriteChannelPort::write ( std::unique_ptr< SegmentedMessageData > msg)
inlinevirtual

Write a multi-segment message.

Takes ownership so the backend can hold the message across partial writes / async completions. Default flattens and calls the regular write(). Backends override for scatter-gather / chunked-DMA support.

Definition at line 344 of file Ports.h.

References write().

◆ writeImpl()

virtual void esi::WriteChannelPort::writeImpl ( const MessageData & )
protectedpure virtual

Implementation for write(). Subclasses must implement this.

Implemented in esi::UnknownWriteChannelPort.

Referenced by write().

Member Data Documentation

◆ connected

◆ translateMessages

bool esi::WriteChannelPort::translateMessages = false
protected

Whether to translate outgoing data if the port type is a window type.

Set by the connect() method.

Definition at line 440 of file Ports.h.

Referenced by tryWrite(), and write().

◆ translationBuffer

std::vector<MessageData> esi::WriteChannelPort::translationBuffer
protected

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.

Definition at line 443 of file Ports.h.

Referenced by flush(), translateOutgoing(), tryWrite(), and write().

◆ translationBufferIdx

size_t esi::WriteChannelPort::translationBufferIdx = 0
protected

Index of the next message to write in translationBuffer.

Definition at line 445 of file Ports.h.

Referenced by flush(), and tryWrite().

◆ transportPad0Bytes

const MessageData esi::WriteChannelPort::transportPad0Bytes = MessageData({0})
inlinestaticprotected

Backing storage for maybePadEmptyMessage return so that the returned reference outlives the call.

Definition at line 425 of file Ports.h.

Referenced by maybePadEmptyMessage().


The documentation for this class was generated from the following files: