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

A wrapper around Initiator implementations. More...

#include <Initiator.hpp>

Public Member Functions

void addTarget (TargetInfo const &targetInfo)
 Add a target to the initiator.
Initiator::MakeProgressResult makeProgress ()
 Attempts to progress execution, including connection management and data operations.
Initiator::MakeProgressResult makeProgressBlocking (std::chrono::steady_clock::duration)
 Attempts to progress execution, including connection management and data operations.
void removeTarget (TargetInfo const &targetInfo)
 Remove a target from the initiator.
void setup (mxlFabricsInitiatorConfig const &config, InitiatorSetupOptions const &options={})
 Set up the initiator with the specified configuration.
mxlFabricsInitiator toAPI () noexcept
 Convert this InitiatorWrapper to its API representation.
void transferGrain (std::uint64_t grainIndex, std::uint16_t startSlice, std::uint16_t endSlice)
 Transfer a grain to all targets.
void transferGrainToTarget (Endpoint::Id targetId, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t payloadOffset, std::uint16_t startSlice, std::uint16_t endSlice)
 Transfer a grain to a specific target.
void transferSamples (std::uint64_t headIndex, std::size_t count)
 Transfer samples to all targets.
 ~InitiatorWrapper ()
 Shut down the underlying initiator before it is destroyed.

Static Public Member Functions

static InitiatorWrapper * fromAPI (mxlFabricsInitiator api) noexcept
 Convert an mxlFabricsInitiator API object to its underlying InitiatorWrapper.

Private Member Functions

void destroyInner () noexcept
 Shut down and destroy the underlying initiator. Errors are logged, because this runs in the destructor.

Private Attributes

std::unique_ptr< Initiator > _inner

Detailed Description

A wrapper around Initiator implementations.

This wrapper creates an unspecified initiator that can be configured for a specific type by calling the setup() method.

Definition at line 120 of file Initiator.hpp.

Constructor & Destructor Documentation

◆ ~InitiatorWrapper()

mxl::lib::fabrics::ofi::InitiatorWrapper::~InitiatorWrapper ( )

Shut down the underlying initiator before it is destroyed.

Definition at line 17 of file Initiator.cpp.

18 {
20 }
void destroyInner() noexcept
Shut down and destroy the underlying initiator. Errors are logged, because this runs in the destructo...
Definition Initiator.cpp:22

Member Function Documentation

◆ addTarget()

void mxl::lib::fabrics::ofi::InitiatorWrapper::addTarget ( TargetInfo const & targetInfo)

Add a target to the initiator.

The is a non-blocking operation. The local endpoint for this target will only actively start connecting to its remote counterpart when control is passed to makeProgress() or makeProgressBlocking(). The local endpoint for this target will only accept write requests after the progress functions return false.

Definition at line 64 of file Initiator.cpp.

65 {
66 if (!_inner)
67 {
68 throw Exception::invalidState("Initiator is not set up");
69 }
70
71 _inner->addTarget(targetInfo);
72 }
static Exception invalidState(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_STATE exception.
Definition Exception.hpp:59
std::unique_ptr< Initiator > _inner

◆ destroyInner()

void mxl::lib::fabrics::ofi::InitiatorWrapper::destroyInner ( )
privatenoexcept

Shut down and destroy the underlying initiator. Errors are logged, because this runs in the destructor.

Definition at line 22 of file Initiator.cpp.

23 {
24 if (!_inner)
25 {
26 return;
27 }
28
29 try
30 {
31 _inner->shutdown();
32 }
33 catch (std::exception const& e)
34 {
35 MXL_ERROR("Failed to shut down the initiator: {}", e.what());
36 }
37
38 _inner.reset();
39 }
#define MXL_ERROR(...)
Definition Logging.hpp:67

◆ fromAPI()

InitiatorWrapper * mxl::lib::fabrics::ofi::InitiatorWrapper::fromAPI ( mxlFabricsInitiator api)
staticnodiscardnoexcept

Convert an mxlFabricsInitiator API object to its underlying InitiatorWrapper.

Parameters
apiThe mxlFabricsInitiator to convert.
Returns
The InitiatorWrapper underlying the given mxlFabricsInitiator.

Definition at line 41 of file Initiator.cpp.

42 {
43 return reinterpret_cast<InitiatorWrapper*>(api);
44 }

◆ makeProgress()

Initiator::MakeProgressResult mxl::lib::fabrics::ofi::InitiatorWrapper::makeProgress ( )

Attempts to progress execution, including connection management and data operations.

This is the non-blocking version of the progress function.

Definition at line 115 of file Initiator.cpp.

116 {
117 if (!_inner)
118 {
119 throw Exception::invalidState("Initiator is not set up");
120 }
121
122 return _inner->makeProgress();
123 }

◆ makeProgressBlocking()

Initiator::MakeProgressResult mxl::lib::fabrics::ofi::InitiatorWrapper::makeProgressBlocking ( std::chrono::steady_clock::duration timeout)

Attempts to progress execution, including connection management and data operations.

This is the blocking version of the progress function.

Definition at line 125 of file Initiator.cpp.

126 {
127 if (!_inner)
128 {
129 throw Exception::invalidState("Initiator is not set up");
130 }
131
132 return _inner->makeProgressBlocking(timeout);
133 }

◆ removeTarget()

void mxl::lib::fabrics::ofi::InitiatorWrapper::removeTarget ( TargetInfo const & targetInfo)

Remove a target from the initiator.

This is a non-blocking operation. The target is only removed after makeProgress() or makeProgressBlocking() returns false.

Definition at line 74 of file Initiator.cpp.

75 {
76 if (!_inner)
77 {
78 throw Exception::invalidState("Initiator is not set up");
79 }
80
81 _inner->removeTarget(targetInfo);
82 }

◆ setup()

void mxl::lib::fabrics::ofi::InitiatorWrapper::setup ( mxlFabricsInitiatorConfig const & config,
InitiatorSetupOptions const & options = {} )

Set up the initiator with the specified configuration.

This method initializes the underlying initiator implementation based on the provided configuration.

Parameters
configThe configuration to use for setting up the initiator.
optionsOptional tuning parameters (e.g. completion queue depth).

Definition at line 51 of file Initiator.cpp.

52 {
54
55 auto const [info, provierConfig] = selectSourceInterface(config.interface, /* target */ false);
56 switch (info.view().endpointType())
57 {
58 case FI_EP_MSG: _inner = RCInitiator::setup(config, info.view(), options); break;
59 case FI_EP_RDM: _inner = RDMInitiator::setup(config, info.view(), options); break;
60 default: throw Exception::invalidState("unsupported endpoint type");
61 }
62 }
static std::unique_ptr< RCInitiator > setup(mxlFabricsInitiatorConfig const &config, FabricInfoView info, InitiatorSetupOptions const &options={})
Set up a fresh initiator without any targets assigned to it.
static std::unique_ptr< RDMInitiator > setup(mxlFabricsInitiatorConfig const &config, FabricInfoView info, InitiatorSetupOptions const &options={})
Set up a new RDMInitiator.
std::pair< FabricInfo, ProviderConfig > selectSourceInterface(::mxlFabricsInterfaceConfig const &interfaceConfig, bool isTarget)

◆ toAPI()

mxlFabricsInitiator mxl::lib::fabrics::ofi::InitiatorWrapper::toAPI ( )
nodiscardnoexcept

Convert this InitiatorWrapper to its API representation.

Returns
The mxlFabricsInitiator representing this InitiatorWrapper.

Definition at line 46 of file Initiator.cpp.

47 {
48 return reinterpret_cast<mxlFabricsInitiator>(this);
49 }
struct mxlFabricsInitiator_t * mxlFabricsInitiator
Definition fabrics.h:44

◆ transferGrain()

void mxl::lib::fabrics::ofi::InitiatorWrapper::transferGrain ( std::uint64_t grainIndex,
std::uint16_t startSlice,
std::uint16_t endSlice )

Transfer a grain to all targets.

This is a non-blocking operation. The transfer is complete only after makeProgress() or makeProgressBlocking() returns false.

Parameters
grainIndexThe index of the grain to transfer.
startSliceThe start slice in the slice range to transfer. This is inclusive.
endSliceThe end slice in the slice range to transfer. This is exclusive.

Definition at line 84 of file Initiator.cpp.

85 {
86 if (!_inner)
87 {
88 throw Exception::invalidState("Initiator is not set up");
89 }
90
91 _inner->transferGrain(grainIndex, startSlice, endSlice);
92 }

◆ transferGrainToTarget()

void mxl::lib::fabrics::ofi::InitiatorWrapper::transferGrainToTarget ( Endpoint::Id targetId,
std::uint64_t localIndex,
std::uint64_t remoteIndex,
std::uint64_t payloadOffset,
std::uint16_t startSlice,
std::uint16_t endSlice )

Transfer a grain to a specific target.

This is a non-blocking operation. The transfer is complete only after makeProgress() or makeProgressBlocking() returns false.

Parameters
targetIdThe ID of the target to transfer the grain to.
localIndexThe index of the local grain to transfer from.
remoteIndexThe index of the remote grain to transfer to.
payloadOffsetThe payload offset within the grain.
startSliceThe start slice in the slice range to transfer. This is inclusive.
endSliceThe end slice in the slice range to transfer. This is exclusive.

Definition at line 94 of file Initiator.cpp.

96 {
97 if (!_inner)
98 {
99 throw Exception::invalidState("Initiator is not set up");
100 }
101
102 _inner->transferGrainToTarget(targetId, localIndex, remoteIndex, payloadOffset, startSlice, endSlice);
103 }

◆ transferSamples()

void mxl::lib::fabrics::ofi::InitiatorWrapper::transferSamples ( std::uint64_t headIndex,
std::size_t count )

Transfer samples to all targets.

This is a non-blocking operation. The transfer is complete only after makeProgress() or makeProgressBlocking() returns false.

Parameters
headIndexThe head index to transfer.
countThe number of samples per channel to transfer.

Definition at line 105 of file Initiator.cpp.

106 {
107 if (!_inner)
108 {
109 throw Exception::invalidState("Initiator is not set up");
110 }
111
112 _inner->transferSamples(headIndex, count);
113 }
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.

Member Data Documentation

◆ _inner

std::unique_ptr<Initiator> mxl::lib::fabrics::ofi::InitiatorWrapper::_inner
private

The underlying initiator implementation.

Definition at line 186 of file Initiator.hpp.


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