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

#include <FabricInterfaceDescription.hpp>

Public Member Functions

std::uint64_t caps () const noexcept
 Return the raw MXL_FABRICS_IFACE_CAP_* flags for this interface.
::mxlFabricsInterfaceList * toRawLinkedListNode (::mxlFabricsInterfaceList *next=nullptr)

Static Public Member Functions

static std::optional< FabricInterfaceDescription > create (FabricInfoView info)
::mxlFabricsInterfaceList * freeRawLinkedListNode (::mxlFabricsInterfaceList *)

Private Member Functions

 FabricInterfaceDescription (Provider, std::string, std::string, std::uint64_t, std::uint64_t, picojson::object)

Private Attributes

picojson::object _attr
std::uint64_t _maxMessageSize
std::string _node
Provider _provider
std::uint64_t _rawCaps
std::string _service

Detailed Description

Describes a discovered fabric interface. Created from a libfabric fi_info entry, translating provider-level details into MXL-level capability flags, address information, and device attributes. Instances are used to build the linked list returned by the public mxlFabricsGetInterfaces API.

Definition at line 17 of file FabricInterfaceDescription.hpp.

Constructor & Destructor Documentation

◆ FabricInterfaceDescription()

mxl::lib::fabrics::ofi::FabricInterfaceDescription::FabricInterfaceDescription ( Provider provider,
std::string node,
std::string service,
std::uint64_t rawCaps,
std::uint64_t maxMessageSize,
picojson::object extraInfo )
explicitprivate

Member Function Documentation

◆ caps()

std::uint64_t mxl::lib::fabrics::ofi::FabricInterfaceDescription::caps ( ) const
inlinenodiscardnoexcept

Return the raw MXL_FABRICS_IFACE_CAP_* flags for this interface.

Definition at line 42 of file FabricInterfaceDescription.hpp.

43 {
44 return _rawCaps;
45 }

◆ create()

std::optional< FabricInterfaceDescription > mxl::lib::fabrics::ofi::FabricInterfaceDescription::create ( FabricInfoView info)
staticnodiscard

Create a description from a libfabric fi_info entry. Translates libfabric capabilities (FI_SEND, FI_WRITE, FI_RMA, etc.) into MXL capability flags and extracts NIC, domain, and endpoint attributes. Returns nullopt if the provider is not recognized.

Definition at line 110 of file FabricInterfaceDescription.cpp.

111 {
112 auto caps = std::uint64_t{};
113 auto attr = picojson::object{};
114 auto const provider = providerFromString(info->fabric_attr->prov_name);
115 if (!provider)
116 {
117 return std::nullopt;
118 }
119
120 auto faddr = FabricAddress::fromSource(info);
121 auto node = std::string{};
122 auto service = std::string{};
123 if (*provider == Provider::SHM)
124 {
125 node = getHostname();
126 service = faddr.service().value_or("");
127 }
128 else
129 {
130 node = faddr.node().value_or("");
131 }
132
133 if ((info->caps & (FI_SEND | FI_RECV)) != 0)
134 {
136 }
137 if ((info->caps & (FI_REMOTE_WRITE | FI_WRITE | FI_RMA)) != 0)
138 {
140 }
142 {
144 }
145
146 copyStringProperty(attr, fiToString(&info->addr_format, FI_TYPE_ADDR_FORMAT), "ep_addr_format");
147 copyStringProperty(attr, fiToString(&info->ep_attr->protocol, FI_TYPE_PROTOCOL), "ep_protocol");
148 copyStringProperty(attr, fiToString(&info->ep_attr->type, FI_TYPE_EP_TYPE), "ep_type");
149 copyDomainProperties(attr, info->domain_attr);
150
151 if (info->nic != nullptr)
152 {
153 copyNicProperties(attr, info->nic);
154 }
155
156 if (provider == Provider::TCP)
157 {
158 // For the TCP provider, the device_name is always the domain_attr->name.
159 copyStringProperty(attr, info->domain_attr->name, "device_name");
160 }
161
162 return FabricInterfaceDescription{*provider, std::move(node), std::move(service), caps, info->ep_attr->max_msg_size, std::move(attr)};
163 }
static bool isWaitObjectSupportedForEFA() noexcept
Check if wait any wait object type supported by the EFA provider for this libfabric version.
static FabricAddress fromSource(FabricInfoView info) noexcept
Build a FabricAddress from the source address of info.
FabricInterfaceDescription(Provider, std::string, std::string, std::uint64_t, std::uint64_t, picojson::object)
std::uint64_t caps() const noexcept
Return the raw MXL_FABRICS_IFACE_CAP_* flags for this interface.
@ 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
std::string fiToString(void *any, ::fi_type type)
Definition Format.cpp:45
std::optional< Provider > providerFromString(std::string const &s) noexcept
Parse a provider name string, and return the enum value.
Definition Provider.cpp:49

◆ freeRawLinkedListNode()

mxlFabricsInterfaceList * mxl::lib::fabrics::ofi::FabricInterfaceDescription::freeRawLinkedListNode ( ::mxlFabricsInterfaceList * list)
staticnodiscard

Free a single linked list node and its strdup'd strings. Returns the next pointer.

Definition at line 194 of file FabricInterfaceDescription.cpp.

195 {
196 auto interface = list->interface;
197 auto next = list->next;
198 ::free(const_cast<char*>(interface.address.node));
199 ::free(const_cast<char*>(interface.address.service));
200 ::free(const_cast<char*>(interface.attr));
201 delete list;
202 return next;
203 }
void free() noexcept
Called internally to release the fi_info object.
mxlFabricsInterfaceList * next
Definition fabrics.h:121

◆ toRawLinkedListNode()

mxlFabricsInterfaceList * mxl::lib::fabrics::ofi::FabricInterfaceDescription::toRawLinkedListNode ( ::mxlFabricsInterfaceList * next = nullptr)
nodiscard

Allocate a heap-allocated mxlFabricsInterfaceList node from this description. String fields (node, service, attr) are strdup'd and owned by the node.

Parameters
nextoptional pointer to the next node in the linked list.

Definition at line 165 of file FabricInterfaceDescription.cpp.

166 {
167 auto attr = std::add_pointer_t<char const>{nullptr};
168 if (!_attr.empty())
169 {
170 attr = ::strdup(picojson::value{_attr}.serialize(false).c_str());
171 }
172
173 // clang-format off
174 return new ::mxlFabricsInterfaceList{
175 .next = next,
176 .interface = {
177 .version = MXL_FABRICS_API_VERSION,
178 .provider = providerToAPI(_provider),
179 .caps = {
180 .version = MXL_FABRICS_API_VERSION,
181 .flags = _rawCaps,
182 .maxMessageSize = _maxMessageSize,
183 },
184 .address = {
185 .node = ::strdup(_node.c_str()),
186 .service = ::strdup(_service.c_str()),
187 },
188 .attr = attr,
189 },
190 };
191 // clang-format on
192 }
#define MXL_FABRICS_API_VERSION
Definition fabrics.h:19
mxlFabricsProvider providerToAPI(Provider provider) noexcept
Convert between external and internal versions of this type.
Definition Provider.cpp:21
mxlFabricsInterfaceConfig interface
Definition fabrics.h:122

Member Data Documentation

◆ _attr

picojson::object mxl::lib::fabrics::ofi::FabricInterfaceDescription::_attr
private

Definition at line 56 of file FabricInterfaceDescription.hpp.

◆ _maxMessageSize

std::uint64_t mxl::lib::fabrics::ofi::FabricInterfaceDescription::_maxMessageSize
private

Definition at line 54 of file FabricInterfaceDescription.hpp.

◆ _node

std::string mxl::lib::fabrics::ofi::FabricInterfaceDescription::_node
private

Definition at line 52 of file FabricInterfaceDescription.hpp.

◆ _provider

Provider mxl::lib::fabrics::ofi::FabricInterfaceDescription::_provider
private

Definition at line 51 of file FabricInterfaceDescription.hpp.

◆ _rawCaps

std::uint64_t mxl::lib::fabrics::ofi::FabricInterfaceDescription::_rawCaps
private

Definition at line 55 of file FabricInterfaceDescription.hpp.

◆ _service

std::string mxl::lib::fabrics::ofi::FabricInterfaceDescription::_service
private

Definition at line 53 of file FabricInterfaceDescription.hpp.


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