Skip to content

Commit

Permalink
#161 fix nvcc compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Oct 13, 2021
1 parent 3c7e20f commit c7d41a0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 101 deletions.
16 changes: 9 additions & 7 deletions src/checkpoint/container/list_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ 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 std::is_same<Serializer, checkpoint::Footprinter>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
typename ReconstructorTraits<ElmT>::template isCopyConstructible<ElmT>* = nullptr
isCopyConstructible<ElmT>* = nullptr
) {
using Alloc = dispatch::Allocator<ElmT>;
using Reconstructor =
Expand All @@ -75,10 +76,11 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
not std::is_same<Serializer, checkpoint::Footprinter>::value, void>
not std::is_same<Serializer, checkpoint::Footprinter>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size,
typename ReconstructorTraits<ElmT>::template isNotCopyConstructible<ElmT>* = nullptr
isNotCopyConstructible<ElmT>* = nullptr
) {
using Alloc = dispatch::Allocator<ElmT>;
using Reconstructor =
Expand All @@ -94,9 +96,9 @@ deserializeOrderedElems(

template <typename Serializer, typename ContainerT, typename ElmT>
inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value,
void
> deserializeOrderedElems(
std::is_same<Serializer, checkpoint::Footprinter>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size
) { }

Expand Down
20 changes: 7 additions & 13 deletions src/checkpoint/container/vector_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +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 std::is_same<SerializerT, checkpoint::Footprinter>::value, SerialSizeType
>
serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
SerialSizeType vec_capacity = vec.capacity();
Expand All @@ -72,16 +71,15 @@ serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
template <typename T, typename VectorAllocator>
void constructVectorData(
SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec,
typename ReconstructorTraits<T>::template isDefaultConsType<T>* = nullptr
isDefaultConsType<T>* = nullptr
) {
vec.resize(vec_size);
}

template <typename T, typename VectorAllocator>
void constructVectorData(
SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec,
typename ReconstructorTraits<T>::template isNotDefaultConsType<T>* = nullptr,
typename ReconstructorTraits<T>::template isCopyConstructible<T>* = nullptr
isNotDefaultConsType<T>* = nullptr, isCopyConstructible<T>* = nullptr
) {
using Alloc = dispatch::Allocator<T>;
using Reconstructor =
Expand All @@ -95,8 +93,7 @@ void constructVectorData(
template <typename T, typename VectorAllocator>
void constructVectorData(
SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec,
typename ReconstructorTraits<T>::template isNotDefaultConsType<T>* = nullptr,
typename ReconstructorTraits<T>::template isNotCopyConstructible<T>* = nullptr
isNotDefaultConsType<T>* = nullptr, isNotCopyConstructible<T>* = nullptr
) {
using Alloc = dispatch::Allocator<T>;
using Reconstructor =
Expand All @@ -111,8 +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 std::is_same<SerializerT, checkpoint::Footprinter>::value, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -126,8 +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 std::is_same<SerializerT, checkpoint::Footprinter>::value, void
>
serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) {
auto const vec_size = serializeVectorMeta(s, vec);
Expand All @@ -151,8 +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
std::is_same<SerializerT, checkpoint::Footprinter>::value, void
>
serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) {
s.countBytes(vec);
Expand Down
45 changes: 9 additions & 36 deletions src/checkpoint/dispatch/reconstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ template <typename T>
struct Reconstructor {
// Default-construct as lowest priority in reconstruction preference
template <typename U = T>
static T* constructDefault(
void* buf,
typename ReconstructorTraits<T>::template isDefaultConsType<U>* = nullptr
) {
static T* constructDefault(void* buf, isDefaultConsType<U>* = nullptr) {
debug_checkpoint(
"DeserializerDispatch: default constructor: buf=%p\n", buf
);
Expand All @@ -70,10 +67,7 @@ struct Reconstructor {

// Fail, no valid option to constructing T
template <typename U = T>
static T* constructDefault(
void* buf,
typename ReconstructorTraits<T>::template isNotDefaultConsType<U>* = nullptr
) {
static T* constructDefault(void* buf, isNotDefaultConsType<U>* = nullptr) {
static_assert(
SerializableTraits<U, void>::is_tagged_constructible or
SerializableTraits<U, void>::is_reconstructible or
Expand All @@ -96,21 +90,15 @@ struct Reconstructor {

// Intrusive reconstruct
template <typename U = T>
static T* constructReconstruct(
void* buf,
typename ReconstructorTraits<T>::template isReconstructibleType<U>* = nullptr
) {
static T* constructReconstruct(void* buf, isReconstructibleType<U>* = nullptr) {
debug_checkpoint("DeserializerDispatch: T::reconstruct(): buf=%p\n", buf);
auto& t = T::reconstruct(buf);
return &t;
}

// Non-intrusive reconstruct
template <typename U = T>
static T* constructReconstruct(
void* buf,
typename ReconstructorTraits<T>::template isNonIntReconstructibleType<U>* = nullptr
) {
static T* constructReconstruct(void* buf, isNonIntReconstructibleType<U>* = nullptr) {
debug_checkpoint(
"DeserializerDispatch: non-int reconstruct(): buf=%p\n", buf
);
Expand All @@ -122,30 +110,21 @@ struct Reconstructor {

/// Non-reconstruct pass-through
template <typename U = T>
static T* constructReconstruct(
void* buf,
typename ReconstructorTraits<T>::template isNotReconstructibleType<U>* = nullptr
) {
static T* constructReconstruct(void* buf, isNotReconstructibleType<U>* = nullptr) {
return constructDefault<U>(buf);
}

/// Tagged constructor
template <typename U = T>
static T* constructTag(
void* buf,
typename ReconstructorTraits<T>::template isTaggedConstructibleType<U>* = nullptr
) {
static T* constructTag(void* buf, isTaggedConstructibleType<U>* = nullptr) {
debug_checkpoint("DeserializerDispatch: tagged constructor: buf=%p\n", buf);
T* t_ptr = new (buf) T{SERIALIZE_CONSTRUCT_TAG{}};
return t_ptr;
}

/// Non-tagged constructor pass-through
template <typename U = T>
static T* constructTag(
void* buf,
typename ReconstructorTraits<T>::template isNotTaggedConstructibleType<U>* = nullptr
) {
static T* constructTag(void* buf, isNotTaggedConstructibleType<U>* = nullptr) {
return constructReconstruct<U>(buf);
}

Expand All @@ -157,18 +136,12 @@ struct Reconstructor {
/// Overloads that allow failure to reconstruct so SFINAE overloads don't
/// static assert out
template <typename U = T>
static T* constructAllowFailImpl(
void* buf,
typename ReconstructorTraits<T>::template isConstructible<U>* = nullptr
) {
static T* constructAllowFailImpl(void* buf, isConstructible<U>* = nullptr) {
return construct<U>(buf);
}

template <typename U = T>
static T* constructAllowFailImpl(
void* buf,
typename ReconstructorTraits<T>::template isNotConstructible<U>* = nullptr
) {
static T* constructAllowFailImpl(void* buf, isNotConstructible<U>* = nullptr) {
std::unique_ptr<char[]> msg = std::make_unique<char[]>(32768);
sprintf(
&msg[0],
Expand Down
87 changes: 42 additions & 45 deletions src/checkpoint/traits/reconstructor_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,51 +52,48 @@
namespace checkpoint {

template <typename T>
struct ReconstructorTraits {
template <typename U>
using isDefaultConsType =
typename std::enable_if<std::is_default_constructible<U>::value, T>::type;

template <typename U>
using isNotDefaultConsType = typename std::enable_if<
not std::is_default_constructible<U>::value, T>::type;

template <typename U>
using isReconstructibleType = typename std::enable_if<
SerializableTraits<U, void>::is_intrusive_reconstructible, T>::type;

template <typename U>
using isNonIntReconstructibleType = typename std::enable_if<
SerializableTraits<U, void>::is_nonintrusive_reconstructible, T>::type;

template <typename U>
using isNotReconstructibleType = typename std::enable_if<
not SerializableTraits<U, void>::is_reconstructible, T>::type;

template <typename U>
using isTaggedConstructibleType = typename std::enable_if<
SerializableTraits<U, void>::is_tagged_constructible, T>::type;

template <typename U>
using isNotTaggedConstructibleType = typename std::enable_if<
not SerializableTraits<U, void>::is_tagged_constructible, T>::type;

template <typename U>
using isConstructible = typename std::enable_if<
SerializableTraits<U, void>::is_constructible, T>::type;

template <typename U>
using isNotConstructible = typename std::enable_if<
not SerializableTraits<U, void>::is_constructible, T>::type;

template <typename U>
using isCopyConstructible =
typename std::enable_if<std::is_copy_constructible<U>::value, T>::type;

template <typename U>
using isNotCopyConstructible =
typename std::enable_if<not std::is_copy_constructible<U>::value, T>::type;
};
using isDefaultConsType =
std::enable_if_t<std::is_default_constructible<T>::value>;

template <typename T>
using isNotDefaultConsType =
std::enable_if_t<not std::is_default_constructible<T>::value>;

template <typename T>
using isReconstructibleType =
std::enable_if_t<SerializableTraits<T, void>::is_intrusive_reconstructible>;

template <typename T>
using isNonIntReconstructibleType = std::enable_if_t<
SerializableTraits<T, void>::is_nonintrusive_reconstructible>;

template <typename T>
using isNotReconstructibleType =
std::enable_if_t<not SerializableTraits<T, void>::is_reconstructible>;

template <typename T>
using isTaggedConstructibleType =
std::enable_if_t<SerializableTraits<T, void>::is_tagged_constructible>;

template <typename T>
using isNotTaggedConstructibleType =
std::enable_if_t<not SerializableTraits<T, void>::is_tagged_constructible>;

template <typename T>
using isConstructible =
std::enable_if_t<SerializableTraits<T, void>::is_constructible>;

template <typename T>
using isNotConstructible =
std::enable_if_t<not SerializableTraits<T, void>::is_constructible>;

template <typename T>
using isNotCopyConstructible =
std::enable_if_t<not std::is_copy_constructible<T>::value>;

template <typename T>
using isCopyConstructible =
std::enable_if_t<std::is_copy_constructible<T>::value>;

} // namespace checkpoint

Expand Down

0 comments on commit c7d41a0

Please sign in to comment.