|
MXL : Media eXchange Layer
MXL
|
RAII Wrapper around a libfabric endpoint (fi_ep). More...
#include <Endpoint.hpp>
Public Types | |
| using | Id = std::uintptr_t |
| An id type that can be used to reference this endpoint from completions and events. | |
Public Member Functions | |
| void | accept () |
| Accept an incoming connection. | |
| std::shared_ptr< AddressVector > | addressVector () const |
| Get the associated addres vector. | |
| void | bind (std::shared_ptr< AddressVector > av) |
| Bind the endpoint to an address vector. | |
| void | bind (std::shared_ptr< CompletionQueue > cq, std::uint64_t flags) |
| Bind the endpoint to a completion queue. | |
| void | bind (std::shared_ptr< EventQueue > eq) |
| Bind the endpoint to an event queue. | |
| std::shared_ptr< CompletionQueue > | completionQueue () const |
| Get the associated completion queue. | |
| void | connect (RawFabricAddress const &addr) |
| Initiate a connection to a remote (passive) endpoint. | |
| std::shared_ptr< Domain > | domain () const |
| Get the domain that the endpoint has beed created on. | |
| void | enable () |
| This call transitions the endpoint into an enabled state. | |
| Endpoint (Endpoint &&) noexcept | |
| Endpoint (Endpoint const &)=delete | |
| std::shared_ptr< EventQueue > | eventQueue () const |
| Get the assiociated event queue. | |
| Id | id () const noexcept |
| Get the id of this endpoint. | |
| FabricInfoView | info () const noexcept |
| Get the fabric information passed to Endpoint::create() initially. | |
| RawFabricAddress | localAddress () const |
| Endpoint & | operator= (Endpoint &&) |
| void | operator= (Endpoint const &)=delete |
| ::fid_ep const * | raw () const noexcept |
| Get the raw libfabric handle to this endpoint. | |
| ::fid_ep * | raw () noexcept |
| Get the raw libfabric handle to this 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. | |
| void | recv (LocalRegion region) const |
| Push a recv work request to the endpoint work queue. | |
| void | shutdown () |
| Initiate a graceful shutdown on a connection-oriented endpoint. | |
| 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. | |
| std::size_t | write (Completion::Token token, LocalRegionGroup const &localGroup, 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 scatter-gather list to the endpoint work queue. | |
| ~Endpoint () | |
| Destructor releases all resources. | |
Static Public Member Functions | |
| static constexpr Id | contextValueToId (void *contextValue) noexcept |
| Convert between Ids and context values that can be written to and read from raw libfabric queue entries and fid_t. | |
| static Endpoint | create (std::shared_ptr< Domain > domain) |
| Creates a new (active) endpoint. | |
| static Endpoint | create (std::shared_ptr< Domain > domain, FabricInfoView info) |
| Allocates (active) new endpoint. | |
| static Endpoint | create (std::shared_ptr< Domain > domain, Id id) |
| Create an (active) endpoint. | |
| static Endpoint | create (std::shared_ptr< Domain > domain, Id id, FabricInfoView) |
| Create an (active) endpoint. | |
| static Id | idFromFID (::fid_ep *) noexcept |
| Read the endpoint id from a libfabric object reference. | |
| static Id | idFromFID (::fid_t) noexcept |
| Read the endpoint id from a libfabric object reference. | |
| 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 id value. This does not perform any lookups, it just converts the types. This is a pure function and will always return the same endpoint id for the same completion token. This function enables using the endpoint id as a completion token. | |
| static constexpr void * | idToContextValue (Id id) noexcept |
| Convert between Ids and context values that can be written to and read from raw libfabric queue entries and fid_t. | |
| static Id | randomId () noexcept |
| Generate a new random endpoint id. | |
| 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 token value. This does not perform any lookups, it just converts the types. This is a pure function and will always return the same token value for the same endpoint id. This function enables using the endpoint id as a completion token. | |
Static Public Attributes | |
| static constexpr auto const | EQReadInterval = std::chrono::milliseconds(100) |
| The minimum interval at which the event queue will be polled when doing a blocking read of both (event and completion) queues. | |
Private Member Functions | |
| void | close () |
| Close the endpoint and release all resources. Called from the destructor and the move assignment operator. | |
| Endpoint (::fid_ep *raw, FabricInfoView info, std::shared_ptr< Domain > domain, std::optional< std::shared_ptr< CompletionQueue > > cq=std::nullopt, std::optional< std::shared_ptr< EventQueue > > eq=std::nullopt, std::optional< std::shared_ptr< AddressVector > > av=std::nullopt) | |
| Construct the 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. | |
Private Attributes | |
| std::optional< std::shared_ptr< AddressVector > > | _av |
| std::optional< std::shared_ptr< CompletionQueue > > | _cq |
| std::shared_ptr< Domain > | _domain |
| std::optional< std::shared_ptr< EventQueue > > | _eq |
| FabricInfo | _info |
| ::fid_ep * | _raw |
RAII Wrapper around a libfabric endpoint (fi_ep).
Definition at line 28 of file Endpoint.hpp.
| using mxl::lib::fabrics::ofi::Endpoint::Id = std::uintptr_t |
An id type that can be used to reference this endpoint from completions and events.
Definition at line 38 of file Endpoint.hpp.
| mxl::lib::fabrics::ofi::Endpoint::~Endpoint | ( | ) |
Destructor releases all resources.
If the event or completion queue have events pending that reference this endpoint, they still will be delivered, but the reference to the endpoint inside these events can no longer be used.
Definition at line 88 of file Endpoint.cpp.
|
delete |
|
noexcept |
Definition at line 121 of file Endpoint.cpp.
|
private |
Construct the endpoint.
Definition at line 93 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::accept | ( | ) |
Accept an incoming connection.
Information about the incoming connection must previously have been passed to Endpoint::create(). A successfully accepted connection request will result in the active (connecting) endpoint seeing an Event::Connected event on its associated event queue. A rejected or failed connection request will generate an error event. The error entry will provide additional details describing the reason for the failed attempt. An Event::Connected event will also be generated on the passive side for the accepting endpoint once the connection has been properly established. The fid of the FI_CONNECTED event will be that of the endpoint passed to fi_accept as opposed to the listening passive endpoint. Outbound data transfers cannot be initiated on a connection-oriented endpoint until an FI_CONNECTED event has been generated. However, receive buffers may be associated with an endpoint anytime.
Definition at line 174 of file Endpoint.cpp.
|
nodiscard |
Get the associated addres vector.
If an address vector is associated with this endpoint. Get the AV. Throws an exception if no address vector is associated with this endpoint.
Definition at line 215 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::bind | ( | std::shared_ptr< AddressVector > | av | ) |
Bind the endpoint to an address vector.
The endpoint can be bound to an address vector only once. The Endpoint object will take ownership of an instance of the shared pointer, so the address vector can not be destroyed before the endpoint.
Definition at line 162 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::bind | ( | std::shared_ptr< CompletionQueue > | cq, |
| std::uint64_t | flags ) |
Bind the endpoint to a completion queue.
The endpoint can be bound to a completion queue only once. The Endpoint object will take ownership of an instance of the shared pointer, so the queue can not be destroyed before the endpoint.
Definition at line 155 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::bind | ( | std::shared_ptr< EventQueue > | eq | ) |
Bind the endpoint to an event queue.
The endpoint can be bound to an event queue only once. The Endpoint object will take ownership of an instance of the shared pointer, so the queue can not be destroyed before the endpoint.
Definition at line 148 of file Endpoint.cpp.
|
private |
Close the endpoint and release all resources. Called from the destructor and the move assignment operator.
Definition at line 105 of file Endpoint.cpp.
|
nodiscard |
Get the associated completion queue.
If a completion queue is associated with this endpoint. Get the queue. Throws an exception if no completion queue is associated with this endpoint.
Definition at line 195 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::connect | ( | RawFabricAddress const & | addr | ) |
Initiate a connection to a remote (passive) endpoint.
This function can only be called once in the lifetime of an Endpoint. After a connection was established, A Event::Connected event will be posted to the event queue associated with this endpoint.
Definition at line 180 of file Endpoint.cpp.
|
inlinestaticnodiscardconstexprnoexcept |
Convert between Ids and context values that can be written to and read from raw libfabric queue entries and fid_t.
Definition at line 57 of file Endpoint.hpp.
Creates a new (active) endpoint.
A new random id will be chosen to identify the endpoint in completions and events.
Definition at line 51 of file Endpoint.cpp.
|
static |
Allocates (active) new endpoint.
If the endpoint is allocated in order to accept a connection request. The fabric information obtained when accepting the connection must be passed via the info parameter. A random id will be chosen to identify the endpoint in events.
Definition at line 56 of file Endpoint.cpp.
|
static |
Create an (active) endpoint.
Definition at line 78 of file Endpoint.cpp.
|
static |
Create an (active) endpoint.
If the endpoint is allocated in order to accept a connection request. The fabric information obtained when accepting the connection must be passed via the info parameter.
Definition at line 61 of file Endpoint.cpp.
|
nodiscard |
Get the domain that the endpoint has beed created on.
Definition at line 302 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::enable | ( | ) |
This call transitions the endpoint into an enabled state.
An endpoint must be enabled before it may be used to perform data transfers. Enabling an endpoint typically results in hardware resources being assigned to it. Endpoints making use of completion queues, event queues, and/or address vectors must be bound to them before being enabled.
Definition at line 169 of file Endpoint.cpp.
|
nodiscard |
Get the assiociated event queue.
If an event queue is associated with this endpoint. Get the queue. Throws an exception if no event queue is associated with this endpoint.
Definition at line 205 of file Endpoint.cpp.
|
nodiscardnoexcept |
Get the id of this endpoint.
The id can be used to reference the endpoint from completion and regular events.
Definition at line 83 of file Endpoint.cpp.
|
staticnoexcept |
Read the endpoint id from a libfabric object reference.
The result is only guaranteed to be valid if the fid refers to a libfabric endpoint that was created with Endpoint::create()
Definition at line 46 of file Endpoint.cpp.
|
staticnoexcept |
Read the endpoint id from a libfabric object reference.
The result is only guaranteed to be valid if the fid refers to a libfabric endpoint that was created with Endpoint::create()
Definition at line 41 of file Endpoint.cpp.
|
inlinestaticnodiscardconstexprnoexcept |
Convert a completion token value to an endpoint id value. Convert a completion token to an endpoint id value. This does not perform any lookups, it just converts the types. This is a pure function and will always return the same endpoint id for the same completion token. This function enables using the endpoint id as a completion token.
Definition at line 82 of file Endpoint.hpp.
|
inlinestaticnodiscardconstexprnoexcept |
Convert between Ids and context values that can be written to and read from raw libfabric queue entries and fid_t.
Definition at line 49 of file Endpoint.hpp.
|
nodiscardnoexcept |
Get the fabric information passed to Endpoint::create() initially.
Definition at line 307 of file Endpoint.cpp.
|
nodiscard |
Obtain the local fabric address for this endpoint.
Definition at line 190 of file Endpoint.cpp.
Definition at line 132 of file Endpoint.cpp.
|
delete |
|
staticnodiscardnoexcept |
Generate a new random endpoint id.
Definition at line 32 of file Endpoint.cpp.
|
nodiscardnoexcept |
Get the raw libfabric handle to this endpoint.
Definition at line 317 of file Endpoint.cpp.
|
noexcept |
Get the raw libfabric handle to this endpoint.
Definition at line 312 of file Endpoint.cpp.
| std::pair< std::optional< Completion >, std::optional< Event > > mxl::lib::fabrics::ofi::Endpoint::readQueues | ( | ) |
Do a non-blocking read of both the event and completion queue associated with this endpoint.
Definition at line 224 of file Endpoint.cpp.
| std::pair< std::optional< Completion >, std::optional< Event > > mxl::lib::fabrics::ofi::Endpoint::readQueuesBlocking | ( | std::chrono::steady_clock::duration | timeout | ) |
Do a combined blocking read of both the event and completion queue associated with this endpoint.
This function will do a non-blocking read of the event queue in an interval of 100ms and block on the completion queue the rest of the time.
Definition at line 242 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::recv | ( | LocalRegion | region | ) | const |
Push a recv work request to the endpoint work queue.
If this is used to receive media data, a bounce buffer shall be used to receive the data into, following by a post completion operation to copy the data back to the media buffers. This is required, because we only know the identification of the receive media data once it is received. In the MXL context, this function can also be used to receive immediate data if domain function usingRecvBufForCqData returns true.
| region | Source memory region to receive data into |
Definition at line 398 of file Endpoint.cpp.
| void mxl::lib::fabrics::ofi::Endpoint::shutdown | ( | ) |
Initiate a graceful shutdown on a connection-oriented endpoint.
When the shutdown is complete, a Event::Shutdown event will be posted to the event queue associated with this endpoint.
Definition at line 185 of file Endpoint.cpp.
|
inlinestaticnodiscardconstexprnoexcept |
Convert an endpoint id value to a completion token value. Convert an endpoint id to a completion token value. This does not perform any lookups, it just converts the types. This is a pure function and will always return the same token value for the same endpoint id. This function enables using the endpoint id as a completion token.
Definition at line 69 of file Endpoint.hpp.
|
nodiscard |
Push a remote write work request of a single contiguous buffer to the endpoint work queue.
When the write is complete, a Completion::Data will be pushed to the completion queue associated with the endpoint. Before a write request can be made, the endpoint must have been enabled.
| token | Completion token to associate with the write operation |
| local | Source memory region to write from |
| remoteGroup | Destination memory regions to write to |
| destAddr | The destination address of the target endpoint. This is unused when using connected endpoints. |
| immData | 64 bits of user data that will be available in the completion entry associated with this transfer. |
Definition at line 343 of file Endpoint.cpp.
|
nodiscard |
Push a remote write work request of a scatter-gather list to the endpoint work queue.
When the write is complete, a Completion::Data will be pushed to the completion queue associated with the endpoint. Before a write request can be made, the endpoint must have been enabled.
| token | Completion token to associate with the write operation |
| localGroup | Source memory regions to write from (scatter-gather version) |
| remoteGroup | Destination memory regions to write to |
| destAddr | The destination address of the target endpoint. This is unused when using connected endpoints. |
| 64 | bits of user data that will be available in the completion entry associated with this transfer. |
Definition at line 356 of file Endpoint.cpp.
|
private |
Internal implementation of the remote write request.
Definition at line 322 of file Endpoint.cpp.
|
private |
Address vector lives here after Endpoint::bind()
Definition at line 327 of file Endpoint.hpp.
|
private |
Completion queue lives here after Endpoint::bind()
Definition at line 325 of file Endpoint.hpp.
|
private |
Domain in which the endpoint was created
Definition at line 323 of file Endpoint.hpp.
|
private |
Event queue lives here after Endpoint::bind()
Definition at line 326 of file Endpoint.hpp.
|
private |
Info passed via Endpoint::create()
Definition at line 322 of file Endpoint.hpp.
|
private |
Raw resource reference
Definition at line 321 of file Endpoint.hpp.
|
staticconstexpr |
The minimum interval at which the event queue will be polled when doing a blocking read of both (event and completion) queues.
Definition at line 34 of file Endpoint.hpp.