MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Format.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 <fmt/base.h>
8#include <fmt/format.h>
9#include <rdma/fabric.h>
10#include <mxl/fabrics.h>
11#include "Provider.hpp"
12
13namespace ofi = mxl::lib::fabrics::ofi;
14
15template<>
16struct fmt::formatter<mxlFabricsProvider>
17{
18 constexpr auto parse(fmt::format_parse_context& ctx)
19 {
20 return ctx.begin();
21 }
22
23 template<typename Context>
24 auto format(mxlFabricsProvider const& provider, Context& ctx) const
25 {
26 switch (provider)
27 {
28 case MXL_FABRICS_PROVIDER_ANY: return fmt::format_to(ctx.out(), "any");
29 case MXL_FABRICS_PROVIDER_TCP: return fmt::format_to(ctx.out(), "tcp");
30 case MXL_FABRICS_PROVIDER_VERBS: return fmt::format_to(ctx.out(), "verbs");
31 case MXL_FABRICS_PROVIDER_EFA: return fmt::format_to(ctx.out(), "efa");
32 case MXL_FABRICS_PROVIDER_SHM: return fmt::format_to(ctx.out(), "shm");
33 default: return fmt::format_to(ctx.out(), "unknown");
34 }
35 }
36};
37
38template<>
39struct fmt::formatter<ofi::Provider>
40{
41 constexpr auto parse(fmt::format_parse_context& ctx)
42 {
43 return ctx.begin();
44 }
45
46 template<typename Context>
47 auto format(ofi::Provider const& provider, Context& ctx) const
48 {
49 switch (provider)
50 {
51 case ofi::Provider::TCP: return fmt::format_to(ctx.out(), "tcp");
52 case ofi::Provider::VERBS: return fmt::format_to(ctx.out(), "verbs");
53 case ofi::Provider::EFA: return fmt::format_to(ctx.out(), "efa");
54 case ofi::Provider::SHM: return fmt::format_to(ctx.out(), "shm");
55 default: return fmt::format_to(ctx.out(), "unknown");
56 }
57 }
58};
59
61{
62 std::string interfaceCapsString(std::uint64_t caps);
63 std::string fiToString(void* any, ::fi_type type);
64}
enum mxlFabricsProvider_t mxlFabricsProvider
@ MXL_FABRICS_PROVIDER_VERBS
Definition fabrics.h:50
@ MXL_FABRICS_PROVIDER_ANY
Definition fabrics.h:48
@ MXL_FABRICS_PROVIDER_TCP
Definition fabrics.h:49
@ MXL_FABRICS_PROVIDER_SHM
Definition fabrics.h:52
@ MXL_FABRICS_PROVIDER_EFA
Definition fabrics.h:51
std::string fiToString(void *any, ::fi_type type)
Definition Format.cpp:45
std::string interfaceCapsString(std::uint64_t caps)
Definition Format.cpp:11
Provider
Internal representation of supported libfabric providers.
Definition Provider.hpp:17
constexpr auto parse(fmt::format_parse_context &ctx)
Definition Format.hpp:18
auto format(mxlFabricsProvider const &provider, Context &ctx) const
Definition Format.hpp:24
auto format(ofi::Provider const &provider, Context &ctx) const
Definition Format.hpp:47
constexpr auto parse(fmt::format_parse_context &ctx)
Definition Format.hpp:41