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

Classes

class  AddressVector
 RAII Wrapper to a libfabric fi_av instance. More...
class  AudioBounceBuffer
 A bounce buffer for audio samples. More...
class  AudioBounceBufferEntry
 An audio bounce buffer entry is backed by a collection of samples The layout is: AudioEntryHeader, followed by samples. More...
struct  AudioEntryHeader
 Header for an audio bounce buffer entry. More...
class  Completion
 Type to represent a completion entry from a CompletionQueue. More...
class  CompletionQueue
 RAII Wrapper around a libfabric completion queue (fi_cq). More...
class  DataLayout
 Describes the layout of data within memory regions. More...
class  Domain
 RAII Wrapper around a libfabric domain (fi_domain). More...
struct  EfaAddress
 Decoded representation of an FI_ADDR_EFA address. More...
class  EgressProtocol
 Interface for transfer operations. More...
class  EgressProtocolTemplate
class  Endpoint
 RAII Wrapper around a libfabric endpoint (fi_ep). More...
class  Event
 Type to represent an event entry from an EventQueue. More...
class  EventQueue
 RAII Wrapper around a libfabric event queue (fi_eq). More...
class  Exception
 Custom exception type used in the fabrics library. More...
class  Fabric
 RAIII wrapper around a libfabric fabric object (fid_fabric). More...
class  FabricAddress
 Owning, type-safe representation of a libfabric address. More...
class  FabricException
 An internal exception type that extends. More...
class  FabricInfoIterator
 Implements a const/non-const ForwardIterator over a ::fi_info linked list, for use with range-based for-loops, std::algorithms and ranges. More...
class  FabricInfoList
 Wrapper for a linked-list of fi_info objects, mostly returned from ::fi_getinfo. More...
class  FabricInfoView
 Non-owning view of a FabricInfo. Returned when iterating over a FabricInfoList. More...
class  FabricInterfaceDescription
class  FabricInterfaceList
class  FabricsInstance
 The underlying implementation of an mxlFabricsInstance API object. More...
class  ImmDataGrain
 Immediate data representation for discrete flow transfers. More...
class  IngressProtocol
 Interface for post-processing on transfer reception. More...
class  Initiator
 Abstract base class for Initiator implementations. More...
struct  InitiatorSetupOptions
 Provider-independent tuning options for initiator setup. More...
class  InitiatorWrapper
 A wrapper around Initiator implementations. More...
struct  LocalRegion
 Represent a source memory region used for for data transfer. More...
class  LocalRegionGroup
 Represent a scatter-gather list of source memory regions used for data transfer. More...
class  LocalRegionGroupSpan
 Represent a span of a LocalRegionGroup. More...
class  MemoryRegion
 RAII wrapper around a libfabric memory region (fid_mr). More...
class  MxlRegions
 Represent a collection of memory regions. More...
struct  OfiSockaddrIb
 Local declaration of libfabric's internal struct ofi_sockaddr_ib. More...
struct  overloaded
class  PassiveEndpoint
 RAII Wrapper around a libfabric passive endpoint (fid_pep). More...
class  ProviderCapabilities
class  ProviderConfig
struct  ProviderConfigValues
class  RawFabricAddress
 Wrapper around a libfabric endpoint address. More...
class  RCInitiator
 An initiator that uses reliable connected endpoints to transfer data to targets. More...
class  RCInitiatorEndpoint
 A single endpoint connected to a target that will be created when the user adds a target to an initiator. More...
class  RCTarget
 Reliable Connected (RC) Target implementation. More...
class  RDMInitiator
 An initiator that uses reliable datagram (RDM) endpoints for data transfers. More...
class  RDMInitiatorTarget
 A single endpoint within an RDMInitiator. More...
class  RDMTarget
 Reliable Datagram (RDM) Target implementation. More...
class  Region
 Represent a memory region (unregistered). More...
class  RegionGroup
 Represent a group of memory regions. More...
class  RegisteredRegion
 Represent a registered memory region. More...
struct  RemoteRegion
 Represent a remote memory region used for data transfer. More...
class  RemoteRegionGroup
 Represent a group of remote memory regions used for data transfer. More...
class  RMAGrainEgressProtocol
class  RMAGrainEgressProtocolTemplate
 Template for creating an Egress protocol for RMA writer endpoint to handle transferring grains to remote targets using remote write operations. More...
class  RMAGrainIngressProtocol
 Ingress protocol for RMA writer endpoint. More...
class  RMASampleEgressProtocol
class  RMASampleEgressProtocolTemplate
 Template for creating an Egress protocol for RMA writer endpoint to handles transferring audio data to remote targets using remote write operations. More...
class  RMASampleIngressProtocol
 Ingress protocol for RMA writer endpoint for audio samples. More...
class  SliceRange
 A SliceRange represents a range of slices within a grain. More...
class  Target
 Abstract base class for Target implementations. More...
struct  TargetInfo
 TargetInfo contains all the information required by an initiator to operate transfers to the given target. More...
struct  TargetInfoBounceBufferInfo
 Information about the bounce buffer on the target, if the target uses one. More...
struct  TargetSetupOptions
 Provider-independent tuning options for target setup. More...
class  TargetWrapper
 A wrapper around Target implementations. More...

Typedefs

using InnerRegion = std::vector<std::uint8_t>
using InnerRegions = std::vector<InnerRegion>

Enumerations

enum class  FabricAddressFormat : std::uint32_t {
  Unspec = static_cast<std::uint32_t>(FI_ADDR_UNSPEC) , Sockaddr = FI_SOCKADDR , SockaddrIp = FI_SOCKADDR_IP , SockaddrIn = FI_SOCKADDR_IN ,
  SockaddrIn6 = FI_SOCKADDR_IN6 , SockaddrIb = FI_SOCKADDR_IB , Efa = FI_ADDR_EFA , String = FI_ADDR_STR
}
enum class  Provider {
  ANY , TCP , VERBS , EFA ,
  SHM
}
 Internal representation of supported libfabric providers. More...
enum class  QueueReadMode { Blocking , NonBlocking }
 Enum to select blocking or non-blocking queue read behaviour. More...

Functions

template<typename F>
void catchAndLogFabricError (F &&fun, std::string_view msg)
static FabricInfo clone (::fi_info const *) noexcept
 RAII wrapper around a libfabric `fi_info`` structure.
FabricAddressFormat convertAddressFormat (std::uint32_t fiAddrFormat)
 Convert from libfabric address format value to FabricAddressFormat.
void drainEventQueue (EventQueue &eq)
 Read all entries from a connectionless endpoint's event queue and log the errors among them.
static FabricInfo empty () noexcept
 Create and empty FabricInfo.
 FabricInfo (::fi_info *) noexcept
 Private constructor can only be called by static members. Used to enforce clear ownership semantics.
 FabricInfo (FabricInfo &&other) noexcept
 FabricInfo (FabricInfo const &) noexcept
 FabricInfo (FabricInfoView) noexcept
 Create an owning FabricInfo object from a non-owning view.
template<typename F, typename... T>
int fiCall (F &&fun, std::string_view msg, T &&... args)
 Call a libfabric function and check its return code.
void fiInitLogging ()
 Initalize logging for libfabric. After this call, all libfabric internal logs will be written to the mxl logging system. It is save to call this function multiple times and concurrently from different threads. If this function throws an exception, the program cannot continue.
std::string fiToString (void *any, ::fi_type type)
std::uint32_t fiVersion () noexcept
 Returns the libfabric version this library was compiled with.
void free () noexcept
 Called internally to release the ::fi_info object.
mxlFabricsInitiatorConfig getDefaultInitiatorConfig (mxlFlowReader reader)
mxlFabricsTargetConfig getDefaultTargetConfig (mxlFlowWriter writer)
std::shared_ptr< Domain > getDomain (bool virtualAddress=false, bool rx_cq_data_mode=false)
MxlRegions getEmptyVideoMxlRegions ()
std::uint64_t getGrainIndexInRingSlot (std::vector< Region > const &regions, std::uint16_t slot)
std::pair< MxlRegions, InnerRegions > getHostRegionGroups ()
MxlRegions getMxlRegions (std::vector< std::vector< std::uint8_t > > const &innerRegions, DataLayout dataLayout=DataLayout::fromDiscrete({8, 0, 0, 0}, 1))
std::string interfaceCapsString (std::uint64_t caps)
FabricAddressFormat mustConvertAddressFormat (std::uint32_t fiAddrFormat)
 Convert from libfabric address format value to FabricAddressFormat Never returns FabricAddressFormat::Unspec, and throws InvalidArgument instead.
MxlRegions mxlFabricsRegionsFromFlow (FlowData const &flow)
 Convert a FlowData's memory regions to MxlRegions. FlowData are obtained from an MXL FlowWriter or FlowReader.
MxlRegions mxlFabricsRegionsFromMutableFlow (FlowData &flow)
 Convert a FlowData's memory regions to MxlRegions. FlowData are obtained from an MXL FlowWriter or FlowReader.
mxlStatus mxlStatusFromFiErrno (int fiErrno)
 Convert an error code returned by libfabric to an appropriate mxlStatus code.
::fi_info & operator* () noexcept
 Dereferencing the FabricInfo return the raw ::fi_info object managed by this object.
::fi_info * operator-> () noexcept
 Dereferencing the FabricInfo return the raw ::fi_info object managed by this object.
FabricInfo & operator= (FabricInfo &&) noexcept
void operator= (FabricInfo const &other) noexcept
static FabricInfo own (::fi_info *) noexcept
 Own an existing ::fi_info object.
FabricInterfaceList probeInterfaces (std::optional< std::reference_wrapper<::mxlFabricsInterfaceConfig const > > query)
std::optional< Provider > providerFromAPI (mxlFabricsProvider api) noexcept
 Convert between external and internal versions of this type.
std::optional< Provider > providerFromString (std::string const &s) noexcept
 Parse a provider name string, and return the enum value.
mxlFabricsProvider providerToAPI (Provider provider) noexcept
 Convert between external and internal versions of this type.
::fi_info * raw () noexcept
 Returns the raw ::fi_info object managed by this FabricInfo instance.
template<QueueReadMode qrm>
std::optional< Completion > readCompletionQueue (CompletionQueue &eq, std::chrono::steady_clock::duration timeout)
 Helper to read a completion queue with blocking or non-blocking behaviour.
template<QueueReadMode qrm>
std::pair< std::optional< Completion >, std::optional< Event > > readEndpointQueues (Endpoint &ep, std::chrono::steady_clock::duration timeout)
 Helper to read both completion and event queues of an endpoint with blocking or non-blocking behaviour.
template<QueueReadMode qrm>
std::optional< Event > readEventQueue (EventQueue &eq, std::chrono::steady_clock::duration timeout)
 Helper to read an event queue with blocking or non-blocking behaviour.
void requireCapability (FabricInfoView info, std::uint64_t cap, std::string_view message)
std::unique_ptr< EgressProtocolTemplate > selectEgressProtocol (DataLayout const &layout, std::vector< Region > regions)
 Select an appropriate egress protocol based on the data layout.
std::unique_ptr< IngressProtocol > selectIngressProtocol (DataLayout const &layout, std::vector< Region > regions, std::uint32_t maxSyncBatchSize)
 Select an appropriate ingress protocol based on the data layout.
std::pair< FabricInfo, ProviderConfig > selectSourceInterface (::mxlFabricsInterfaceConfig const &interfaceConfig, bool isTarget)
void setDeviceId (::fi_mr_attr &attr, Region::Location loc)
void setValidSlicesForGrain (std::vector< Region > const &regions, std::uint16_t slot, std::uint16_t validSlices)
std::vector< LocalRegion > toLocal (std::vector< RegisteredRegion > const &groups) noexcept
std::vector< RemoteRegion > toRemote (std::vector< RegisteredRegion > const &groups, bool useVirtualAddress) noexcept
FabricInfoView view () const noexcept
 Return a non-owning view of the FabricInfo.
 ~FabricInfo () noexcept

Variables

::fi_info * _raw
static std::map< std::string_view, Provider > const providerStringMap

Typedef Documentation

◆ InnerRegion

using mxl::lib::fabrics::ofi::InnerRegion = std::vector<std::uint8_t>

Definition at line 22 of file Util.hpp.

◆ InnerRegions

Definition at line 23 of file Util.hpp.

Enumeration Type Documentation

◆ FabricAddressFormat

enum class mxl::lib::fabrics::ofi::FabricAddressFormat : std::uint32_t
strong
Enumerator
Unspec 
Sockaddr 
SockaddrIp 
SockaddrIn 
SockaddrIn6 
SockaddrIb 
Efa 
String 

Definition at line 16 of file FabricAddress.hpp.

17 {
18 Unspec = static_cast<std::uint32_t>(FI_ADDR_UNSPEC), // Unspecified
19 Sockaddr = FI_SOCKADDR, // Any socket address, including infiniband
20 SockaddrIp = FI_SOCKADDR_IP, // Any socket address, but infiniband is not valid
21 SockaddrIn = FI_SOCKADDR_IN, // AF_INET socket address
22 SockaddrIn6 = FI_SOCKADDR_IN6, // AF_INET6 socket address
23 SockaddrIb = FI_SOCKADDR_IB, // AF_IB socket address
24 Efa = FI_ADDR_EFA, // EFA specific proprietary address format
25 String = FI_ADDR_STR, // String address in the form of scheme://addr, example: fi_ns://<node>:<service>
26 };

◆ Provider

Internal representation of supported libfabric providers.

Enumerator
ANY 
TCP 
VERBS 
EFA 
SHM 

Definition at line 16 of file Provider.hpp.

◆ QueueReadMode

Enum to select blocking or non-blocking queue read behaviour.

Enumerator
Blocking 
NonBlocking 

Definition at line 24 of file QueueHelpers.hpp.

Function Documentation

◆ catchAndLogFabricError()

template<typename F>
void mxl::lib::fabrics::ofi::catchAndLogFabricError ( F && fun,
std::string_view msg )

Definition at line 168 of file Exception.hpp.

169 {
170 try
171 {
172 fun();
173 }
174 catch (FabricException const& e)
175 {
176 MXL_ERROR("FabricException caught: {}: {}", msg, e.what());
177 }
178 }
#define MXL_ERROR(...)
Definition Logging.hpp:67

◆ clone()

FabricInfo mxl::lib::fabrics::ofi::FabricInfo::clone ( ::fi_info const * info)
staticnoexcept

RAII wrapper around a libfabric `fi_info`` structure.

Manages the lifetime of a fi_info object, ensuring that it is properly deallocated when the FabricInfo object goes out of scope. */ class FabricInfo { public: /** Clone an existing ::fi_info structure, take ownership of the cloned object.

Definition at line 28 of file FabricInfo.cpp.

29 {
30 return FabricInfo{::fi_dupinfo(info)};
31 }
FabricInfo(FabricInfoView) noexcept
Create an owning FabricInfo object from a non-owning view.

◆ convertAddressFormat()

FabricAddressFormat mxl::lib::fabrics::ofi::convertAddressFormat ( std::uint32_t fiAddrFormat)
nodiscard

Convert from libfabric address format value to FabricAddressFormat.

Definition at line 191 of file FabricAddress.cpp.

◆ drainEventQueue()

void mxl::lib::fabrics::ofi::drainEventQueue ( EventQueue & eq)
inline

Read all entries from a connectionless endpoint's event queue and log the errors among them.

The errors concern work the provider does on its own behalf, such as EFA's peer handshake, so they are only logged.

Parameters
eqThe event queue to drain.

Definition at line 115 of file QueueHelpers.hpp.

116 {
117 try
118 {
119 while (auto event = eq.read())
120 {
121 if (event->isError())
122 {
123 auto const& error = event->error();
124 // The provider code is logged as a number: fi_strerror() would name an unrelated error.
125 MXL_WARN("Event queue error: {} ({}), provider code {}", ::fi_strerror(error.code()), error.code(), error.providerCode());
126 }
127 }
128 }
129 catch (Exception const& ex)
130 {
131 MXL_WARN("Unhandled entry on the event queue: {}", ex.what());
132 }
133 }
#define MXL_WARN(...)
Definition Logging.hpp:56
std::optional< Event > read()
Perform a non-blocking read on the event queue. If no event is available in the queue,...

◆ empty()

FabricInfo mxl::lib::fabrics::ofi::empty ( )
staticnoexcept

Create and empty FabricInfo.

◆ FabricInfo() [1/4]

mxl::lib::fabrics::ofi::FabricInfo ( ::fi_info * )
explicitprivatenoexcept

Private constructor can only be called by static members. Used to enforce clear ownership semantics.

◆ FabricInfo() [2/4]

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

◆ FabricInfo() [3/4]

mxl::lib::fabrics::ofi::FabricInfo ( FabricInfo const & )
noexcept

◆ FabricInfo() [4/4]

mxl::lib::fabrics::ofi::FabricInfo ( FabricInfoView )
noexcept

Create an owning FabricInfo object from a non-owning view.

◆ fiCall()

template<typename F, typename... T>
int mxl::lib::fabrics::ofi::fiCall ( F && fun,
std::string_view msg,
T &&... args )

Call a libfabric function and check its return code.

If the code is not FI_SUCCESS, throws an FabricException that includes the error code, and the message passed in as the second argument.

Definition at line 155 of file Exception.hpp.

156 {
157 int result = fun(std::forward<T>(args)...);
158 if (result < 0)
159 {
160 auto str = ::fi_strerror(result);
161 throw FabricException::make(result, "{}: {}, code {}", msg, str, result);
162 }
163
164 return result;
165 }
static FabricException make(int fiErrno, fmt::format_string< T... > fmt, T &&... args)
Create a new exception object.

◆ fiInitLogging()

void mxl::lib::fabrics::ofi::fiInitLogging ( )

Initalize logging for libfabric. After this call, all libfabric internal logs will be written to the mxl logging system. It is save to call this function multiple times and concurrently from different threads. If this function throws an exception, the program cannot continue.

Definition at line 160 of file FILogging.cpp.

161 {
162 logging.init();
163 }

◆ fiToString()

std::string mxl::lib::fabrics::ofi::fiToString ( void * any,
::fi_type type )

Definition at line 45 of file Format.cpp.

46 {
47 auto buf = std::string((type == FI_TYPE_INFO) ? 4096 : 1024, '\0');
48 ::fi_tostr_r(buf.data(), buf.size(), any, type);
49 buf.resize(::strlen(buf.data()));
50 return buf;
51 }

◆ fiVersion()

std::uint32_t mxl::lib::fabrics::ofi::fiVersion ( )
noexcept

Returns the libfabric version this library was compiled with.

Definition at line 10 of file FabricVersion.cpp.

11 {
12 return FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION);
13 }

◆ free()

void mxl::lib::fabrics::ofi::free ( )
privatenoexcept

Called internally to release the ::fi_info object.

◆ getDefaultInitiatorConfig()

mxlFabricsInitiatorConfig mxl::lib::fabrics::ofi::getDefaultInitiatorConfig ( mxlFlowReader reader)
inline

Definition at line 36 of file Util.hpp.

37 {
38 auto config = mxlFabricsInitiatorConfig{};
39 config.interface.address.node = "127.0.0.1";
40 config.interface.address.service = "9091";
41 config.interface.provider = MXL_FABRICS_PROVIDER_TCP;
42 config.reader = reader;
43 return config;
44 }
@ MXL_FABRICS_PROVIDER_TCP
Definition fabrics.h:49
struct mxlFabricsInitiatorConfig_t mxlFabricsInitiatorConfig
mxlFlowReader reader

◆ getDefaultTargetConfig()

mxlFabricsTargetConfig mxl::lib::fabrics::ofi::getDefaultTargetConfig ( mxlFlowWriter writer)
inlinenodiscard

Definition at line 26 of file Util.hpp.

27 {
28 auto config = mxlFabricsTargetConfig{};
29 config.interface.address.node = "127.0.0.1";
30 config.interface.address.service = "9090";
31 config.interface.provider = MXL_FABRICS_PROVIDER_TCP;
32 config.writer = writer;
33 return config;
34 }
struct mxlFabricsTargetConfig_t mxlFabricsTargetConfig
mxlFlowWriter writer

◆ getDomain()

std::shared_ptr< Domain > mxl::lib::fabrics::ofi::getDomain ( bool virtualAddress = false,
bool rx_cq_data_mode = false )
inline

Definition at line 46 of file Util.hpp.

47 {
48 auto providerConfig = ProviderConfig::tcp(false, std::nullopt);
49 auto fabricAddress = FabricAddress::parse(Provider::TCP, "127.0.0.1", "1111");
50
51 auto infoList = FabricInfoList::getSourceInterfaces(providerConfig, fabricAddress);
52 auto info = *infoList.begin();
53
54 auto fabric = Fabric::open(info);
55 auto domain = Domain::open(fabric);
56
57 if (virtualAddress)
58 {
59 fabric->info()->domain_attr->mr_mode |= FI_MR_VIRT_ADDR;
60 }
61 else
62 {
63 fabric->info()->domain_attr->mr_mode &= ~FI_MR_VIRT_ADDR;
64 }
65
66 if (rx_cq_data_mode)
67 {
68 fabric->info()->rx_attr->mode |= FI_RX_CQ_DATA;
69 }
70 else
71 {
72 fabric->info()->rx_attr->mode &= ~FI_RX_CQ_DATA;
73 }
74
75 return domain;
76 }
static std::shared_ptr< Domain > open(std::shared_ptr< Fabric > fabric)
Open a new domain associated with the specified fabric.
Definition Domain.cpp:30
static FabricAddress parse(Provider provider, std::optional< std::string > node, std::optional< std::string > service)
Parse a node/service pair into a typed address for the given provider.
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 prov...
static std::shared_ptr< Fabric > open(FabricInfoView info)
Open a fabric object based on the provided FabricInfoView.
Definition Fabric.cpp:15
static ProviderConfig tcp(bool isTarget, std::optional< ProviderCapabilities > capabilities)

◆ getEmptyVideoMxlRegions()

MxlRegions mxl::lib::fabrics::ofi::getEmptyVideoMxlRegions ( )
inline

Definition at line 78 of file Util.hpp.

79 {
80 return MxlRegions({}, DataLayout::fromDiscrete({8, 0, 0, 0}, 1));
81 }
static DataLayout fromDiscrete(std::array< std::uint32_t, MXL_MAX_PLANES_PER_GRAIN > const &sliceSizes, std::uint16_t totalSlices) noexcept
Create a DataLayout representing video data.
Represent a collection of memory regions.
Definition Region.hpp:203

◆ getGrainIndexInRingSlot()

std::uint64_t mxl::lib::fabrics::ofi::getGrainIndexInRingSlot ( std::vector< Region > const & regions,
std::uint16_t slot )

Definition at line 208 of file Region.cpp.

209 {
210 if (slot >= regions.size())
211 {
212 throw Exception::invalidArgument("Invalid ring buffer slot number: {}, ring buffer len: {}", slot, regions.size());
213 }
214
215 return *regions[slot].grainIndexPtr;
216 }
static Exception invalidArgument(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_ARG exception.
Definition Exception.hpp:43

◆ getHostRegionGroups()

std::pair< MxlRegions, InnerRegions > mxl::lib::fabrics::ofi::getHostRegionGroups ( )
inline

Warning: Do not modify the values below, you will break many tests

Definition at line 83 of file Util.hpp.

84 {
86 auto innerRegions = std::vector<std::vector<std::uint8_t>>{
87 std::vector<std::uint8_t>(256),
88 std::vector<std::uint8_t>(512),
89 std::vector<std::uint8_t>(1024),
90 std::vector<std::uint8_t>(2048),
91 };
92
93 auto regions = std::vector<Region>{};
94 regions.reserve(innerRegions.size());
95 for (auto const& innerRegion : innerRegions)
96 {
97 regions.emplace_back(*innerRegion.data(), innerRegion.size(), nullptr, nullptr);
98 }
99
100 auto mxlRegions = MxlRegions(regions, DataLayout::fromDiscrete({8, 0, 0, 0}, 1));
101 return {mxlRegions, innerRegions};
102 }

◆ getMxlRegions()

MxlRegions mxl::lib::fabrics::ofi::getMxlRegions ( std::vector< std::vector< std::uint8_t > > const & innerRegions,
DataLayout dataLayout = DataLayout::fromDiscrete({8, 0, 0, 0}, 1) )
inline

Definition at line 104 of file Util.hpp.

105 {8, 0, 0, 0}, 1))
106 {
107 auto regions = std::vector<Region>{};
108 regions.reserve(innerRegions.size());
109 for (auto const& innerRegion : innerRegions)
110 {
111 regions.emplace_back(*innerRegion.data(), innerRegion.size(), nullptr, nullptr);
112 }
113 return {regions, dataLayout};
114 }

◆ interfaceCapsString()

std::string mxl::lib::fabrics::ofi::interfaceCapsString ( std::uint64_t caps)

Definition at line 11 of file Format.cpp.

12 {
13 auto resultLength = std::size_t{0};
14 auto capStrings = std::vector<std::string>{};
16 {
17 resultLength += capStrings.emplace_back("BLOCKING_OPERATIONS").size();
18 }
19 if ((caps & MXL_FABRICS_IFACE_CAP_REMOTE_WRITE) != 0)
20 {
21 resultLength += capStrings.emplace_back("REMOTE_WRITE").size();
22 }
23 if ((caps & MXL_FABRICS_IFACE_CAP_SEND_RECEIVE) != 0)
24 {
25 resultLength += capStrings.emplace_back("SEND_RECEIVE").size();
26 }
27 if (capStrings.empty())
28 {
29 resultLength += capStrings.emplace_back("<none>").size();
30 }
31
32 resultLength += (capStrings.size() - 1); // separating '|' chars
33
34 auto result = capStrings.front();
35 result.reserve(resultLength);
36 for (auto it = capStrings.begin() + 1; it != capStrings.end(); ++it)
37 {
38 result.push_back('|');
39 result.append(*it);
40 }
41
42 return result;
43 }
@ MXL_FABRICS_IFACE_CAP_SEND_RECEIVE
Definition fabrics.h:80
@ MXL_FABRICS_IFACE_CAP_BLOCKING_OPERATIONS
Definition fabrics.h:78
@ MXL_FABRICS_IFACE_CAP_REMOTE_WRITE
Definition fabrics.h:79

◆ mustConvertAddressFormat()

FabricAddressFormat mxl::lib::fabrics::ofi::mustConvertAddressFormat ( std::uint32_t fiAddrFormat)
nodiscard

Convert from libfabric address format value to FabricAddressFormat Never returns FabricAddressFormat::Unspec, and throws InvalidArgument instead.

Definition at line 214 of file FabricAddress.cpp.

215 {
216 auto val = convertAddressFormat(fiAddrFormat);
218 {
219 throw Exception::invalidArgument("Invalid or unsupported address format value: {}", fiToString(&fiAddrFormat, FI_TYPE_ADDR_FORMAT));
220 }
221
222 return val;
223 }
FabricAddressFormat convertAddressFormat(std::uint32_t fiAddrFormat)
Convert from libfabric address format value to FabricAddressFormat.
std::string fiToString(void *any, ::fi_type type)
Definition Format.cpp:45

◆ mxlFabricsRegionsFromFlow()

MxlRegions mxl::lib::fabrics::ofi::mxlFabricsRegionsFromFlow ( FlowData const & flow)
nodiscard

Convert a FlowData's memory regions to MxlRegions. FlowData are obtained from an MXL FlowWriter or FlowReader.

Definition at line 153 of file Region.cpp.

154 {
155 static_assert(sizeof(GrainHeader) == 8192,
156 "GrainHeader type size changed! The Fabrics API makes assumptions on the memory layout of a flow, please review the code below if the "
157 "change is intended!");
158
159 if (flow.flowInfo()->config.common.payloadLocation != MXL_PAYLOAD_LOCATION_HOST_MEMORY)
160 {
162 "GPU memory is not currently supported in the Flow API of MXL. Edit the code below when it is supported");
163 }
164
165 if (mxlIsDiscreteDataFormat(static_cast<int>(flow.flowInfo()->config.common.format)))
166 {
167 auto const& discreteFlow = static_cast<DiscreteFlowData const&>(flow);
168 auto regions = std::vector<Region>{};
169 regions.reserve(discreteFlow.grainCount());
170 for (auto i = std::size_t{0}; i < discreteFlow.grainCount(); ++i)
171 {
172 auto grain = discreteFlow.grainAt(i);
173
174 auto grainInfoBaseAddr = reinterpret_cast<std::uintptr_t>(discreteFlow.grainAt(i));
175 auto grainInfoSize = sizeof(GrainHeader);
176 auto grainPayloadSize = grain->header.info.grainSize;
177
178 regions.emplace_back(grainInfoBaseAddr, grainInfoSize + grainPayloadSize, nullptr, nullptr, Region::Location::host());
179 }
180
181 auto const totalSlices = discreteFlow.grainAt(0)->header.info.totalSlices;
182 return {std::move(regions),
183 DataLayout::fromDiscrete(std::to_array(discreteFlow.flowInfo()->config.discrete.sliceSizes), totalSlices),
184 discreteFlow.flowInfo()->config.common.maxSyncBatchSizeHint};
185 }
186 else if (mxlIsContinuousDataFormat(static_cast<int>(flow.flowInfo()->config.common.format)))
187 {
188 auto const& continuousFlow = static_cast<ContinuousFlowData const&>(flow);
189 auto regions = std::vector<Region>{};
190
191 // For the continuous flow, the data layout is a single contiguous buffer
192 regions.emplace_back(reinterpret_cast<std::uintptr_t>(continuousFlow.channelData()),
193 continuousFlow.channelDataSize(),
194 nullptr,
195 nullptr,
197
198 return {std::move(regions),
199 DataLayout::fromContinuous(continuousFlow.sampleWordSize(), continuousFlow.channelCount(), continuousFlow.channelBufferLength()),
200 continuousFlow.flowInfo()->config.common.maxSyncBatchSizeHint};
201 }
202 else
203 {
204 throw Exception::make(MXL_ERR_UNKNOWN, "Unsupported flow fromat {}", flow.flowInfo()->config.common.format);
205 }
206 }
Grain * grainAt(std::size_t i) noexcept
static DataLayout fromContinuous(std::size_t sampleSize, std::size_t channelCount, std::size_t bufferLength) noexcept
Create a DataLayout representing audio data.
static Exception make(mxlStatus status, fmt::format_string< T... > fmt, T &&... args)
Make any type of exception.
Definition Exception.hpp:35
static Location host() noexcept
specify a host memory location.
Definition Region.cpp:23
int mxlIsContinuousDataFormat(int format)
Definition dataformat.h:106
int mxlIsDiscreteDataFormat(int format)
Definition dataformat.h:75
@ MXL_PAYLOAD_LOCATION_HOST_MEMORY
Definition flowinfo.h:39
@ MXL_ERR_UNKNOWN
Definition mxl.h:27
uint16_t totalSlices
Definition flow.h:146
mxlGrainInfo info
Definition Flow.hpp:42
GrainHeader header
Definition Flow.hpp:57

◆ mxlFabricsRegionsFromMutableFlow()

MxlRegions mxl::lib::fabrics::ofi::mxlFabricsRegionsFromMutableFlow ( FlowData & flow)
nodiscard

Convert a FlowData's memory regions to MxlRegions. FlowData are obtained from an MXL FlowWriter or FlowReader.

Definition at line 130 of file Region.cpp.

131 {
132 auto mxlRegions = mxlFabricsRegionsFromFlow(flow);
133
134 if (mxlIsDiscreteDataFormat(static_cast<int>(flow.flowInfo()->config.common.format)))
135 {
136 auto& discreteFlow = static_cast<DiscreteFlowData&>(flow);
137
138 if (mxlRegions._regions.size() != discreteFlow.grainCount())
139 {
140 throw Exception::invalidState("Unexpected number of grains in discrete flow");
141 }
142
143 for (std::size_t i = 0; i < discreteFlow.grainCount(); ++i)
144 {
145 mxlRegions._regions[i].grainIndexPtr = &discreteFlow.grainAt(i)->header.info.index;
146 mxlRegions._regions[i].validSlicesPtr = &discreteFlow.grainAt(i)->header.info.validSlices;
147 }
148 }
149
150 return mxlRegions;
151 }
constexpr mxlFlowInfo * flowInfo() noexcept
Definition FlowData.hpp:92
static Exception invalidState(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_STATE exception.
Definition Exception.hpp:59
MxlRegions mxlFabricsRegionsFromFlow(FlowData const &flow)
Convert a FlowData's memory regions to MxlRegions. FlowData are obtained from an MXL FlowWriter or Fl...
Definition Region.cpp:153
mxlCommonFlowConfigInfo common
Definition flowinfo.h:178
mxlFlowConfigInfo config
Definition flowinfo.h:227

◆ mxlStatusFromFiErrno()

mxlStatus mxl::lib::fabrics::ofi::mxlStatusFromFiErrno ( int fiErrno)

Convert an error code returned by libfabric to an appropriate mxlStatus code.

Definition at line 41 of file Exception.cpp.

42 {
43 switch (fiErrno)
44 {
45 case -FI_EINTR: return MXL_ERR_INTERRUPTED;
46 case -FI_EAGAIN: return MXL_ERR_NOT_READY;
47 case -FI_ENOSYS: return MXL_ERR_UNSUPPORTED_OPERATION;
48 default: return MXL_ERR_UNKNOWN;
49 }
50 }
@ MXL_ERR_NOT_READY
Definition mxl.h:49
@ MXL_ERR_INTERRUPTED
Definition mxl.h:45
@ MXL_ERR_UNSUPPORTED_OPERATION
Definition mxl.h:52

◆ operator*()

fi_info const & mxl::lib::fabrics::ofi::operator* ( ) const
nodiscardnoexcept

Dereferencing the FabricInfo return the raw ::fi_info object managed by this object.

Dereferencing the FabricInfo return the raw ::fi_info object managed by this object.

◆ operator->()

fi_info const * mxl::lib::fabrics::ofi::operator-> ( )
nodiscardnoexcept

Dereferencing the FabricInfo return the raw ::fi_info object managed by this object.

◆ operator=() [1/2]

FabricInfo & mxl::lib::fabrics::ofi::operator= ( FabricInfo && )
noexcept

◆ operator=() [2/2]

void mxl::lib::fabrics::ofi::operator= ( FabricInfo const & other)
noexcept

◆ own()

FabricInfo mxl::lib::fabrics::ofi::own ( ::fi_info * )
staticnoexcept

Own an existing ::fi_info object.

The object will be free'd when the FabricInfo object goes out of scope.

◆ probeInterfaces()

FabricInterfaceList mxl::lib::fabrics::ofi::probeInterfaces ( std::optional< std::reference_wrapper<::mxlFabricsInterfaceConfig const > > query)
nodiscard

Query path: enumerate all available fabric interfaces matching the optional filter criteria. Capabilities in the query are ignored and all matching interfaces are returned with their reported capabilities as informational output. When query is nullopt, all interfaces across all providers are returned.

Definition at line 72 of file FabricInterfaceProbe.cpp.

73 {
74 // Maps of provider specific configurations and addresses. They are lazily created when they appear on the fabric list.
75 auto providerConfigs = std::map<Provider, ProviderConfig>{};
76 auto fabricAddresses = std::map<Provider, std::optional<FabricAddress>>{};
77 auto getProviderConfig = [&](Provider provider) -> ProviderConfig const&
78 {
79 auto it = providerConfigs.lower_bound(provider);
80 if ((it == providerConfigs.end()) || (it->first != provider))
81 {
82 it = providerConfigs.emplace_hint(it, provider, ProviderConfig::create(provider, false, std::nullopt));
83 }
84
85 return it->second;
86 };
87
88 auto getFabricAddress = [&](Provider provider) -> std::optional<FabricAddress> const&
89 {
90 auto it = fabricAddresses.lower_bound(provider);
91 if ((it == fabricAddresses.end()) || (it->first != provider))
92 {
93 try
94 {
95 it = fabricAddresses.emplace_hint(it,
96 provider,
97 FabricAddress::parse(provider,
98 query ? optStringFromCStr(query.value().get().address.node) : std::nullopt,
99 query ? optStringFromCStr(query.value().get().address.service) : std::nullopt));
100 }
101 catch (Exception const&)
102 {
103 it = fabricAddresses.emplace_hint(it, provider, std::nullopt);
104 }
105 }
106
107 return it->second;
108 };
109
110 // clang-format off
111 auto const requestedProvider = query
112 ? providerFromAPI(query.value().get().provider)
113 : Provider::ANY;
114 // clang-format on
115 if (!requestedProvider)
116 {
117 throw Exception::invalidArgument("Invalid provider");
118 }
119
120 auto list = FabricInterfaceList{};
121 for (auto&& info : FabricInfoList::get())
122 {
123 // Ignore if the provider of this fabric info is not known.
124 auto provider = providerFromString(info->fabric_attr->prov_name);
125 if (!provider)
126 {
127 continue;
128 }
129
130 // Ignore if a specific provider is requested, and this one does not match.
131 if ((requestedProvider != Provider::ANY) && (provider != requestedProvider))
132 {
133 continue;
134 }
135
136 // Ignore if the query address could not be parsed for this provider
137 auto const& address = getFabricAddress(*provider);
138 if (!address)
139 {
140 continue;
141 }
142
143 // Ignore if the info does not match the requested address
144 if (!matchesRequestedAddress(*address, info))
145 {
146 continue;
147 }
148
149 // Ignore if no supported.
150 auto const& config = getProviderConfig(*provider);
151 if (config.isSupportedFabricInfo(info))
152 {
153 auto description = FabricInterfaceDescription::create(info);
154 if (description)
155 {
156 list.push(*description);
157 }
158 }
159 }
160
161 return list;
162 }
Custom exception type used in the fabrics library.
Definition Exception.hpp:28
static FabricInfoList get()
Calls fi_getinfo without any hints and returns the full list of fabric information objects.
static std::optional< FabricInterfaceDescription > create(FabricInfoView info)
static ProviderConfig create(Provider provider, bool isTarget, std::optional< ProviderCapabilities > capabilities)
std::optional< Provider > providerFromString(std::string const &s) noexcept
Parse a provider name string, and return the enum value.
Definition Provider.cpp:49
std::optional< Provider > providerFromAPI(mxlFabricsProvider api) noexcept
Convert between external and internal versions of this type.
Definition Provider.cpp:35
Provider
Internal representation of supported libfabric providers.
Definition Provider.hpp:17

◆ providerFromAPI()

std::optional< Provider > mxl::lib::fabrics::ofi::providerFromAPI ( mxlFabricsProvider api)
noexcept

Convert between external and internal versions of this type.

Definition at line 35 of file Provider.cpp.

36 {
37 switch (api)
38 {
44 }
45
46 return std::nullopt;
47 }
@ MXL_FABRICS_PROVIDER_VERBS
Definition fabrics.h:50
@ MXL_FABRICS_PROVIDER_ANY
Definition fabrics.h:48
@ MXL_FABRICS_PROVIDER_SHM
Definition fabrics.h:52
@ MXL_FABRICS_PROVIDER_EFA
Definition fabrics.h:51

◆ providerFromString()

std::optional< Provider > mxl::lib::fabrics::ofi::providerFromString ( std::string const & s)
noexcept

Parse a provider name string, and return the enum value.

Returns std::nullopt if the string passed was not a valid provider name.

Definition at line 49 of file Provider.cpp.

50 {
51 auto it = providerStringMap.find(s);
52 if (it == providerStringMap.end())
53 {
54 return std::nullopt;
55 }
56
57 return it->second;
58 }
static std::map< std::string_view, Provider > const providerStringMap
Definition Provider.cpp:13

◆ providerToAPI()

mxlFabricsProvider mxl::lib::fabrics::ofi::providerToAPI ( Provider provider)
noexcept

Convert between external and internal versions of this type.

Definition at line 21 of file Provider.cpp.

22 {
23 switch (provider)
24 {
30 }
31
33 }

◆ raw()

fi_info const * mxl::lib::fabrics::ofi::raw ( ) const
nodiscardnoexcept

Returns the raw ::fi_info object managed by this FabricInfo instance.

Returns the raw ::fi_info object managed by this FabricInfo instance.

◆ readCompletionQueue()

template<QueueReadMode qrm>
std::optional< Completion > mxl::lib::fabrics::ofi::readCompletionQueue ( CompletionQueue & eq,
std::chrono::steady_clock::duration timeout )

Helper to read a completion queue with blocking or non-blocking behaviour.

Template Parameters
qrmThe queue read mode, either Blocking or NonBlocking.
Parameters
eqThe completion queue to read from.
timeoutThe timeout to use for blocking reads.
Returns
An optional Completion object read from the completion queue.

Definition at line 91 of file QueueHelpers.hpp.

92 {
93 static_assert((qrm == QueueReadMode::Blocking) || (qrm == QueueReadMode::NonBlocking), "Unsupported queue behaviour parameter");
94
95 auto completion = std::optional<Completion>{};
96
97 if constexpr (qrm == QueueReadMode::Blocking)
98 {
99 completion = eq.readBlocking(timeout);
100 }
101 else if constexpr (qrm == QueueReadMode::NonBlocking)
102 {
103 completion = eq.read();
104 }
105
106 return completion;
107 }
std::optional< Completion > readBlocking(std::chrono::steady_clock::duration timeout)
Perform a blocking read on the completion queue.
std::optional< Completion > read()
Perform a non-blocking read on the completion queue.

◆ readEndpointQueues()

template<QueueReadMode qrm>
std::pair< std::optional< Completion >, std::optional< Event > > mxl::lib::fabrics::ofi::readEndpointQueues ( Endpoint & ep,
std::chrono::steady_clock::duration timeout )

Helper to read both completion and event queues of an endpoint with blocking or non-blocking behaviour.

Template Parameters
qrmThe queue read mode, either Blocking or NonBlocking.
Parameters
epThe endpoint to read from.
timeoutThe timeout to use for blocking reads.
Returns
A pair of optional Completion and Event objects read from the endpoint queues.
Note
To read only one of the queues, use readCompletionQueue() or readEventQueue().

Definition at line 39 of file QueueHelpers.hpp.

40 {
41 static_assert((qrm == QueueReadMode::Blocking) || (qrm == QueueReadMode::NonBlocking), "Unsupported queue behaviour parameter");
42
43 auto result = std::pair<std::optional<Completion>, std::optional<Event>>{};
44
45 if constexpr (qrm == QueueReadMode::Blocking)
46 {
47 result = ep.readQueuesBlocking(timeout);
48 }
49 else if constexpr (qrm == QueueReadMode::NonBlocking)
50 {
51 result = ep.readQueues();
52 }
53
54 return result;
55 }
std::pair< std::optional< Completion >, std::optional< Event > > readQueues()
Do a non-blocking read of both the event and completion queue associated with this endpoint.
Definition Endpoint.cpp:224
std::pair< std::optional< Completion >, std::optional< Event > > readQueuesBlocking(std::chrono::steady_clock::duration timeout)
Do a combined blocking read of both the event and completion queue associated with this endpoint.
Definition Endpoint.cpp:242

◆ readEventQueue()

template<QueueReadMode qrm>
std::optional< Event > mxl::lib::fabrics::ofi::readEventQueue ( EventQueue & eq,
std::chrono::steady_clock::duration timeout )

Helper to read an event queue with blocking or non-blocking behaviour.

Template Parameters
qrmThe queue read mode, either Blocking or NonBlocking.
Parameters
eqThe event queue to read from.
timeoutThe timeout to use for blocking reads.
Returns
An optional Event object read from the event queue.

Definition at line 65 of file QueueHelpers.hpp.

66 {
67 static_assert((qrm == QueueReadMode::Blocking) || (qrm == QueueReadMode::NonBlocking), "Unsupported queue behaviour parameter");
68
69 auto event = std::optional<Event>{};
70
71 if constexpr (qrm == QueueReadMode::Blocking)
72 {
73 event = eq.readBlocking(timeout);
74 }
75 else if constexpr (qrm == QueueReadMode::NonBlocking)
76 {
77 event = eq.read();
78 }
79
80 return event;
81 }
std::optional< Event > readBlocking(std::chrono::steady_clock::duration timeout)
Perform a blocking read on the event queue.

◆ requireCapability()

void mxl::lib::fabrics::ofi::requireCapability ( FabricInfoView info,
std::uint64_t cap,
std::string_view message )

Definition at line 10 of file FabricInfoHelpers.cpp.

11 {
12 if ((info->caps & cap) != cap)
13 {
14 throw Exception::unsupportedOperation("{}", message);
15 }
16 }
static Exception unsupportedOperation(fmt::format_string< T... > fmt, T &&... args)
Definition Exception.hpp:89

◆ selectEgressProtocol()

std::unique_ptr< EgressProtocolTemplate > mxl::lib::fabrics::ofi::selectEgressProtocol ( DataLayout const & layout,
std::vector< Region > regions )
nodiscard

Select an appropriate egress protocol based on the data layout.

Parameters
layoutThe data layout.
regionsThe regions involved.
Returns
A unique pointer to the selected egress protocol.

Definition at line 33 of file Protocol.cpp.

34 {
35 if (layout.isDiscrete())
36 {
37 return std::make_unique<RMAGrainEgressProtocolTemplate>(layout.asDiscrete(), std::move(regions));
38 }
39 else if (layout.isContinuous())
40 {
41 if (regions.size() != 1)
42 {
43 throw Exception::invalidArgument("Expected exactly 1 region for sample protocol.");
44 }
45 return std::make_unique<RMASampleEgressProtocolTemplate>(layout.asContinuous(), regions.front());
46 }
47 else
48 {
49 throw Exception::invalidArgument("Unsupported data layout");
50 }
51 }

◆ selectIngressProtocol()

std::unique_ptr< IngressProtocol > mxl::lib::fabrics::ofi::selectIngressProtocol ( DataLayout const & layout,
std::vector< Region > regions,
std::uint32_t maxSyncBatchSize )
nodiscard

Select an appropriate ingress protocol based on the data layout.

Parameters
layoutThe data layout.
regionsThe regions involved.
maxSyncBatchSizeThe maximum batch size for transfers.
Returns
A unique pointer to the selected ingress protocol.

Definition at line 13 of file Protocol.cpp.

14 {
15 if (layout.isDiscrete())
16 {
17 return std::make_unique<RMAGrainIngressProtocol>(std::move(regions));
18 }
19 else if (layout.isContinuous())
20 {
21 if (regions.size() != 1)
22 {
23 throw Exception::invalidArgument("Expected exactly 1 region for sample protocol.");
24 }
25 return std::make_unique<RMASampleIngressProtocol>(regions.front(), layout.asContinuous(), maxSyncBatchSize);
26 }
27 else
28 {
29 throw Exception::invalidArgument("Unsupported data layout");
30 }
31 }

◆ selectSourceInterface()

std::pair< FabricInfo, ProviderConfig > mxl::lib::fabrics::ofi::selectSourceInterface ( ::mxlFabricsInterfaceConfig const & interfaceConfig,
bool isTarget )
nodiscard

Setup path: select a single source interface for target or initiator setup. Capabilities from interfaceConfig are treated as requirements if no transfer capability (REMOTE_WRITE or SEND_RECEIVE) is set, REMOTE_WRITE is applied with a warning. Returns the matched fabric info and its resolved provider configuration.

Parameters
isTargettrue for target (FI_REMOTE_WRITE), false for initiator (FI_WRITE).
Exceptions
Exception::noFabricif no matching interface is found or capabilities are unsupported.

Definition at line 164 of file FabricInterfaceProbe.cpp.

165 {
166 auto provider = providerFromAPI(interfaceConfig.provider);
167 if (!provider)
168 {
169 throw Exception::invalidArgument("invalid provider");
170 }
171
172 constexpr auto transferCapsMask = std::uint64_t{MXL_FABRICS_IFACE_CAP_REMOTE_WRITE | MXL_FABRICS_IFACE_CAP_SEND_RECEIVE};
173 auto caps = ProviderCapabilities::fromAPI(interfaceConfig.caps);
174 if ((caps.interfaceCaps & transferCapsMask) == 0)
175 {
177 "Unsupported provider constraints: Missing transfer capability. Need either SEND_RECEIVE or REMOTE_WRITE");
178 }
179 else if ((caps.interfaceCaps & MXL_FABRICS_IFACE_CAP_REMOTE_WRITE) == 0)
180 {
181 throw Exception::noFabric("Unsupported provider constraints: Only REMOTE_WRITE supported at this time.");
182 }
183 if (caps.maxMessageSize == 0)
184 {
185 MXL_WARN("maxMessageSize is not set. This field will be required in a future version.");
186 }
187 auto providerConfig = ProviderConfig::create(*provider, isTarget, caps);
188 auto fabricAddress = FabricAddress::parse(
189 *provider, optStringFromCStr(interfaceConfig.address.node), optStringFromCStr(interfaceConfig.address.service));
190
191 auto sourceInterfaces = FabricInfoList::getSourceInterfaces(providerConfig, fabricAddress);
192 if (std::ranges::distance(sourceInterfaces) == 0)
193 {
194 throw Exception::noFabric("no supported interfaces found");
195 }
196
197 return {*sourceInterfaces.begin(), std::move(providerConfig)};
198 }
static Exception noFabric(fmt::format_string< T... > fmt, T &&... args)
Definition Exception.hpp:95
static ProviderCapabilities fromAPI(::mxlFabricsInterfaceCaps)

◆ setDeviceId()

void mxl::lib::fabrics::ofi::setDeviceId ( ::fi_mr_attr & attr,
Region::Location loc )

Definition at line 20 of file MemoryRegion.cpp.

21 {
22 switch (loc.iface())
23 {
24 case FI_HMEM_CUDA:
25 {
26 attr.device.cuda = loc.id();
27 return;
28 }
29
30 case FI_HMEM_SYSTEM:
31 case FI_HMEM_ROCR:
32 case FI_HMEM_ZE:
33 case FI_HMEM_NEURON:
34 case FI_HMEM_SYNAPSEAI: return;
35 }
36 }
std::uint64_t id() const noexcept
Return the device id. For host location 0 is returned.
Definition Region.cpp:33
::fi_hmem_iface iface() const noexcept
Convert the current location to libfabric "iface" representation.
Definition Region.cpp:47

◆ setValidSlicesForGrain()

void mxl::lib::fabrics::ofi::setValidSlicesForGrain ( std::vector< Region > const & regions,
std::uint16_t slot,
std::uint16_t validSlices )

Definition at line 218 of file Region.cpp.

219 {
220 if (slot >= regions.size())
221 {
222 throw Exception::invalidArgument("Invalid ring buffer slot number: {}, ring buffer len: {}", slot, regions.size());
223 }
224
225 *regions[slot].validSlicesPtr = validSlices;
226 }

◆ toLocal()

std::vector< LocalRegion > mxl::lib::fabrics::ofi::toLocal ( std::vector< RegisteredRegion > const & regions)
noexcept

Generate a list of LocalRegions from a list of RegisteredRegions.

Definition at line 32 of file RegisteredRegion.cpp.

33 {
34 std::vector<LocalRegion> localGroups;
35 std::ranges::transform(groups, std::back_inserter(localGroups), [](RegisteredRegion const& reg) { return reg.toLocal(); });
36 return localGroups;
37 }
Represent a registered memory region.
LocalRegion toLocal() const noexcept
Generate a LocalRegion from this RegisteredRegion.

◆ toRemote()

std::vector< RemoteRegion > mxl::lib::fabrics::ofi::toRemote ( std::vector< RegisteredRegion > const & regions,
bool useVirtualAddress )
noexcept

Generate a list of RemoteRegions from a list of RegisteredRegions.

Parameters
useVirtualAddressIf true, the RemoteRegions will use the virtual addresses. If false, the RemoteRegions will use zero-based addresses.

Definition at line 24 of file RegisteredRegion.cpp.

25 {
26 std::vector<RemoteRegion> remoteGroups;
27 std::ranges::transform(
28 groups, std::back_inserter(remoteGroups), [&](RegisteredRegion const& reg) { return reg.toRemote(useVirtualAddress); });
29 return remoteGroups;
30 }
RemoteRegion toRemote(bool useVirtualAddress) const noexcept
Generate a RemoteRegion from this RegisteredRegion.

◆ view()

FabricInfoView mxl::lib::fabrics::ofi::FabricInfo::view ( ) const
nodiscardnoexcept

Return a non-owning view of the FabricInfo.

Definition at line 105 of file FabricInfo.cpp.

106 {
107 return FabricInfoView{_raw};
108 }
Non-owning view of a FabricInfo. Returned when iterating over a FabricInfoList.

◆ ~FabricInfo()

mxl::lib::fabrics::ofi::FabricInfo::~FabricInfo ( )
noexcept

Definition at line 45 of file FabricInfo.cpp.

46 {
47 free();
48 }
void free() noexcept
Called internally to release the fi_info object.

Variable Documentation

◆ _raw

::fi_info* mxl::lib::fabrics::ofi::_raw
private

Definition at line 100 of file FabricInfo.hpp.

◆ providerStringMap

std::map<std::string_view, Provider> const mxl::lib::fabrics::ofi::providerStringMap
static
Initial value:
= {
{"any", Provider::ANY },
{"tcp", Provider::TCP },
{"verbs", Provider::VERBS},
{"efa", Provider::EFA },
{"shm", Provider::SHM },
}

Definition at line 13 of file Provider.cpp.

13 {
14 {"any", Provider::ANY },
15 {"tcp", Provider::TCP },
16 {"verbs", Provider::VERBS},
17 {"efa", Provider::EFA },
18 {"shm", Provider::SHM },
19 };