Simple message passing buffers support¶
The simple message passing buffer (mpbuffer) is a hardware device that can be used to communicate among compute tiles. They are useful to build efficient or optimized message passing applications, but in most cases the message passing library is recommended as it first encapsulates the actual message passing protocol (end-to-end flow control control etc.), and second uses the available hardware accelerators which are more performant than the message passing buffers.
The message passing buffers are hardware FIFOs and the software directly writes and reads network packets into the FIFOs. There are multiple endpoints to mitigate message-dependent deadlocks. Your software can query the number of available endpoints with optimsoc_mp_simple_num_endpoints().
Software can send a packet on an endpoint using optimsoc_mp_simple_send(). To receive incoming packets, the software registers a handler for incoming messages using optimsoc_mp_simple_addhandler(). Messages from all endpoints invoke the handler, but you can register different handlers for different message classes.
Be careful with selecting classes, because they may be occupied by other hardware. If you are not sure, use class 0.
Initialize simple message passing buffers
Query the number of endpoints.
Number of endpoints
Enable the endpoint to receive packets
The hardware will only be able to receive packets after it was enabled. Hence you need to check the endpoint from the remote using optimsoc_mp_simple_enable() before calling optimsoc_mp_simple_send().
endpoint: Endpoint buffer to enable
optimsoc_mp_simple_ctready(uint32_t rank, uint16_t endpoint)¶
Check if an endpoint at another compute tile is ready
This function must be called before calling optimsoc_mp_simple_send(). The function is non-blocking, meaning that with the first call it will always return 0. It sends a message to the remote to check the state. Further calls will then return immediately if a successfull response was received, otherwise try again.
The receiver must enable the endpoint using optimsoc_mp_simple_enable().
Endpoint status (0: not ready, 1: enabled)
rank: Compute tile rank to check
endpoint: Endpoint buffer to check
optimsoc_mp_simple_send(uint16_t endpoint, size_t size, uint32_t *buf)¶
Send a message
Sends a message of size from buf.
endpoint: The endpoint to send the message on
size: Size of the message in (word-sized) flits
buf: Message buffer containint size flits
optimsoc_mp_simple_addhandler(uint8_t cls, void (*hnd)(uint32_t*, size_t))¶
Add a handler for a class of incoming messages
A message header contains a class. This class field can be used to mix different kinds of message services. For each class you are using in your system you need to add a class handler. As there is no default class handler all remaining classes are dropped.
cls: Class to register
hnd: Function pointer to handler for this class