MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
RemoteRegion.hpp
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#pragma once
6
7#include <cstddef>
8#include <cstdint>
9#include <algorithm>
10#include <vector>
11#include <rdma/fi_rma.h>
12
14{
15
21 {
22 public:
29 [[nodiscard]]
30 RemoteRegion sub(std::uint64_t offset, std::size_t length) const;
31
34 [[nodiscard]]
35 ::fi_rma_iov toRmaIov() const noexcept;
36
37 bool operator==(RemoteRegion const& other) const noexcept;
38
39 public:
40 std::uint64_t addr;
41 std::size_t len;
42 std::uint64_t rkey;
43 };
44
48 {
49 public:
50 using iterator = std::vector<RemoteRegion>::iterator;
51 using const_iterator = std::vector<RemoteRegion>::const_iterator;
52
53 public:
56 RemoteRegionGroup(std::vector<RemoteRegion> const& group)
57 : _inner(std::move(group))
58 , _rmaIovs(rmaIovsFromGroup(group.begin(), group.end()))
59 {}
60
65 [[nodiscard]]
66 ::fi_rma_iov const* asRmaIovs() const noexcept;
67
68 bool operator==(RemoteRegionGroup const& other) const noexcept;
69
71 {
72 return _inner.begin();
73 }
74
76 {
77 return _inner.end();
78 }
79
80 [[nodiscard]]
82 {
83 return _inner.cbegin();
84 }
85
86 [[nodiscard]]
88 {
89 return _inner.cend();
90 }
91
93 {
94 return _inner[index];
95 }
96
97 RemoteRegion const& operator[](std::size_t index) const
98 {
99 return _inner[index];
100 }
101
102 [[nodiscard]]
103 std::size_t size() const noexcept
104 {
105 return _inner.size();
106 }
107
108 private:
111 template<typename Begin, typename End>
112 [[nodiscard]]
113 static std::vector<::fi_rma_iov> rmaIovsFromGroup(Begin&& begin, End&& end) noexcept
114 {
115 std::vector<::fi_rma_iov> rmaIovs;
116 std::ranges::transform(std::forward<Begin>(begin),
117 std::forward<End>(end),
118 std::back_inserter(rmaIovs),
119 [](RemoteRegion const& reg) { return reg.toRmaIov(); });
120 return rmaIovs;
121 }
122
123 private:
124 std::vector<RemoteRegion> _inner;
125
126 std::vector<::fi_rma_iov>
128 };
129}
Represent a group of remote memory regions used for data transfer.
std::vector< RemoteRegion >::const_iterator const_iterator
RemoteRegion const & operator[](std::size_t index) const
RemoteRegionGroup(std::vector< RemoteRegion > const &group)
Convert a vector of RemoteRegion into a RemoteRegionGroup.
static std::vector<::fi_rma_iov > rmaIovsFromGroup(Begin &&begin, End &&end) noexcept
Convert a vector of RemoteRegion into a vector of fi_rma_iov structures. Used by the constructor.
std::vector< RemoteRegion >::iterator iterator
::fi_rma_iov const * asRmaIovs() const noexcept
Get a pointer to an array of fi_rma_iov structures representing the remote regions.
RemoteRegion & operator[](std::size_t index)
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.
uint64_t index