Program Listing for File SendSocket.hpp

Return to documentation for file (BackendLibfabric/SendSocket.hpp)

#ifndef NETIO3BACKEND_BACKENDLIBFABRIC_SENDSOCKET_HPP
#define NETIO3BACKEND_BACKENDLIBFABRIC_SENDSOCKET_HPP

#include <tbb/concurrent_queue.h>

#include <tracy/Tracy.hpp>

#include <rdma/fabric.h>
#include <rdma/fi_domain.h>

#include "BaseSocket.hpp"
#include "Helpers.hpp"
#include "netio3-backend/Netio3Backend.hpp"

namespace netio3::libfabric {
  class SendSocket : public BaseSocket
  {
  public:
    [[nodiscard]] const EndPointAddress& get_address() const { return m_addr; }

  protected:
    SendSocket(EndPointAddress address, NetworkMode mode, fid_fabric* fabric, fid_domain* domain);

    void init();

    [[nodiscard]] NetioStatus send_data(iovec data, fid_mr* mr, std::uint64_t key) const
    {
      ZoneScoped;
      return send_data(std::span{&data, 1}, std::span{&mr, 1}, key);
    }

    [[nodiscard]] NetioStatus send_data(std::span<const iovec> data,
                                        std::span<fid_mr*> mrs,
                                        std::uint64_t key) const;

  private:
    [[nodiscard]] static Endpoint create_endpoint(const EndPointAddress& address,
                                                  NetworkMode mode,
                                                  fid_fabric* fabric,
                                                  fid_domain* domain);

    [[nodiscard]] static FiInfoUniquePtr get_info(const EndPointAddress& address,
                                                  NetworkMode mode);

    static void open_cq(const EndPointAddress& address, Endpoint& ep, fid_domain* domain);

    EndPointAddress m_addr;
    ConnectionParameters m_conn_parameters{};
    tbb::concurrent_queue<std::uint64_t> m_available_buffers;
  };

  template<typename SocketType>
  concept SendSocketConcept = std::derived_from<SocketType, SendSocket>;
}  // namespace netio3::libfabric

#endif  // NETIO3BACKEND_BACKENDLIBFABRIC_SENDSOCKET_HPP