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

#include <ProtocolEgressRMA.hpp>

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

Public Member Functions

virtual bool hasPendingWork () const final
 Check if there is uncompleted requests.
virtual void processCompletion (Completion const &) final
 Process a completion event. Any post-processing after a transfer should be done here.
virtual void registerMemory (std::shared_ptr< Domain > domain) final
 Register local memory regions used in this protocol.
virtual std::size_t reset () final
 Destroy the protocol object.
virtual void transferGrain (Endpoint const &ep, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint32_t payloadOffset, SliceRange const &sliceRange, ::fi_addr_t destAddr=FI_ADDR_UNSPEC) final
 Transfer a grain to a remote target.
virtual void transferSamples (Endpoint const &, std::uint64_t, std::size_t, ::fi_addr_t) final
 Transfer samples to a remote target.
Public Member Functions inherited from mxl::lib::fabrics::ofi::EgressProtocol
virtual ~EgressProtocol ()=default

Private Member Functions

 RMAGrainEgressProtocol (Completion::Token token, TargetInfo info, DataLayout::Discrete dataLayout, std::vector< LocalRegion > _localRegions)

Private Attributes

DataLayout::Discrete _layout
std::vector< LocalRegion > _localRegions
std::size_t _pending = 0
TargetInfo _remoteInfo
Completion::Token _token

Friends

class RMAGrainEgressProtocolTemplate

Detailed Description

Definition at line 15 of file ProtocolEgressRMA.hpp.

Constructor & Destructor Documentation

◆ RMAGrainEgressProtocol()

mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::RMAGrainEgressProtocol ( Completion::Token token,
TargetInfo info,
DataLayout::Discrete dataLayout,
std::vector< LocalRegion > _localRegions )
private

Definition at line 15 of file ProtocolEgressRMA.cpp.

17 : _token{token}
18 , _remoteInfo{std::move(info)}
19 , _layout{layout}
20 , _localRegions{std::move(localRegions)}
21 {}

Member Function Documentation

◆ hasPendingWork()

bool mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::hasPendingWork ( ) const
nodiscardfinalvirtual

Check if there is uncompleted requests.

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 93 of file ProtocolEgressRMA.cpp.

94 {
95 return _pending > 0;
96 }

◆ processCompletion()

void mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::processCompletion ( Completion const & )
finalvirtual

Process a completion event. Any post-processing after a transfer should be done here.

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 85 of file ProtocolEgressRMA.cpp.

86 {
87 if (_pending > 0)
88 {
89 --_pending;
90 }
91 }

◆ registerMemory()

void mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::registerMemory ( std::shared_ptr< Domain > domain)
finalvirtual

Register local memory regions used in this protocol.

Parameters
domainThe domain to register memory with.
Note
This is used to register additional local memory regions. One example of this, is in the case where there is a metadata header that needs to be transferred along with the actual data, and the header is stored in a different memory region from the data. And such memory region can only be created after the protocol template creates the protocol instance since the header content is only known after the instance is created.
This is a NOP for this protocol

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 23 of file ProtocolEgressRMA.cpp.

24 {
25 // For this protocol, memory registration is completely handled at the protocol template level, so this function doesn't need to do anything.
26 }

◆ reset()

std::size_t mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::reset ( )
finalvirtual

Destroy the protocol object.

Returns
The number of pending transfers.

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 98 of file ProtocolEgressRMA.cpp.

99 {
100 return std::exchange(_pending, 0);
101 }

◆ transferGrain()

void mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::transferGrain ( Endpoint const & ep,
std::uint64_t localIndex,
std::uint64_t remoteIndex,
std::uint32_t payloadOffset,
SliceRange const & sliceRange,
::fi_addr_t destAddr = FI_ADDR_UNSPEC )
finalvirtual

Transfer a grain to a remote target.

Parameters
localRegionThe local region to transfer from.
remoteIndexThe index of the remote grain to transfer to.
payloadOffsetThe payload offset within the grain.
sliceRangeThe range of slices to transfer.
destAddrThe destination address. This is ignored for connection-oriented endpoints.

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 28 of file ProtocolEgressRMA.cpp.

30 {
31 auto const localGrain = _localRegions[localIndex % _localRegions.size()];
32 auto const remoteGrain = _remoteInfo.remoteRegions[remoteIndex % _remoteInfo.remoteRegions.size()];
33 auto const remoteSlot = remoteIndex % _remoteInfo.remoteRegions.size();
34
35 // Fast path: a full grain is transferred, can do one write no matter how many planes
36 if ((sliceRange.start() == 0) && (sliceRange.end() == _layout.totalSlices))
37 {
38 _pending += ep.write(_token, localGrain, remoteGrain, destAddr, std::make_optional(ImmDataGrain{remoteSlot, _layout.totalSlices}.data()));
39 return;
40 }
41
42 auto const planeCount = _layout.activePlaneCount();
43 for (std::size_t plane = 0; plane < planeCount; ++plane)
44 {
45 auto const sliceSize = _layout.sliceSizes[plane];
46 auto offset = std::uint32_t{0};
47 auto size = std::uint32_t{0};
48
49 if (plane == 0)
50 {
51 // need to include header with slice 0-x
52 if (sliceRange.start() == 0)
53 {
54 offset = sliceRange.transferOffset(0, sliceSize);
55 size = sliceRange.transferSize(sliceSize) + payloadOffset;
56 }
57 else
58 {
59 offset = sliceRange.transferOffset(payloadOffset, sliceSize);
60 size = sliceRange.transferSize(sliceSize);
61 }
62 }
63 else
64 {
65 auto const planeBase = _layout.planePayloadOffset(plane, payloadOffset);
66 offset = sliceRange.transferOffset(planeBase, sliceSize);
67 size = sliceRange.transferSize(sliceSize);
68 }
69
70 auto const localRegion = localGrain.sub(offset, size);
71 auto const remoteRegion = remoteGrain.sub(offset, size);
72
73 auto const isLastPlane = (plane == planeCount - 1);
74 auto const immData = isLastPlane ? std::make_optional(ImmDataGrain{remoteSlot, sliceRange.end()}.data()) : std::nullopt;
75
76 _pending += ep.write(_token, localRegion, remoteRegion, destAddr, immData);
77 }
78 }
std::size_t size() const noexcept
Returns the total number of writers that are registered in the DomainWatcher.

◆ transferSamples()

void mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::transferSamples ( Endpoint const & ,
std::uint64_t ,
std::size_t ,
::fi_addr_t  )
finalvirtual

Transfer samples to a remote target.

Parameters
headIndexThe head index of the samples to transfer.
countThe number of samples per channel to transfer.
destAddrThe destination address. This is ignored for connection-oriented endpoints.
Note
This is unsupported in this protocol since it is designed for grain data. Calling this function will result in an Exception::invalidState being thrown.

Implements mxl::lib::fabrics::ofi::EgressProtocol.

Definition at line 80 of file ProtocolEgressRMA.cpp.

81 {
82 throw Exception::invalidState("transferSamples is not supported in RMAGrainEgressProtocol.");
83 }
static Exception invalidState(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_STATE exception.
Definition Exception.hpp:59

◆ RMAGrainEgressProtocolTemplate

friend class RMAGrainEgressProtocolTemplate
friend

Definition at line 48 of file ProtocolEgressRMA.hpp.

Member Data Documentation

◆ _layout

DataLayout::Discrete mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::_layout
private

Definition at line 55 of file ProtocolEgressRMA.hpp.

◆ _localRegions

std::vector<LocalRegion> mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::_localRegions
private

Definition at line 56 of file ProtocolEgressRMA.hpp.

◆ _pending

std::size_t mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::_pending = 0
private

Definition at line 57 of file ProtocolEgressRMA.hpp.

◆ _remoteInfo

TargetInfo mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::_remoteInfo
private

Definition at line 54 of file ProtocolEgressRMA.hpp.

◆ _token

Completion::Token mxl::lib::fabrics::ofi::RMAGrainEgressProtocol::_token
private

Definition at line 53 of file ProtocolEgressRMA.hpp.


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