CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
esi::ReadChannelPort Class Reference

A ChannelPort which reads data from the accelerator. More...

#include <Ports.h>

Inheritance diagram for esi::ReadChannelPort:
Inheritance graph
[legend]
Collaboration diagram for esi::ReadChannelPort:
Collaboration graph
[legend]

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< MessageDatareadAsync ()
 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 TypegetType () 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< MessageDatadataQueue
 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 Typetype
 
std::unique_ptr< TranslationInfotranslationInfo
 

Detailed Description

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.

Definition at line 318 of file Ports.h.

Member Enumeration Documentation

◆ Mode

Indicates the current mode of the channel.

Enumerator
Disconnected 
Callback 
Polling 

Definition at line 374 of file Ports.h.

Constructor & Destructor Documentation

◆ ReadChannelPort()

esi::ReadChannelPort::ReadChannelPort ( const Type type)
inline

Definition at line 321 of file Ports.h.

Member Function Documentation

◆ connect() [1/2]

void ReadChannelPort::connect ( const ConnectOptions options = {})
overridevirtual

◆ connect() [2/2]

void ReadChannelPort::connect ( std::function< bool(MessageData)>  callback,
const ConnectOptions options = {} 
)
virtual

◆ disconnect()

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

Implements esi::ChannelPort.

Definition at line 323 of file Ports.h.

References Disconnected, and mode.

Referenced by dmaReadTest(), streamingAddTest(), and streamingAddTranslatedTest().

◆ isConnected()

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

Implements esi::ChannelPort.

Definition at line 324 of file Ports.h.

References Disconnected, and mode.

◆ read()

virtual void esi::ReadChannelPort::read ( MessageData outData)
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().

◆ readAsync()

std::future< MessageData > ReadChannelPort::readAsync ( )
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().

◆ resetTranslationState()

void ReadChannelPort::resetTranslationState ( )
protected

Reset translation state buffers and indices.

Definition at line 62 of file Ports.cpp.

References accumulatingListData, listDataBuffer, nextFrameIndex, and translationBuffer.

Referenced by connect(), and connect().

◆ setMaxDataQueueMsgs()

void esi::ReadChannelPort::setMaxDataQueueMsgs ( uint64_t  maxMsgs)
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.

◆ translateIncoming()

bool ReadChannelPort::translateIncoming ( MessageData data)
protected

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

Returns true if the message has been completely received.

Definition at line 364 of file Ports.cpp.

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

Referenced by connect(), and connect().

Member Data Documentation

◆ accumulatingListData

bool esi::ReadChannelPort::accumulatingListData = false
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().

◆ callback

std::function<bool(MessageData)> esi::ReadChannelPort::callback
protected

Backends call this callback when new data is available.

Definition at line 378 of file Ports.h.

Referenced by connect(), and connect().

◆ dataQueue

std::queue<MessageData> esi::ReadChannelPort::dataQueue
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().

◆ DefaultMaxDataQueueMsgs

constexpr uint64_t esi::ReadChannelPort::DefaultMaxDataQueueMsgs = 32
staticconstexpr

Default max data queue size set at connect time.

Definition at line 348 of file Ports.h.

Referenced by connect().

◆ listDataBuffer

std::vector<uint8_t> esi::ReadChannelPort::listDataBuffer
protected

For list fields: accumulated list data across frames.

Definition at line 385 of file Ports.h.

Referenced by resetTranslationState().

◆ maxDataQueueMsgs

uint64_t esi::ReadChannelPort::maxDataQueueMsgs
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().

◆ mode

volatile Mode esi::ReadChannelPort::mode
protected

Definition at line 375 of file Ports.h.

Referenced by connect(), connect(), disconnect(), isConnected(), and readAsync().

◆ nextFrameIndex

size_t esi::ReadChannelPort::nextFrameIndex = 0
protected

Index of the next expected frame (for multi-frame windows).

Definition at line 383 of file Ports.h.

Referenced by resetTranslationState().

◆ pollingM

std::mutex esi::ReadChannelPort::pollingM
protected

Mutex to protect the two queues used for polling.

Definition at line 399 of file Ports.h.

Referenced by connect(), and readAsync().

◆ promiseQueue

std::queue<std::promise<MessageData> > esi::ReadChannelPort::promiseQueue
protected

Promises to be fulfilled when data is available.

Definition at line 406 of file Ports.h.

Referenced by connect(), and readAsync().

◆ translationBuffer

std::vector<uint8_t> esi::ReadChannelPort::translationBuffer
protected

Window translation support.

Definition at line 381 of file Ports.h.

Referenced by connect(), connect(), and resetTranslationState().


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