16 std::vector<LocalRegion> localRegions)
29 SliceRange const& sliceRange, ::fi_addr_t destAddr)
33 auto const remoteSlot = remoteIndex %
_remoteInfo.remoteRegions.size();
36 if ((sliceRange.
start() == 0) && (sliceRange.
end() ==
_layout.totalSlices))
42 auto const planeCount =
_layout.activePlaneCount();
43 for (std::size_t plane = 0; plane < planeCount; ++plane)
45 auto const sliceSize =
_layout.sliceSizes[plane];
46 auto offset = std::uint32_t{0};
47 auto size = std::uint32_t{0};
52 if (sliceRange.
start() == 0)
65 auto const planeBase =
_layout.planePayloadOffset(plane, payloadOffset);
70 auto const localRegion = localGrain.sub(offset,
size);
71 auto const remoteRegion = remoteGrain.sub(offset,
size);
73 auto const isLastPlane = (plane == planeCount - 1);
74 auto const immData = isLastPlane ? std::make_optional(
ImmDataGrain{remoteSlot, sliceRange.
end()}.
data()) : std::nullopt;
115 domain->registerRegions(
_regions, FI_WRITE);
133 return std::make_unique<MakeUniqueEnabler>(token, std::move(remoteInfo),
_layout, *
_localRegions);
137 std::size_t bounceBufferEntryCount)
153 auto entryHeaderRegions = std::vector<Region>{};
157 entryHeaderRegions.emplace_back(
reinterpret_cast<std::uintptr_t
>(&header),
168 auto const offset = domain->localRegions().size();
169 domain->registerRegions(entryHeaderRegions, FI_WRITE);
170 auto const localRegions = domain->localRegions();
172 _entryHeaderRegions = std::vector(localRegions.cbegin() +
static_cast<std::ptrdiff_t
>(offset), localRegions.cend());
188 if (entrySizeRequired >
_remoteInfo.bounceBufferInfo->entrySize)
190 throw Exception::invalidArgument(
"Count is too large for the bounce buffer entry size. Count {}, entry size {}, required entry size {}.",
240 reinterpret_cast<std::uint8_t*
>(region.
addr),
244 auto const sgListLen = (slice.base.fragments[1].size > 0) ? 2 * slice.count : slice.count;
248 auto sgList = std::vector<LocalRegion>{};
249 sgList.reserve(sgListLen);
254 for (
auto chan = std::size_t{0}; chan < slice.count; chan++)
256 for (
auto const& fragment : slice.base.fragments)
259 if (fragment.size > 0)
261 auto const srcAddr =
reinterpret_cast<std::uintptr_t
>(fragment.pointer) + (slice.stride * chan);
263 sgList.emplace_back(
LocalRegion{.addr = srcAddr, .len = fragment.size, .desc = region.
desc});
283 if (!domain->localRegions().empty())
291 domain->registerRegion(
_region, FI_WRITE);
311 std::uint32_t bounceBufferEntryCount)
static void getMutableMultiBufferSlices(std::uint64_t index, std::size_t count, std::size_t bufferLength, std::size_t sampleWordSize, std::size_t channelCount, std::uint8_t *baseBufferPtr, mxlMutableWrappedMultiBufferSlice &slice) noexcept
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 endpoint (fi_ep).
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.
static Exception invalidArgument(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_ARG exception.
static Exception invalidState(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_STATE exception.
Immediate data representation for discrete flow transfers.
std::uint32_t data() const noexcept
Get the packed immediate data.
virtual void registerMemory(std::shared_ptr< Domain > domain) override
Register memory required by the protocol.
std::optional< std::vector< LocalRegion > > _localRegions
RMAGrainEgressProtocolTemplate(DataLayout::Discrete layout, std::vector< Region > regions)
virtual std::unique_ptr< EgressProtocol > createInstance(Completion::Token, TargetInfo remoteInfo) override
Create a new instance of the protocol for a remote target.
std::vector< Region > _regions
DataLayout::Discrete _layout
DataLayout::Discrete _layout
virtual std::size_t reset() final
Destroy the protocol object.
virtual void processCompletion(Completion const &) final
Process a completion event. Any post-processing after a transfer should be done here.
virtual void transferSamples(Endpoint const &, std::uint64_t, std::size_t, ::fi_addr_t) final
Transfer samples to a remote target.
virtual bool hasPendingWork() const final
Check if there is uncompleted requests.
std::vector< LocalRegion > _localRegions
virtual void registerMemory(std::shared_ptr< Domain > domain) final
Register local memory regions used in this protocol.
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.
RMAGrainEgressProtocol(Completion::Token token, TargetInfo info, DataLayout::Discrete dataLayout, std::vector< LocalRegion > _localRegions)
virtual void registerMemory(std::shared_ptr< Domain > domain) override
Register memory required by the protocol.
DataLayout::Continuous _layout
virtual std::unique_ptr< EgressProtocol > createInstance(Completion::Token, TargetInfo remoteInfo) override
Create a new instance of the protocol for a remote target.
RMASampleEgressProtocolTemplate(DataLayout::Continuous layout, Region region)
std::optional< LocalRegion > _localRegion
std::size_t _bounceBufferEntryCount
std::vector< LocalRegion > _entryHeaderRegions
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 void transferSamples(Endpoint const &ep, std::uint64_t headIndex, std::size_t count, ::fi_addr_t destAddr=FI_ADDR_UNSPEC) final
Transfer samples to a remote target.
DataLayout::Continuous _layout
virtual std::size_t reset() final
Destroy the protocol object.
std::uint32_t _bounceBufferEntryIndex
RMASampleEgressProtocol(Completion::Token token, TargetInfo info, DataLayout::Continuous dataLayout, LocalRegion _localRegion, std::size_t bounceBufferEntryCount)
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 bool hasPendingWork() const final
Check if there is uncompleted requests.
std::vector< AudioEntryHeader > _entryHeaders
static std::vector< LocalRegion > makeScatterGatherList(DataLayout::Continuous const &layout, std::uint64_t headIndex, std::size_t count, LocalRegion const ®ion)
Create the scatter-gather list for a given audio region and data layout. This will be used for the re...
static Location host() noexcept
specify a host memory location.
Represent a memory region (unregistered).
A SliceRange represents a range of slices within a grain.
std::uint32_t transferSize(std::uint32_t sliceSize) const noexcept
Get the size of the range (end - start).
std::uint32_t transferOffset(std::uint32_t payloadOffset, std::uint32_t sliceSize) const noexcept
Get the offset within the payload for the start of the range.
std::uint16_t end() const noexcept
Get the exclusive end of the range.
std::uint16_t start() const noexcept
Get the inclusive start of the range.
struct mxlMutableWrappedMultiBufferSlice_t mxlMutableWrappedMultiBufferSlice
std::size_t size() const noexcept
Returns the total number of writers that are registered in the DomainWatcher.
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
Continuous layout variant of DataLayout.
Discrete layout variant of DataLayout.
Represent a source memory region used for for data transfer.
TargetInfo contains all the information required by an initiator to operate transfers to the given ta...
std::optional< TargetInfoBounceBufferInfo > bounceBufferInfo