Skip to content

Commit

Permalink
#2216: Fix namespace issues and remove uneeded custom formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Dec 12, 2023
1 parent 1f505cc commit 807f2e7
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 116 deletions.
6 changes: 4 additions & 2 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@
#define INCLUDE_FMT_RANGES <fmt/ranges.h>
#define INCLUDE_FMT_OSTREAM <fmt/ostream.h>

#define VT_FMT_NAMESPACE namespace fmt
#define VT_FMT_NAMESPACE_BEGIN namespace fmt {
#define VT_FMT_NAMESPACE_END }
#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
#define VT_FMT_NAMESPACE_BEGIN namespace fmt { inline namespace vt {
#define VT_FMT_NAMESPACE_END } }
#endif
6 changes: 4 additions & 2 deletions src/vt/rdma/rdma_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static constexpr ByteType rdma_default_byte_size = sizeof(char);

}} //end namespace vt::rdma

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <>
struct formatter<::vt::rdma::Type> : formatter<std::string_view> {
template <typename FormatContext>
Expand All @@ -136,11 +136,13 @@ VT_FMT_NAMESPACE {
case ::vt::rdma::Type::Uninitialized:
name = "Uninitialized";
break;
default:
name = fmt::format("{}", static_cast<std::underlying_type_t<::vt::rdma::Type>>(t));
}
return formatter<std::string_view>::format(name, ctx);
}
};
} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

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

}}}

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <typename DomainT, DomainT sentinel>
struct formatter<::vt::term::interval::Interval<DomainT, sentinel>>
: formatter<std::string> {
Expand All @@ -249,6 +249,6 @@ VT_FMT_NAMESPACE {
ctx.out(), "Interval[{}, {}]", interval.lower(), interval.upper());
}
};
} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

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

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

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <>
struct formatter<::vt::TimeTypeWrapper> {
template <typename ParseContext>
Expand All @@ -79,6 +79,6 @@ VT_FMT_NAMESPACE {
}
};

} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

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

}} // end namespace vt::index

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <typename IndexType, ::vt::index::NumDimensionsType ndim>
struct formatter<::vt::index::DenseIndexArray<IndexType, ndim>>
: formatter<std::array<IndexType, ndim>> {
Expand All @@ -170,7 +170,7 @@ VT_FMT_NAMESPACE {
return formatter<std::array<IndexType, ndim>>::format(wrapper.dims, ctx);
}
};
} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

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

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

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

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <>
struct formatter<::vt::vrt::collection::lb::DataDistStrategy>
: formatter<std::string_view> {
Expand All @@ -149,6 +149,6 @@ VT_FMT_NAMESPACE {
}
};

} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_GREEDYLB_GREEDYLB_H*/
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/lb_args_enum_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct LBArgsEnumConverter {
auto err = fmt::format(
"LBArgsEnumConverter: enum '{}' value '{}' corresponding to LB "
"argument '{}' does not have a string associated with it",
enum_type_, e, par_name_
enum_type_, static_cast<std::underlying_type_t<T>>(e), par_name_
);
vtAbort(err);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vt/vrt/collection/balance/temperedlb/criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct Criterion {

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

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <>
struct formatter<::vt::vrt::collection::lb::CriterionEnum>
: formatter<std::string_view> {
Expand All @@ -113,6 +113,6 @@ VT_FMT_NAMESPACE {
}
};

} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_CRITERION_H*/
99 changes: 0 additions & 99 deletions src/vt/vrt/collection/balance/temperedlb/tempered_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,103 +167,4 @@ enum struct KnowledgeEnum : uint8_t {

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

VT_FMT_NAMESPACE {
// Specialize fmt::formatter for ObjectOrderEnum
template <>
struct formatter<::vt::vrt::collection::lb::ObjectOrderEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::ObjectOrderEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::ObjectOrderEnum::Arbitrary:
name = "Arbitrary";
break;
case ::vt::vrt::collection::lb::ObjectOrderEnum::ElmID:
name = "ElmID";
break;
case ::vt::vrt::collection::lb::ObjectOrderEnum::FewestMigrations:
name = "FewestMigrations";
break;
case ::vt::vrt::collection::lb::ObjectOrderEnum::SmallObjects:
name = "SmallObjects";
break;
case ::vt::vrt::collection::lb::ObjectOrderEnum::LargestObjects:
name = "LargestObjects";
break;
}
return formatter<string_view>::format(name, ctx);
}
};

// Specialize fmt::formatter for CMFTypeEnum
template <>
struct formatter<::vt::vrt::collection::lb::CMFTypeEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto format(::vt::vrt::collection::lb::CMFTypeEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::CMFTypeEnum::Original:
name = "Original";
break;
case ::vt::vrt::collection::lb::CMFTypeEnum::NormByMax:
name = "NormByMax";
break;
case ::vt::vrt::collection::lb::CMFTypeEnum::NormBySelf:
name = "NormBySelf";
break;
case ::vt::vrt::collection::lb::CMFTypeEnum::NormByMaxExcludeIneligible:
name = "NormByMaxExcludeIneligible";
break;
}
return formatter<string_view>::format(name, ctx);
}
};

// Specialize fmt::formatter for KnowledgeEnum
template <>
struct formatter<::vt::vrt::collection::lb::KnowledgeEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::KnowledgeEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::KnowledgeEnum::UserDefined:
name = "UserDefined";
break;
case ::vt::vrt::collection::lb::KnowledgeEnum::Complete:
name = "Complete";
break;
case ::vt::vrt::collection::lb::KnowledgeEnum::Log:
name = "Log";
break;
}
return formatter<string_view>::format(name, ctx);
}
};

// Specialize fmt::formatter for KnowledgeEnum
template <>
struct formatter<::vt::vrt::collection::lb::InformTypeEnum>
: formatter<std::string_view> {
template <typename FormatContext>
auto
format(::vt::vrt::collection::lb::InformTypeEnum c, FormatContext& ctx) {
std::string_view name = "Unknown";
switch (c) {
case ::vt::vrt::collection::lb::InformTypeEnum::SyncInform:
name = "SyncInform";
break;
case ::vt::vrt::collection::lb::InformTypeEnum::AsyncInform:
name = "AsyncInform";
break;
}
return formatter<string_view>::format(name, ctx);
}
};
} // VT_FMT_NAMESPACE

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_TEMPERED_ENUMS_H*/
4 changes: 2 additions & 2 deletions tests/unit/lb/test_lbargs_enum_conv.nompi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST_F(TestLBArgsEnumConverter, test_enum_converter_config) {

}}} // end namespace vt::tests::unit

VT_FMT_NAMESPACE {
VT_FMT_NAMESPACE_BEGIN
template <>
struct formatter<::vt::tests::unit::DummyEnum> : formatter<std::string_view> {
template <typename FormatContext>
Expand All @@ -168,4 +168,4 @@ VT_FMT_NAMESPACE {
return formatter<string_view>::format(name, ctx);
}
};
} // VT_FMT_NAMESPACE
VT_FMT_NAMESPACE_END

0 comments on commit 807f2e7

Please sign in to comment.