12#include <rdma/fabric.h>
13#include <rdma/fi_endpoint.h>
38 using Id = std::uintptr_t;
51 return std::bit_cast<void*>(
id);
59 return std::bit_cast<Endpoint::Id>(contextValue);
71 static_assert(std::is_same_v<Completion::Token, Id>,
"Completion token and endpoint id should be the same underlying type.");
84 static_assert(std::is_same_v<Completion::Token, Id>,
"Completion token and endpoint id should be the same underlying type.");
144 Id id() const noexcept;
264 std::optional<std::uint32_t> immData = std::nullopt) const;
283 ::fi_addr_t destAddr = FI_ADDR_UNSPEC, std::optional<std::uint32_t> immData = std::nullopt) const;
297 ::fid_ep*
raw() noexcept;
302 ::fid_ep const*
raw() const noexcept;
307 void writeImpl(
Completion::Token token, ::iovec const* msgIov, std::
size_t iovCount,
void** desc, ::fi_rma_iov const* rmaIov,
308 ::fi_addr_t destAddr, std::optional<std::uint32_t> immData) const;
317 std::optional<std::shared_ptr<
CompletionQueue>> cq = std::nullopt, std::optional<std::shared_ptr<
EventQueue>> eq = std::nullopt,
318 std::optional<std::shared_ptr<
AddressVector>> av = std::nullopt);
RAII Wrapper to a libfabric fi_av instance.
RAII Wrapper around a libfabric completion queue (fi_cq).
Type to represent a completion entry from a CompletionQueue.
std::uintptr_t Token
A token used to associate a completion entry with an endpoint.
RAII Wrapper around a libfabric domain (fi_domain).
std::shared_ptr< AddressVector > addressVector() const
Get the associated addres vector.
static constexpr Id idFromToken(Completion::Token token) noexcept
Convert a completion token value to an endpoint id value. Convert a completion token to an endpoint i...
::fid_ep * raw() noexcept
Get the raw libfabric handle to this endpoint.
static Id idFromFID(::fid_t) noexcept
Read the endpoint id from a libfabric object reference.
std::shared_ptr< Domain > domain() const
Get the domain that the endpoint has beed created on.
void accept()
Accept an incoming connection.
static Id randomId() noexcept
Generate a new random endpoint id.
void enable()
This call transitions the endpoint into an enabled state.
void close()
Close the endpoint and release all resources. Called from the destructor and the move assignment oper...
std::uintptr_t Id
An id type that can be used to reference this endpoint from completions and events.
RawFabricAddress localAddress() const
~Endpoint()
Destructor releases all resources.
std::optional< std::shared_ptr< AddressVector > > _av
static Endpoint create(std::shared_ptr< Domain > domain, FabricInfoView info)
Allocates (active) new endpoint.
FabricInfoView info() const noexcept
Get the fabric information passed to Endpoint::create() initially.
void operator=(Endpoint const &)=delete
Endpoint(Endpoint const &)=delete
static constexpr Id contextValueToId(void *contextValue) noexcept
Convert between Ids and context values that can be written to and read from raw libfabric queue entri...
void connect(RawFabricAddress const &addr)
Initiate a connection to a remote (passive) endpoint.
std::pair< std::optional< Completion >, std::optional< Event > > readQueues()
Do a non-blocking read of both the event and completion queue associated with this endpoint.
std::pair< std::optional< Completion >, std::optional< Event > > readQueuesBlocking(std::chrono::steady_clock::duration timeout)
Do a combined blocking read of both the event and completion queue associated with this endpoint.
std::shared_ptr< CompletionQueue > completionQueue() const
Get the associated completion queue.
std::shared_ptr< EventQueue > eventQueue() const
Get the assiociated event queue.
void bind(std::shared_ptr< EventQueue > eq)
Bind the endpoint to an event queue.
void recv(LocalRegion region) const
Push a recv work request to the endpoint work queue.
std::shared_ptr< Domain > _domain
static constexpr void * idToContextValue(Id id) noexcept
Convert between Ids and context values that can be written to and read from raw libfabric queue entri...
std::size_t write(Completion::Token token, LocalRegion const &local, RemoteRegion const &remote, ::fi_addr_t destAddr=FI_ADDR_UNSPEC, std::optional< std::uint32_t > immData=std::nullopt) const
Push a remote write work request of a single contiguous buffer to the endpoint work queue.
Id id() const noexcept
Get the id of this endpoint.
static constexpr auto const EQReadInterval
The minimum interval at which the event queue will be polled when doing a blocking read of both (even...
std::optional< std::shared_ptr< EventQueue > > _eq
std::optional< std::shared_ptr< CompletionQueue > > _cq
static constexpr Completion::Token tokenFromId(Id id) noexcept
Convert an endpoint id value to a completion token value. Convert an endpoint id to a completion toke...
void shutdown()
Initiate a graceful shutdown on a connection-oriented endpoint.
void writeImpl(Completion::Token token, ::iovec const *msgIov, std::size_t iovCount, void **desc, ::fi_rma_iov const *rmaIov, ::fi_addr_t destAddr, std::optional< std::uint32_t > immData) const
Internal implementation of the remote write request.
RAII Wrapper around a libfabric event queue (fi_eq).
Type to represent an event entry from an EventQueue.
Non-owning view of a FabricInfo. Returned when iterating over a FabricInfoList.
Represent a scatter-gather list of source memory regions used for data transfer.
Wrapper around a libfabric endpoint address.
FabricInfo(FabricInfoView) noexcept
Create an owning FabricInfo object from a non-owning view.
Represent a source memory region used for for data transfer.
Represent a remote memory region used for data transfer.
gInfo flags
Mark the grain as invalid.