Skip to content

Commit 087e196

Browse files
committed
#2216: Fix issue with namespace when using external and bundled fmt versions. Make 9.1.0 fmt version as required for external fmt
1 parent 91513d4 commit 087e196

File tree

10 files changed

+221
-218
lines changed

10 files changed

+221
-218
lines changed

cmake/load_bundled_libraries.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ if(${vt_external_fmt})
2828
else()
2929
message(STATUS "vt_external_fmt = ON but fmt_DIR is not provided!")
3030
endif()
31-
find_package(fmt REQUIRED)
32-
# set(FMT_LIBRARY fmt::fmt)
31+
find_package(fmt 9.1.0 REQUIRED)
32+
3333
else()
3434
set(FMT_LIBRARY fmt)
3535
add_subdirectory(${PROJECT_LIB_DIR}/fmt)

cmake_config.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@
9797
#define INCLUDE_FMT_FORMAT <fmt/format.h>
9898
#define INCLUDE_FMT_RANGES <fmt/ranges.h>
9999
#define INCLUDE_FMT_OSTREAM <fmt/ostream.h>
100+
101+
#define VT_FMT_NAMESPACE namespace fmt
100102
#else
101103
#define INCLUDE_FMT_CORE <fmt-vt/core.h>
102104
#define INCLUDE_FMT_FORMAT <fmt-vt/format.h>
103105
#define INCLUDE_FMT_RANGES <fmt-vt/ranges.h>
104106
#define INCLUDE_FMT_OSTREAM <fmt-vt/ostream.h>
107+
108+
#define VT_FMT_NAMESPACE namespace fmt::vt
105109
#endif

src/vt/rdma/rdma_common.h

+23-23
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,30 @@ static constexpr ByteType rdma_default_byte_size = sizeof(char);
117117

118118
}} //end namespace vt::rdma
119119

120-
namespace fmt { inline namespace vt {
121-
template <>
122-
struct formatter<::vt::rdma::Type> : formatter<std::string_view> {
123-
template <typename FormatContext>
124-
auto format(::vt::rdma::Type t, FormatContext& ctx) {
125-
std::string_view name = "Unknown";
126-
switch (t) {
127-
case ::vt::rdma::Type::Get:
128-
name = "Get";
129-
break;
130-
case ::vt::rdma::Type::Put:
131-
name = "Put";
132-
break;
133-
case ::vt::rdma::Type::GetOrPut:
134-
name = "GetOrPut";
135-
break;
136-
case ::vt::rdma::Type::Uninitialized:
137-
name = "Uninitialized";
138-
break;
120+
VT_FMT_NAMESPACE {
121+
template <>
122+
struct formatter<::vt::rdma::Type> : formatter<std::string_view> {
123+
template <typename FormatContext>
124+
auto format(::vt::rdma::Type t, FormatContext& ctx) {
125+
std::string_view name = "Unknown";
126+
switch (t) {
127+
case ::vt::rdma::Type::Get:
128+
name = "Get";
129+
break;
130+
case ::vt::rdma::Type::Put:
131+
name = "Put";
132+
break;
133+
case ::vt::rdma::Type::GetOrPut:
134+
name = "GetOrPut";
135+
break;
136+
case ::vt::rdma::Type::Uninitialized:
137+
name = "Uninitialized";
138+
break;
139+
}
140+
return formatter<std::string_view>::format(name, ctx);
139141
}
140-
return formatter<std::string_view>::format(name, ctx);
141-
}
142-
};
143-
}} // namespace fmt::vt
142+
};
143+
} // VT_FMT_NAMESPACE
144144

145145
#define PRINT_CHANNEL_TYPE(rdma_op_type) ( \
146146
rdma_op_type == vt::rdma::Type::Get ? "rdma::Get" : ( \

src/vt/termination/interval/interval.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,18 @@ struct Interval;
237237

238238
}}}
239239

240-
namespace fmt { inline namespace vt {
241-
template <typename DomainT, DomainT sentinel>
242-
struct formatter<::vt::term::interval::Interval<DomainT, sentinel>>
243-
: formatter<std::string> {
244-
template <typename FormatContext>
245-
auto format(
246-
const ::vt::term::interval::Interval<DomainT, sentinel>& interval,
247-
FormatContext& ctx) {
248-
return format_to(
249-
ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper());
250-
}
251-
};
252-
}} // namespace fmt::vt
240+
VT_FMT_NAMESPACE {
241+
template <typename DomainT, DomainT sentinel>
242+
struct formatter<::vt::term::interval::Interval<DomainT, sentinel>>
243+
: formatter<std::string> {
244+
template <typename FormatContext>
245+
auto format(
246+
const ::vt::term::interval::Interval<DomainT, sentinel>& interval,
247+
FormatContext& ctx) {
248+
return format_to(
249+
ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper());
250+
}
251+
};
252+
} // VT_FMT_NAMESPACE
253253

254254
#endif /*INCLUDED_VT_TERMINATION_INTERVAL_INTERVAL_H*/

src/vt/timing/timing.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ TimeType getCurrentTime();
6363

6464
}} /* end namespace vt::timing */
6565

66-
namespace fmt { inline namespace vt {
67-
template <>
68-
struct formatter<::vt::TimeTypeWrapper> {
69-
template <typename ParseContext>
70-
constexpr auto parse(ParseContext& ctx) {
71-
return ctx.begin();
72-
}
66+
VT_FMT_NAMESPACE {
67+
template <>
68+
struct formatter<::vt::TimeTypeWrapper> {
69+
template <typename ParseContext>
70+
constexpr auto parse(ParseContext& ctx) {
71+
return ctx.begin();
72+
}
7373

74-
template <typename FormatContext>
75-
auto format(::vt::TimeTypeWrapper const& t, FormatContext& ctx) {
76-
return fmt::format_to(
77-
ctx.out(), "{}",
78-
to_engineering_string(t.seconds(), 3, eng_exponential, "s"));
79-
}
80-
};
74+
template <typename FormatContext>
75+
auto format(::vt::TimeTypeWrapper const& t, FormatContext& ctx) {
76+
return fmt::format_to(
77+
ctx.out(), "{}",
78+
to_engineering_string(t.seconds(), 3, eng_exponential, "s"));
79+
}
80+
};
8181

82-
}} // namespace fmt::vt
82+
} // VT_FMT_NAMESPACE
8383

8484
#endif /*INCLUDED_VT_TIMING_TIMING_H*/

src/vt/topos/index/dense/dense_array.h

+12-13
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,18 @@ static_assert(
159159

160160
}} // end namespace vt::index
161161

162-
namespace fmt { inline namespace vt {
163-
164-
template <typename IndexType, ::vt::index::NumDimensionsType ndim>
165-
struct formatter<::vt::index::DenseIndexArray<IndexType, ndim>>
166-
: formatter<std::array<IndexType, ndim>> {
167-
template <typename FormatContext>
168-
auto format(
169-
const ::vt::index::DenseIndexArray<IndexType, ndim>& wrapper,
170-
FormatContext& ctx) {
171-
return formatter<std::array<IndexType, ndim>>::format(wrapper.dims, ctx);
172-
}
173-
};
174-
}} // namespace fmt::vt
162+
VT_FMT_NAMESPACE {
163+
template <typename IndexType, ::vt::index::NumDimensionsType ndim>
164+
struct formatter<::vt::index::DenseIndexArray<IndexType, ndim>>
165+
: formatter<std::array<IndexType, ndim>> {
166+
template <typename FormatContext>
167+
auto format(
168+
const ::vt::index::DenseIndexArray<IndexType, ndim>& wrapper,
169+
FormatContext& ctx) {
170+
return formatter<std::array<IndexType, ndim>>::format(wrapper.dims, ctx);
171+
}
172+
};
173+
} // VT_FMT_NAMESPACE
175174

176175
#include "vt/topos/index/dense/dense_array.impl.h"
177176

src/vt/vrt/collection/balance/greedylb/greedylb.h

+22-22
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,29 @@ struct GreedyLB : LoadSamplerBaseLB {
126126

127127
}}}} /* end namespace vt::vrt::collection::lb */
128128

129-
namespace fmt { inline namespace vt {
130-
template <>
131-
struct formatter<::vt::vrt::collection::lb::DataDistStrategy>
132-
: formatter<std::string_view> {
133-
template <typename FormatContext>
134-
auto
135-
format(::vt::vrt::collection::lb::DataDistStrategy c, FormatContext& ctx) {
136-
std::string_view name = "Unknown";
137-
switch (c) {
138-
case ::vt::vrt::collection::lb::DataDistStrategy::scatter:
139-
name = "scatter";
140-
break;
141-
case ::vt::vrt::collection::lb::DataDistStrategy::bcast:
142-
name = "bcast";
143-
break;
144-
case ::vt::vrt::collection::lb::DataDistStrategy::pt2pt:
145-
name = "pt2pt";
146-
break;
129+
VT_FMT_NAMESPACE {
130+
template <>
131+
struct formatter<::vt::vrt::collection::lb::DataDistStrategy>
132+
: formatter<std::string_view> {
133+
template <typename FormatContext>
134+
auto
135+
format(::vt::vrt::collection::lb::DataDistStrategy c, FormatContext& ctx) {
136+
std::string_view name = "Unknown";
137+
switch (c) {
138+
case ::vt::vrt::collection::lb::DataDistStrategy::scatter:
139+
name = "scatter";
140+
break;
141+
case ::vt::vrt::collection::lb::DataDistStrategy::bcast:
142+
name = "bcast";
143+
break;
144+
case ::vt::vrt::collection::lb::DataDistStrategy::pt2pt:
145+
name = "pt2pt";
146+
break;
147+
}
148+
return formatter<string_view>::format(name, ctx);
147149
}
148-
return formatter<string_view>::format(name, ctx);
149-
}
150-
};
150+
};
151151

152-
}} // namespace fmt::vt
152+
} // VT_FMT_NAMESPACE
153153

154154
#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_GREEDYLB_GREEDYLB_H*/

src/vt/vrt/collection/balance/temperedlb/criterion.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ struct Criterion {
9393

9494
}}}} /* end namespace vt::vrt::collection::lb */
9595

96-
namespace fmt { inline namespace vt {
97-
98-
template <>
99-
struct formatter<::vt::vrt::collection::lb::CriterionEnum>
100-
: formatter<std::string_view> {
101-
template <typename FormatContext>
102-
auto format(::vt::vrt::collection::lb::CriterionEnum c, FormatContext& ctx) {
103-
std::string_view name = "Unknown";
104-
switch (c) {
105-
case ::vt::vrt::collection::lb::CriterionEnum::Grapevine:
106-
name = "Grapevine";
107-
break;
108-
case ::vt::vrt::collection::lb::CriterionEnum::ModifiedGrapevine:
109-
name = "ModifiedGrapevine";
110-
break;
96+
VT_FMT_NAMESPACE {
97+
template <>
98+
struct formatter<::vt::vrt::collection::lb::CriterionEnum>
99+
: formatter<std::string_view> {
100+
template <typename FormatContext>
101+
auto
102+
format(::vt::vrt::collection::lb::CriterionEnum c, FormatContext& ctx) {
103+
std::string_view name = "Unknown";
104+
switch (c) {
105+
case ::vt::vrt::collection::lb::CriterionEnum::Grapevine:
106+
name = "Grapevine";
107+
break;
108+
case ::vt::vrt::collection::lb::CriterionEnum::ModifiedGrapevine:
109+
name = "ModifiedGrapevine";
110+
break;
111+
}
112+
return formatter<string_view>::format(name, ctx);
111113
}
112-
return formatter<string_view>::format(name, ctx);
113-
}
114-
};
114+
};
115115

116-
}} // namespace fmt::vt
116+
} // VT_FMT_NAMESPACE
117117

118118
#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_CRITERION_H*/

0 commit comments

Comments
 (0)