Class SendEndpointZeroCopy

Class Documentation

class SendEndpointZeroCopy

Represents an endpoint with zero-copy send capabilities.

This class provides functionality for sending data over the network without copying data. Therefore, two buffers are allocated: The memory region which contains the data (e.g. a DMA buffer) and the header buffer which contains the header information like the tag and other user data. Compared to buffered sending, this is necessary because the data is not copied to a buffer before sending.

The header buffer is registered as a single memory region but contains several slots that can be used to store header information. Only the relevant part is send over the network.

The key that is returned to the user on the on_send_complete callback is the same as the one which is passed to the send_data function.

Public Functions

SendEndpointZeroCopy(ActiveEndpoint &endpoint, const ConnectionParametersSendZeroCopy &connection_params, std::optional<ZeroCopyBufferManager> &shared_buffer_manager, DomainManager &domain_manager)

Constructs a SendEndpointZeroCopy object.

The constructor calls the constructor of the base class creating the endpoint. It then allocates the header buffer and registers the header buffer and the memory region specified in the connection parameters as MRs.

Throws:
  • FailedOpenActiveEndpoint – in case of a libfabric error

  • std::logic_error – if no buffers are provided

Parameters:
  • endpoint – The active endpoint object handling the connection

  • connection_params – The connection parameters containing the address of the MR

  • shared_buffer_manager – An optional shared buffer manager to use for shared buffers

  • domain_manager – The domain manager

inline auto operator<=>(const SendEndpointZeroCopy &other) const
inline const ActiveEndpoint &get_active_endpoint() const

Get the active endpoint object.

Returns:

A const reference for const objects, non const for non const objects

inline ActiveEndpoint &get_active_endpoint()
NetioStatus send_data(std::span<std::uint8_t> data, std::span<const std::uint8_t> header_data, std::uint64_t key, fi_addr_t addr = 0)

Sends an array of data without copying.

See also

send_data(std::span<const iovec> iov, std::span<const std::uint8_t>, std::uint64_t)

Parameters:
  • data – The data to send

  • header_data – The header data associated with the data

  • key – The key to be returned on completion callback

  • addr – The address of the remote peer (for connectionless endpoints)

Returns:

The status of the send operation

NetioStatus send_data(std::span<const iovec> iov, std::span<const std::uint8_t> header_data, std::uint64_t key, fi_addr_t addr = 0)

Sends an array of data without copying.

Requests a header slot to store the header data and prepend the header data to the vector of iovs before sending. This means header data will be prepended to the message. The data need to be in the registered memory region. The return value indicates whether the send operation was successful. A maximum of NUM_HEADER_SLOTS send operations can happen in parallel.

Parameters:
  • iov – The vector of iovec structures representing the data to send

  • header_data – The header data associated with the data

  • key – The key to be returned on completion callback

  • addr – The address of the remote peer (for connectionless endpoints)

Returns:

The status of the send operation

std::uint64_t release_buffer(std::uint64_t bufnum)

Marks a slot in the header buffer as available for reuse.

Parameters:

bufnum – The buffer number to release

Returns:

The key corresponding to the buffer number

std::size_t get_num_available_buffers()

Retrieves the number of available slots in the header buffer.

Returns the mininum number of available buffers since the last call to this function.

Returns:

The number of available buffers

std::vector<std::uint64_t> get_pending_sends()

Retrieves the keys of pending send operations.

To be called when the connection is closed to notify that these sends will not complete

Returns:

The keys of pending send operations