Skip to content

Commit

Permalink
Merge pull request #370 from DARMA-tasking/369-is-footprinter
Browse files Browse the repository at this point in the history
#369 Implement checkpoint::is_footprinter<>
  • Loading branch information
lifflander authored Sep 25, 2024
2 parents 3d60dd6 + 298af49 commit b33cc40
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/checkpoint/container/atomic_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serialize(SerializerT& s, const std::atomic<T>& atomic) {
Expand Down
5 changes: 1 addition & 4 deletions src/checkpoint/container/function_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ template <
typename Res,
typename... ArgTypes,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serializeFunction(SerializerT& s, std::function<Res(ArgTypes...)>& fn) {
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/container/kokkos_unordered_map_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ template <
typename Hasher, typename EqualTo
>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter_v<SerializerT>, void
> serialize(
SerializerT& s,
Kokkos::UnorderedMap<Key, Value, Device, Hasher, EqualTo>& map
Expand All @@ -140,7 +140,7 @@ template <
typename Hasher, typename EqualTo
>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter_v<SerializerT>, void
> serialize(
SerializerT& s,
Kokkos::UnorderedMap<Key, Value, Device, Hasher, EqualTo>& map
Expand Down
6 changes: 3 additions & 3 deletions src/checkpoint/container/list_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace checkpoint {

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter_v<Serializer>, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
Expand All @@ -76,7 +76,7 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter_v<Serializer>, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
Expand All @@ -96,7 +96,7 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter_v<Serializer>, void
>
deserializeOrderedElems(
Serializer&, ContainerT&, typename ContainerT::size_type
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/container/map_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace checkpoint {

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value,
not checkpoint::is_footprinter_v<Serializer>,
void
> deserializeEmplaceElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size
Expand All @@ -77,7 +77,7 @@ inline typename std::enable_if_t<

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value,
checkpoint::is_footprinter_v<Serializer>,
void
> deserializeEmplaceElems(
Serializer&, ContainerT&, typename ContainerT::size_type
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/queue_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ template <
typename SerializerT,
typename Q,
typename = std::enable_if_t<
std::is_same_v<SerializerT, checkpoint::Footprinter>
checkpoint::is_footprinter_v<SerializerT>
>
>
void serializeQueueLikeContainer(SerializerT& s, const Q& q) {
Expand Down
7 changes: 2 additions & 5 deletions src/checkpoint/container/raw_ptr_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serialize(SerializerT& s, T* ptr) {
Expand Down Expand Up @@ -95,7 +92,7 @@ void serializeRawPtr(SerializerT& s, void* ptr) {
#define CHECKPOINT_FOOTPRINT_PIMPL_WITH_SIZEOF_PTR(PIMPL_TYPE) \
template < \
typename SerializerT, \
typename = std::enable_if_t< std::is_same<SerializerT, checkpoint::Footprinter >::value > \
typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> > \
> \
void serialize(SerializerT &s, PIMPL_TYPE *t) { \
s.countBytes(t); \
Expand Down
5 changes: 1 addition & 4 deletions src/checkpoint/container/shared_ptr_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serialize(SerializerT& s, std::shared_ptr<T>& ptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/thread_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace checkpoint {
template <
typename SerializerT,
typename = std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serialize(SerializerT& s, const std::thread& t) {
Expand Down
10 changes: 5 additions & 5 deletions src/checkpoint/container/vector_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace checkpoint {

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, SerialSizeType
not checkpoint::is_footprinter_v<SerializerT>, SerialSizeType
>
serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
SerialSizeType vec_capacity = vec.capacity();
Expand Down Expand Up @@ -108,7 +108,7 @@ void constructVectorData(

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter_v<SerializerT>, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -122,7 +122,7 @@ serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {

template <typename SerializerT, typename VectorAllocator>
typename std::enable_if_t<
not std::is_same<SerializerT, checkpoint::Footprinter>::value, void
not checkpoint::is_footprinter_v<SerializerT>, void
>
serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -146,7 +146,7 @@ serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {

template <typename SerializerT, typename T, typename VectorAllocator>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter_v<SerializerT>, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
s.countBytes(vec);
Expand All @@ -156,7 +156,7 @@ serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {

template <typename SerializerT, typename VectorAllocator>
typename std::enable_if_t<
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
checkpoint::is_footprinter_v<SerializerT>, void
>
serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {
s.countBytes(vec);
Expand Down
14 changes: 14 additions & 0 deletions src/checkpoint/serializers/footprinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ struct Footprinter : BaseSerializer {
SerialSizeType num_bytes_ = 0;
};

namespace {
template <typename>
struct is_footprinter_impl : public std::false_type {};

template <>
struct is_footprinter_impl<Footprinter> : public std::true_type {};
}

template<typename U>
using is_footprinter = is_footprinter_impl<std::decay_t<U>>;

template<typename U>
static constexpr const bool is_footprinter_v = is_footprinter<U>::value;

} /* end namespace checkpoint */

#endif /*INCLUDED_SRC_CHECKPOINT_SERIALIZERS_FOOTPRINTER_H*/
5 changes: 1 addition & 4 deletions tests/unit/test_footprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ struct TestDerived2 : TestBase {
template <
typename SerializerT,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
checkpoint::is_footprinter_v<SerializerT>
>
>
void serialize(SerializerT& s) {
Expand Down

0 comments on commit b33cc40

Please sign in to comment.