MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
mxl::lib::fabrics::ofi::RDMTarget Class Reference

Reliable Datagram (RDM) Target implementation. More...

#include <RDMTarget.hpp>

Inheritance diagram for mxl::lib::fabrics::ofi::RDMTarget:
Collaboration diagram for mxl::lib::fabrics::ofi::RDMTarget:

Public Member Functions

virtual std::optional< Target::ReadResult > read () final
 Determine if new data can be consumed.
virtual std::optional< Target::ReadResult > readBlocking (std::chrono::steady_clock::duration timeout) final
virtual void shutdown () final
 Shut down the target gracefully. Initiates a graceful shutdown of the target and blocks until the shutdown is complete. Can throw an exception if the shutdown is not successful. If this function throws the target can now longer be used.
Public Member Functions inherited from mxl::lib::fabrics::ofi::Target
virtual ~Target ()=default

Static Public Member Functions

static std::pair< std::unique_ptr< RDMTarget >, std::unique_ptr< TargetInfo > > setup (mxlFabricsTargetConfig const &config, FabricInfoView info, TargetSetupOptions const &options)
 Set up a fresh RDMTarget and its associated TargetInfo based on the given configuration.

Private Member Functions

 RDMTarget (Endpoint ep, std::unique_ptr< IngressProtocol > protocol)
 Construct an RDMTarget with the given endpoint and immediate data location.
 RDMTarget (Endpoint ep, std::unique_ptr< void > protocol)
template<QueueReadMode>
std::optional< Target::ReadResult > readNext (std::chrono::steady_clock::duration timeout)
 Internal method to drive progress based on the current state.

Private Attributes

Endpoint _ep
std::unique_ptr< IngressProtocol > _protocol = {}
std::vector< Region > _regions

Additional Inherited Members

Public Types inherited from mxl::lib::fabrics::ofi::Target
using ReadResult = std::variant<GrainReadResult, SampleReadResult, Interrupted>

Detailed Description

Reliable Datagram (RDM) Target implementation.

Definition at line 18 of file RDMTarget.hpp.

Constructor & Destructor Documentation

◆ RDMTarget() [1/2]

mxl::lib::fabrics::ofi::RDMTarget::RDMTarget ( Endpoint ep,
std::unique_ptr< IngressProtocol > protocol )
private

Construct an RDMTarget with the given endpoint and immediate data location.

Parameters
endpointThe endpoint to use for communication.
protocolThe protocol that will be run over the endpoint.

Definition at line 86 of file RDMTarget.cpp.

87 : _ep(std::move(ep))
88 , _protocol(std::move(proto))
89 {}
std::unique_ptr< IngressProtocol > _protocol
Definition RDMTarget.hpp:61

◆ RDMTarget() [2/2]

mxl::lib::fabrics::ofi::RDMTarget::RDMTarget ( Endpoint ep,
std::unique_ptr< void > protocol )
private

Member Function Documentation

◆ read()

std::optional< Target::ReadResult > mxl::lib::fabrics::ofi::RDMTarget::read ( )
finalvirtual

Determine if new data can be consumed.

A non-blocking operation that also drives the connection forward. Continuous invocation of this function is necessary for connection establishment and ongoing progress.

Implements mxl::lib::fabrics::ofi::Target.

Definition at line 91 of file RDMTarget.cpp.

92 {
94 }
std::optional< Target::ReadResult > readNext(std::chrono::steady_clock::duration timeout)
Internal method to drive progress based on the current state.

◆ readBlocking()

std::optional< Target::ReadResult > mxl::lib::fabrics::ofi::RDMTarget::readBlocking ( std::chrono::steady_clock::duration timeout)
finalvirtual

Implements mxl::lib::fabrics::ofi::Target.

Definition at line 96 of file RDMTarget.cpp.

97 {
99 }

◆ readNext()

template<QueueReadMode queueReadMode>
std::optional< Target::ReadResult > mxl::lib::fabrics::ofi::RDMTarget::readNext ( std::chrono::steady_clock::duration timeout)
private

Internal method to drive progress based on the current state.

Parameters
timeoutThe maximum duration to block waiting for progress.
Returns
The result of the read operation.

Definition at line 107 of file RDMTarget.cpp.

108 {
109 drainEventQueue(*_ep.eventQueue());
110 try
111 {
112 auto completion = readCompletionQueue<queueReadMode>(*_ep.completionQueue(), timeout);
113 if (completion)
114 {
115 return _protocol->read(_ep, *completion);
116 }
117 }
118 catch (FabricException const& ex)
119 {
120 if (ex.isInterrupted())
121 {
122 return std::make_optional<Target::Interrupted>();
123 }
124
125 throw;
126 }
127
128 return {};
129 }
void drainEventQueue(EventQueue &eq)
Read all entries from a connectionless endpoint's event queue and log the errors among them.
std::optional< Completion > readCompletionQueue(CompletionQueue &eq, std::chrono::steady_clock::duration timeout)
Helper to read a completion queue with blocking or non-blocking behaviour.

◆ setup()

std::pair< std::unique_ptr< RDMTarget >, std::unique_ptr< TargetInfo > > mxl::lib::fabrics::ofi::RDMTarget::setup ( mxlFabricsTargetConfig const & config,
FabricInfoView info,
TargetSetupOptions const & options )
staticnodiscard

Set up a fresh RDMTarget and its associated TargetInfo based on the given configuration.

Parameters
configThe configuration to use for setting up the target.
Returns
A pair consisting of the newly setup RDMTarget and its associated TargetInfo.

Definition at line 24 of file RDMTarget.cpp.

26 {
27 requireCapability(info, FI_REMOTE_WRITE, "Interface is missing required remote write capability");
28 auto const provider = providerFromString(info->fabric_attr->prov_name);
29 if (!provider)
30 {
31 throw Exception::invalidArgument("invalid provider: {}", info->fabric_attr->prov_name);
32 }
33
34 MXL_INFO("Setting up RDM target with source address: {}", FabricAddress::fromSource(info).toString());
35
36 auto fabric = Fabric::open(info);
37 auto domain = Domain::open(fabric);
38
39 auto endpoint = Endpoint::create(domain);
40
42 if (options.cqDepth)
43 {
44 cqAttr.size = *options.cqDepth;
45 }
46 if (provider == Provider::EFA)
47 {
49 {
50 if ((config.interface.caps.flags & MXL_FABRICS_IFACE_CAP_BLOCKING_OPERATIONS) != 0)
51 {
52 throw Exception::make(MXL_ERR_NO_FABRIC, "Blocking API support requested, but not available for this fabric/version");
53 }
54
55 cqAttr.waitObject = FI_WAIT_NONE;
56 }
57 }
58
59 auto cq = CompletionQueue::open(domain, cqAttr);
60 endpoint.bind(cq, FI_RECV | FI_TRANSMIT);
61
62 // Connectionless endpoints must be bound to an address vector. Even if it is not using the address vector.
63 auto av = AddressVector::open(domain);
64 endpoint.bind(av);
65
66 endpoint.bind(EventQueue::open(fabric));
67
68 // Connectionless endpoints must be explictely enabled when they are ready to be used.
69 endpoint.enable();
70
71 auto mxlRegions = MxlRegions::forWriter(config.writer);
72 auto protocol = selectIngressProtocol(mxlRegions.dataLayout(), mxlRegions.regions(), mxlRegions.maxSyncBatchSize());
73 auto targetInfo = std::make_unique<TargetInfo>(
74 endpoint.id(), endpoint.localAddress(), *provider, protocol->registerMemory(domain), protocol->bounceBufferInfo());
75
76 struct MakeUniqueEnabler : RDMTarget
77 {
78 MakeUniqueEnabler(Endpoint ep, std::unique_ptr<IngressProtocol> proto)
79 : RDMTarget(std::move(ep), std::move(proto))
80 {}
81 };
82
83 return {std::make_unique<MakeUniqueEnabler>(std::move(endpoint), std::move(protocol)), std::move(targetInfo)};
84 }
#define MXL_INFO(...)
Definition Logging.hpp:45
static std::shared_ptr< AddressVector > open(std::shared_ptr< Domain > domain, Attributes attr=Attributes::defaults())
Create an AddressVector.
static std::shared_ptr< CompletionQueue > open(std::shared_ptr< Domain > domain, Attributes const &attr=Attributes::defaults())
Create a new completion queue in the specified domain.
static bool isWaitObjectSupportedForEFA() noexcept
Check if wait any wait object type supported by the EFA provider for this libfabric version.
static std::shared_ptr< Domain > open(std::shared_ptr< Fabric > fabric)
Open a new domain associated with the specified fabric.
Definition Domain.cpp:30
static Endpoint create(std::shared_ptr< Domain > domain, FabricInfoView info)
Allocates (active) new endpoint.
Definition Endpoint.cpp:56
static std::shared_ptr< EventQueue > open(std::shared_ptr< Fabric >, Attributes const &attr=Attributes::defaults())
Create a new event queue associated with the specified fabric.
static Exception invalidArgument(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_ARG exception.
Definition Exception.hpp:43
static Exception make(mxlStatus status, fmt::format_string< T... > fmt, T &&... args)
Make any type of exception.
Definition Exception.hpp:35
static FabricAddress fromSource(FabricInfoView info) noexcept
Build a FabricAddress from the source address of info.
static std::shared_ptr< Fabric > open(FabricInfoView info)
Open a fabric object based on the provided FabricInfoView.
Definition Fabric.cpp:15
static MxlRegions forWriter(mxlFlowWriter)
Definition Region.cpp:110
RDMTarget(Endpoint ep, std::unique_ptr< IngressProtocol > protocol)
Construct an RDMTarget with the given endpoint and immediate data location.
Definition RDMTarget.cpp:86
@ MXL_FABRICS_IFACE_CAP_BLOCKING_OPERATIONS
Definition fabrics.h:78
@ MXL_ERR_NO_FABRIC
Definition mxl.h:46
std::optional< Provider > providerFromString(std::string const &s) noexcept
Parse a provider name string, and return the enum value.
Definition Provider.cpp:49
std::unique_ptr< IngressProtocol > selectIngressProtocol(DataLayout const &layout, std::vector< Region > regions, std::uint32_t maxSyncBatchSize)
Select an appropriate ingress protocol based on the data layout.
Definition Protocol.cpp:13
void requireCapability(FabricInfoView info, std::uint64_t cap, std::string_view message)
static Attributes defaults()
Returns the a CompletionQueueAttr with all of its attributes set to reasonable defaults.

◆ shutdown()

void mxl::lib::fabrics::ofi::RDMTarget::shutdown ( )
finalvirtual

Shut down the target gracefully. Initiates a graceful shutdown of the target and blocks until the shutdown is complete. Can throw an exception if the shutdown is not successful. If this function throws the target can now longer be used.

Implements mxl::lib::fabrics::ofi::Target.

Definition at line 101 of file RDMTarget.cpp.

102 {
103 // no connection, no shutdown...
104 }

Member Data Documentation

◆ _ep

Endpoint mxl::lib::fabrics::ofi::RDMTarget::_ep
private

Definition at line 60 of file RDMTarget.hpp.

◆ _protocol

std::unique_ptr<IngressProtocol> mxl::lib::fabrics::ofi::RDMTarget::_protocol = {}
private

Definition at line 61 of file RDMTarget.hpp.

61{};

◆ _regions

std::vector<Region> mxl::lib::fabrics::ofi::RDMTarget::_regions
private

Definition at line 62 of file RDMTarget.hpp.


The documentation for this class was generated from the following files: