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

Wrapper for a linked-list of fi_info objects, mostly returned from ::fi_getinfo. More...

Public Types

using const_iterator = FabricInfoIterator<true>
using iterator = FabricInfoIterator<false>

Public Member Functions

const_iterator begin () const noexcept
iterator begin () noexcept
const_iterator cbegin () const noexcept
const_iterator cend () const noexcept
const_iterator end () const noexcept
iterator end () noexcept
 FabricInfoList (FabricInfoList &&other) noexcept
 FabricInfoList (FabricInfoList const &)=delete
FabricInfoList & operator= (FabricInfoList &&other) noexcept
FabricInfoList & operator= (FabricInfoList const &)=delete
 ~FabricInfoList ()
 calls ::fi_freeinfo to deallocate the underlying linked-list

Static Public Member Functions

static FabricInfoList get ()
 Calls fi_getinfo without any hints and returns the full list of fabric information objects.
static FabricInfoList getSourceInterfaces (ProviderConfig const &providerConfig, std::optional< FabricAddress > const &sourceAddress)
 Calls fi_getinfo with FI_SOURCE to get source interface information. Uses hints derived from the provider config value.
static FabricInfoList own (::fi_info *info) noexcept
 Take ownership over a fi_info raw pointer.

Private Member Functions

 FabricInfoList (::fi_info *) noexcept
void free ()

Private Attributes

::fi_info * _begin

Detailed Description

Wrapper for a linked-list of fi_info objects, mostly returned from ::fi_getinfo.

Can be iterated over and used with std::algorithms and std::ranges.

Definition at line 225 of file FabricInfo.hpp.

Member Typedef Documentation

◆ const_iterator

◆ iterator

Constructor & Destructor Documentation

◆ ~FabricInfoList()

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

calls ::fi_freeinfo to deallocate the underlying linked-list

Definition at line 239 of file FabricInfo.cpp.

240 {
241 free();
242 }

◆ FabricInfoList() [1/3]

mxl::lib::fabrics::ofi::FabricInfoList::FabricInfoList ( FabricInfoList const & )
delete

◆ FabricInfoList() [2/3]

mxl::lib::fabrics::ofi::FabricInfoList::FabricInfoList ( FabricInfoList && other)
noexcept

Definition at line 244 of file FabricInfo.cpp.

245 : _begin(other._begin)
246 {
247 other._begin = nullptr;
248 }

◆ FabricInfoList() [3/3]

mxl::lib::fabrics::ofi::FabricInfoList::FabricInfoList ( ::fi_info * begin)
explicitprivatenoexcept

Definition at line 235 of file FabricInfo.cpp.

236 : _begin(begin)
237 {}

Member Function Documentation

◆ begin() [1/2]

FabricInfoList::const_iterator mxl::lib::fabrics::ofi::FabricInfoList::begin ( ) const
nodiscardnoexcept

Definition at line 269 of file FabricInfo.cpp.

270 {
271 return const_iterator{_begin};
272 }
FabricInfoIterator< true > const_iterator

◆ begin() [2/2]

FabricInfoList::iterator mxl::lib::fabrics::ofi::FabricInfoList::begin ( )
noexcept

Definition at line 259 of file FabricInfo.cpp.

260 {
261 return iterator{_begin};
262 }
FabricInfoIterator< false > iterator

◆ cbegin()

FabricInfoList::const_iterator mxl::lib::fabrics::ofi::FabricInfoList::cbegin ( ) const
nodiscardnoexcept

Definition at line 279 of file FabricInfo.cpp.

280 {
281 return const_iterator{_begin};
282 }

◆ cend()

FabricInfoList::const_iterator mxl::lib::fabrics::ofi::FabricInfoList::cend ( ) const
nodiscardnoexcept

Definition at line 284 of file FabricInfo.cpp.

285 {
286 return const_iterator{nullptr};
287 }

◆ end() [1/2]

FabricInfoList::const_iterator mxl::lib::fabrics::ofi::FabricInfoList::end ( ) const
nodiscardnoexcept

Definition at line 274 of file FabricInfo.cpp.

275 {
276 return const_iterator{nullptr};
277 }

◆ end() [2/2]

FabricInfoList::iterator mxl::lib::fabrics::ofi::FabricInfoList::end ( )
noexcept

Definition at line 264 of file FabricInfo.cpp.

265 {
266 return iterator{nullptr};
267 }

◆ free()

void mxl::lib::fabrics::ofi::FabricInfoList::free ( )
private

Definition at line 289 of file FabricInfo.cpp.

290 {
291 if (_begin != nullptr)
292 {
293 ::fi_freeinfo(_begin);
294 _begin = nullptr;
295 }
296 }

◆ get()

FabricInfoList mxl::lib::fabrics::ofi::FabricInfoList::get ( )
staticnodiscard

Calls fi_getinfo without any hints and returns the full list of fabric information objects.

Definition at line 173 of file FabricInfo.cpp.

174 {
175 auto info = std::add_pointer_t<::fi_info>{nullptr};
176 fiCall(::fi_getinfo, "Failed to get provider information", fiVersion(), nullptr, nullptr, 0, nullptr, &info);
177 return FabricInfoList{info};
178 }
FabricInfoList(FabricInfoList const &)=delete
std::uint32_t fiVersion() noexcept
Returns the libfabric version this library was compiled with.
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.

◆ getSourceInterfaces()

FabricInfoList mxl::lib::fabrics::ofi::FabricInfoList::getSourceInterfaces ( ProviderConfig const & providerConfig,
std::optional< FabricAddress > const & sourceAddress )
staticnodiscard

Calls fi_getinfo with FI_SOURCE to get source interface information. Uses hints derived from the provider config value.

Definition at line 180 of file FabricInfo.cpp.

181 {
182 auto info = std::add_pointer_t<::fi_info>{nullptr};
183 auto hints = FabricInfo::empty();
184
185 auto node = std::string{};
186 auto service = std::string{};
187 auto nodeStringBuffer = std::add_pointer_t<char const>{nullptr};
188 auto serviceStringBuffer = std::add_pointer_t<char const>{nullptr};
189
190 // Provider name is owned by the fi_info object and must be ::strdupe'd here.
191 hints->fabric_attr->prov_name = ::strdup(providerConfig.getProviderName().c_str());
192
193 // Set hints defined in the provider config
194 hints->domain_attr->mr_mode = providerConfig.getSupportedMemoryRegistrationModes();
195 hints->ep_attr->type = providerConfig.getEndpointType();
196 hints->caps = providerConfig.getCaps();
197
198 if (sourceAddress)
199 {
200 // If a service name/port exists, create a std::string, and get the c_str()
201 // the std::strings need to live through the call to fi_getinfo, so they are assigned to lvalues
202 // in the parent scope too.
203 if (auto nodeValue = sourceAddress->node(); nodeValue)
204 {
205 node = *nodeValue;
206 nodeStringBuffer = node.c_str();
207 }
208
209 if (auto serviceValue = sourceAddress->service(); serviceValue)
210 {
211 service = *serviceValue;
212 serviceStringBuffer = service.c_str();
213 }
214
215 // The verbs provider need the addr_format hint set for ipv6 to work correctly
216 hints->addr_format = static_cast<std::uint32_t>(sourceAddress->addressFormat());
217 }
218
219 fiCall(::fi_getinfo,
220 "Failed to get source interface information",
221 fiVersion(),
222 nodeStringBuffer,
223 serviceStringBuffer,
224 FI_SOURCE,
225 hints.raw(),
226 &info);
227 return FabricInfoList{info};
228 }

◆ operator=() [1/2]

FabricInfoList & mxl::lib::fabrics::ofi::FabricInfoList::operator= ( FabricInfoList && other)
noexcept

Definition at line 250 of file FabricInfo.cpp.

251 {
252 free();
253
254 _begin = other._begin;
255 other._begin = nullptr;
256 return *this;
257 }

◆ operator=() [2/2]

FabricInfoList & mxl::lib::fabrics::ofi::FabricInfoList::operator= ( FabricInfoList const & )
delete

◆ own()

FabricInfoList mxl::lib::fabrics::ofi::FabricInfoList::own ( ::fi_info * info)
staticnoexcept

Take ownership over a fi_info raw pointer.

Definition at line 230 of file FabricInfo.cpp.

231 {
232 return FabricInfoList{info};
233 }

Member Data Documentation

◆ _begin

::fi_info* mxl::lib::fabrics::ofi::FabricInfoList::_begin
private

Definition at line 279 of file FabricInfo.hpp.


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