MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
RemoteRegion.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Contributors to the Media eXchange Layer project.
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#include "RemoteRegion.hpp"
6#include <cassert>
7#include <algorithm>
8#include "Exception.hpp"
9
11{
12
13 RemoteRegion RemoteRegion::sub(std::uint64_t offset, std::size_t length) const
14 {
15 if (offset + length > len)
16 {
17 throw Exception::invalidArgument("Invalid offset and length for remote region");
18 }
19
20 return RemoteRegion{
21 .addr = addr + offset,
22 .len = length,
23 .rkey = rkey,
24 };
25 }
26
27 ::fi_rma_iov RemoteRegion::toRmaIov() const noexcept
28 {
29 return ::fi_rma_iov{.addr = addr, .len = len, .key = rkey};
30 }
31
32 bool RemoteRegion::operator==(RemoteRegion const& other) const noexcept
33 {
34 return addr == other.addr && len == other.len && rkey == other.rkey;
35 }
36
37 ::fi_rma_iov const* RemoteRegionGroup::asRmaIovs() const noexcept
38 {
39 return _rmaIovs.data();
40 }
41
42 bool RemoteRegionGroup::operator==(RemoteRegionGroup const& other) const noexcept
43 {
44 return _inner == other._inner;
45 }
46}
static Exception invalidArgument(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_ARG exception.
Definition Exception.hpp:43
RemoteRegionGroup(std::vector< RemoteRegion > const &group)
Convert a vector of RemoteRegion into a RemoteRegionGroup.
bool operator==(RemoteRegionGroup const &other) const noexcept
::fi_rma_iov const * asRmaIovs() const noexcept
Get a pointer to an array of fi_rma_iov structures representing the remote regions.
Represent a remote memory region used for data transfer.
::fi_rma_iov toRmaIov() const noexcept
Convert this RemoteRegion to a struct fi_rma_iov used by libfabric RMA transfer functions.
bool operator==(RemoteRegion const &other) const noexcept
RemoteRegion sub(std::uint64_t offset, std::size_t length) const
Create a sub-region of this RemoteRegion.