Skip to content

Commit

Permalink
#2216: Fix issue with namespace when using external and bundled fmt v…
Browse files Browse the repository at this point in the history
…ersions. Make 9.1.0 fmt version as required for external fmt
  • Loading branch information
JacobDomagala committed Dec 11, 2023
1 parent 91513d4 commit 087e196
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 218 deletions.
4 changes: 2 additions & 2 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if(${vt_external_fmt})
else()
message(STATUS "vt_external_fmt = ON but fmt_DIR is not provided!")
endif()
find_package(fmt REQUIRED)
# set(FMT_LIBRARY fmt::fmt)
find_package(fmt 9.1.0 REQUIRED)

else()
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
Expand Down
4 changes: 4 additions & 0 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@
#define INCLUDE_FMT_FORMAT <fmt/format.h>
#define INCLUDE_FMT_RANGES <fmt/ranges.h>
#define INCLUDE_FMT_OSTREAM <fmt/ostream.h>

#define VT_FMT_NAMESPACE namespace fmt
#else
#define INCLUDE_FMT_CORE <fmt-vt/core.h>
#define INCLUDE_FMT_FORMAT <fmt-vt/format.h>
#define INCLUDE_FMT_RANGES <fmt-vt/ranges.h>
#define INCLUDE_FMT_OSTREAM <fmt-vt/ostream.h>

#define VT_FMT_NAMESPACE namespace fmt::vt
#endif
46 changes: 23 additions & 23 deletions src/vt/rdma/rdma_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,30 @@ static constexpr ByteType rdma_default_byte_size = sizeof(char);

}} //end namespace vt::rdma

namespace fmt { inline namespace vt {
template <>
struct formatter<::vt::rdma::Type> : formatter<std::string_view> {
template <typename FormatContext>
auto format(::vt::rdma::Type t, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (t) {
case ::vt::rdma::Type::Get:
name = "Get";
break;
case ::vt::rdma::Type::Put:
name = "Put";
break;
case ::vt::rdma::Type::GetOrPut:
name = "GetOrPut";
break;
case ::vt::rdma::Type::Uninitialized:
name = "Uninitialized";
break;
VT_FMT_NAMESPACE {
template <>
struct formatter<::vt::rdma::Type> : formatter<std::string_view> {
template <typename FormatContext>
auto format(::vt::rdma::Type t, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (t) {
case ::vt::rdma::Type::Get:
name = "Get";
break;
case ::vt::rdma::Type::Put:
name = "Put";
break;
case ::vt::rdma::Type::GetOrPut:
name = "GetOrPut";
break;
case ::vt::rdma::Type::Uninitialized:
name = "Uninitialized";
break;
}
return formatter<std::string_view>::format(name, ctx);
}
return formatter<std::string_view>::format(name, ctx);
}
};
}} // namespace fmt::vt
};
} // VT_FMT_NAMESPACE

#define PRINT_CHANNEL_TYPE(rdma_op_type) ( \
rdma_op_type == vt::rdma::Type::Get ? "rdma::Get" : ( \
Expand Down
26 changes: 13 additions & 13 deletions src/vt/termination/interval/interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@ struct Interval;

}}}

namespace fmt { inline namespace vt {
template <typename DomainT, DomainT sentinel>
struct formatter<::vt::term::interval::Interval<DomainT, sentinel>>
: formatter<std::string> {
template <typename FormatContext>
auto format(
const ::vt::term::interval::Interval<DomainT, sentinel>& interval,
FormatContext& ctx) {
return format_to(
ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper());
}
};
}} // namespace fmt::vt
VT_FMT_NAMESPACE {
template <typename DomainT, DomainT sentinel>
struct formatter<::vt::term::interval::Interval<DomainT, sentinel>>
: formatter<std::string> {
template <typename FormatContext>
auto format(
const ::vt::term::interval::Interval<DomainT, sentinel>& interval,
FormatContext& ctx) {
return format_to(
ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper());
}
};
} // VT_FMT_NAMESPACE

#endif /*INCLUDED_VT_TERMINATION_INTERVAL_INTERVAL_H*/
30 changes: 15 additions & 15 deletions src/vt/timing/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ TimeType getCurrentTime();

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

namespace fmt { inline namespace vt {
template <>
struct formatter<::vt::TimeTypeWrapper> {
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx) {
return ctx.begin();
}
VT_FMT_NAMESPACE {
template <>
struct formatter<::vt::TimeTypeWrapper> {
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx) {
return ctx.begin();
}

template <typename FormatContext>
auto format(::vt::TimeTypeWrapper const& t, FormatContext& ctx) {
return fmt::format_to(
ctx.out(), "{}",
to_engineering_string(t.seconds(), 3, eng_exponential, "s"));
}
};
template <typename FormatContext>
auto format(::vt::TimeTypeWrapper const& t, FormatContext& ctx) {
return fmt::format_to(
ctx.out(), "{}",
to_engineering_string(t.seconds(), 3, eng_exponential, "s"));
}
};

}} // namespace fmt::vt
} // VT_FMT_NAMESPACE

#endif /*INCLUDED_VT_TIMING_TIMING_H*/
25 changes: 12 additions & 13 deletions src/vt/topos/index/dense/dense_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,18 @@ static_assert(

}} // end namespace vt::index

namespace fmt { inline namespace vt {

template <typename IndexType, ::vt::index::NumDimensionsType ndim>
struct formatter<::vt::index::DenseIndexArray<IndexType, ndim>>
: formatter<std::array<IndexType, ndim>> {
template <typename FormatContext>
auto format(
const ::vt::index::DenseIndexArray<IndexType, ndim>& wrapper,
FormatContext& ctx) {
return formatter<std::array<IndexType, ndim>>::format(wrapper.dims, ctx);
}
};
}} // namespace fmt::vt
VT_FMT_NAMESPACE {
template <typename IndexType, ::vt::index::NumDimensionsType ndim>
struct formatter<::vt::index::DenseIndexArray<IndexType, ndim>>
: formatter<std::array<IndexType, ndim>> {
template <typename FormatContext>
auto format(
const ::vt::index::DenseIndexArray<IndexType, ndim>& wrapper,
FormatContext& ctx) {
return formatter<std::array<IndexType, ndim>>::format(wrapper.dims, ctx);
}
};
} // VT_FMT_NAMESPACE

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

Expand Down
44 changes: 22 additions & 22 deletions src/vt/vrt/collection/balance/greedylb/greedylb.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,29 @@ struct GreedyLB : LoadSamplerBaseLB {

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

namespace fmt { inline namespace vt {
template <>
struct formatter<::vt::vrt::collection::lb::DataDistStrategy>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::DataDistStrategy c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::DataDistStrategy::scatter:
name = "scatter";
break;
case ::vt::vrt::collection::lb::DataDistStrategy::bcast:
name = "bcast";
break;
case ::vt::vrt::collection::lb::DataDistStrategy::pt2pt:
name = "pt2pt";
break;
VT_FMT_NAMESPACE {
template <>
struct formatter<::vt::vrt::collection::lb::DataDistStrategy>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::DataDistStrategy c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::DataDistStrategy::scatter:
name = "scatter";
break;
case ::vt::vrt::collection::lb::DataDistStrategy::bcast:
name = "bcast";
break;
case ::vt::vrt::collection::lb::DataDistStrategy::pt2pt:
name = "pt2pt";
break;
}
return formatter<string_view>::format(name, ctx);
}
return formatter<string_view>::format(name, ctx);
}
};
};

}} // namespace fmt::vt
} // VT_FMT_NAMESPACE

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_GREEDYLB_GREEDYLB_H*/
38 changes: 19 additions & 19 deletions src/vt/vrt/collection/balance/temperedlb/criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,26 @@ struct Criterion {

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

namespace fmt { inline namespace vt {

template <>
struct formatter<::vt::vrt::collection::lb::CriterionEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto format(::vt::vrt::collection::lb::CriterionEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::CriterionEnum::Grapevine:
name = "Grapevine";
break;
case ::vt::vrt::collection::lb::CriterionEnum::ModifiedGrapevine:
name = "ModifiedGrapevine";
break;
VT_FMT_NAMESPACE {
template <>
struct formatter<::vt::vrt::collection::lb::CriterionEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::CriterionEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::CriterionEnum::Grapevine:
name = "Grapevine";
break;
case ::vt::vrt::collection::lb::CriterionEnum::ModifiedGrapevine:
name = "ModifiedGrapevine";
break;
}
return formatter<string_view>::format(name, ctx);
}
return formatter<string_view>::format(name, ctx);
}
};
};

}} // namespace fmt::vt
} // VT_FMT_NAMESPACE

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_CRITERION_H*/
Loading

0 comments on commit 087e196

Please sign in to comment.