Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

344 implement user traits #345

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Matthew-Whitlock
Copy link
Contributor

@Matthew-Whitlock Matthew-Whitlock commented May 30, 2024

Closes #344

@Matthew-Whitlock Matthew-Whitlock linked an issue May 30, 2024 that may be closed by this pull request
@Matthew-Whitlock Matthew-Whitlock force-pushed the 344-implement-user-traits branch 5 times, most recently from 45d2aca to 28e3ef9 Compare June 6, 2024 17:37
@Matthew-Whitlock Matthew-Whitlock force-pushed the 344-implement-user-traits branch 2 times, most recently from 014e8dd to 02b04a2 Compare June 12, 2024 01:04
@nmm0 nmm0 requested review from lifflander and nmm0 June 18, 2024 17:18
@lifflander lifflander requested a review from cz4rs June 18, 2024 17:23
@nmm0
Copy link
Contributor

nmm0 commented Jun 18, 2024

@Matthew-Whitlock will this require some changes to VT?

Copy link
Contributor

@cz4rs cz4rs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Matthew-Whitlock PR tests with vt build is currently failing in the configuration stage and reports success incorrectly. #352 fixes both these issue, please rebase once it is merged.

Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About half reviewed

examples/checkpoint_example_user_traits.hpp Show resolved Hide resolved
src/checkpoint/checkpoint_api.h Outdated Show resolved Hide resolved
src/checkpoint/dispatch/dispatch.h Show resolved Hide resolved
src/checkpoint/dispatch/vrt/virtual_serialize.h Outdated Show resolved Hide resolved
src/checkpoint/serializers/reference.h Outdated Show resolved Hide resolved
src/checkpoint/serializers/reference.h Outdated Show resolved Hide resolved
src/checkpoint/serializers/reference.h Outdated Show resolved Hide resolved
src/checkpoint/serializers/reference.h Outdated Show resolved Hide resolved
src/checkpoint/serializers/reference.h Outdated Show resolved Hide resolved
@nmm0
Copy link
Contributor

nmm0 commented Oct 16, 2024

@Matthew-Whitlock Can you rebase and mark as ready for review?

@nmm0 nmm0 requested review from cz4rs and nmm0 October 16, 2024 16:42
Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whew, sorry it took so long I added a bunch comments

tests/unit/test_user_traits.cc Outdated Show resolved Hide resolved
src/checkpoint/serializers/serializer_ref.h Outdated Show resolved Hide resolved
src/checkpoint/traits/user_traits.h Outdated Show resolved Hide resolved
struct NoTrait;

template<typename Traits, typename T, typename... U>
struct without_helper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere in the PR make sure the casing matches the rest of magistrate, i.e. CamelCase for struct names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make this change, but I think underscore casing makes sense for type manipulation and template helpers. The rest of the code is a bit inconsistent, though.

serializable_traits.h has:

template <typename U>
using specialized_reconstruct_t = decltype(
  checkpoint::CheckpointReconstructor<U>::reconstruct(
    std::declval<U*&>(),
    std::declval<void*>()
  )
);
using has_specialized_reconstruct =
  detection::is_detected<specialized_reconstruct_t, T>;

//But also this style
template <typename U, typename V>
using serializeThis_t =
  decltype(std::declval<U>().serializeThis(std::declval<V&>()));
using has_serializeThis = detection::is_detected<serializeThis_t, T, S>;

checkpoint_traits.h:

template <typename U>    
using contiguousBytes_t = decltype(std::declval<U>().contiguousBytes(    
  std::declval<void*>(), std::declval<SizeType>(), std::declval<SizeType>()    
));    
using has_contiguousBytes = detection::is_detected<contiguousBytes_t, T>;

reconstructor_traits.h:

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, I'll defer to @lifflander then for this one :P

}

struct ShallowTrait {};
struct TraitPairA {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TraitPairA is a little confusing as they don't seem the be pairs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is based on the check in UserObjectA that expects to have either both or neither of TraitPairA and TraitPairB

tests/unit/test_user_traits.cc Outdated Show resolved Hide resolved
tests/unit/test_user_traits.cc Outdated Show resolved Hide resolved
auto serB = checkpoint::serialize<UserObjectB, ShallowTrait>(objB);
objB.val_b = new_b_val;
objB.val_a = new_a_val;
checkpoint::deserializeInPlace<UserObjectB, ShallowTrait>(serB->getBuffer(), &objB);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this test also check name to ensure that the UserObjectA was called correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but I don't think that's checking for anything that wouldn't already be caught by test_serialize_extra so I'd rather keep the checks within the test's scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the extra check for correct trait detection, we should be fine leaving the name checking to the test_serialize_extra test

auto serB = checkpoint::serialize<UserObjectB, TraitPairA>(objB);
objB.val_b = new_b_val;
objB.val_a = new_a_val;
checkpoint::deserializeInPlace<UserObjectB, TraitPairA>(serB->getBuffer(), &objB);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@Matthew-Whitlock Matthew-Whitlock force-pushed the 344-implement-user-traits branch 2 times, most recently from e721da2 to a8bd64c Compare November 11, 2024 14:24
@Matthew-Whitlock Matthew-Whitlock marked this pull request as ready for review November 11, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement User Traits
4 participants