DARMA-tasking-internal / darma-frontend

Header library providing the frontend programming model for the DARMA asynchronous many-task model
Other
7 stars 0 forks source link

Serialization broken for non-STL types #92

Open jjwilke opened 6 years ago

jjwilke commented 6 years ago

Non-intrusive serialized types are no longer working - aside from those already implemented in the the standard library serializers. If have a serializer for a custom type:

struct config {
 int aField;
};

namespace darma_runtime {
namespace serialization {
template <>
struct Serializer<config> {
  template <typename ArchiveT>
  void serialize(config& cfg, ArchiveT& ar) const {
    ar | cfg.aField;
  }
};
}}

This a) generates meaningless template spew, and b) if I print which fields are incorrect using the code

#define print(x) std::cout << #x << "=" << std::boolalpha << \
    get_serializer_style<config,SimpleSizingArchive>::x << std::endl
  print(uses_multiple_styles);
  print(unserializable);
  print(uses_intrusive_serialize);
  print(uses_intrusive_pack_unpack);
  print(uses_nonintrusive);

I get the following output

uses_multiple_styles=false
unserializable=true
uses_intrusive_serialize=false
uses_intrusive_pack_unpack=false
uses_nonintrusive=false

Clearly nonintrusive should be true here. This code was working 6 months ago. I suspect the code below is broken, but it is not really comprehensible.


static constexpr auto uses_nonintrusive = tinympl::and_<
    // Only generate (even in unevaluated context) if is_sizing() is true
    tinympl::or_<
      tinympl::bool_<!Archive::is_sizing()>,
      _has_nonintrusive_compute_size<T, Archive>
    >,
    // Only generate (even in unevaluated context) if is_packing() is true
    tinympl::or_<
      tinympl::bool_<!Archive::is_packing()>,
      _has_nonintrusive_pack<T, Archive>
    >,
    // Only generate (even in unevaluated context) if is_unpacking() is true
    tinympl::or_<
      tinympl::bool_<!Archive::is_unpacking()>,
      _has_nonintrusive_unpack<T, Archive>
    >,
    // If all three are false, something has gone horribly wrong, so don't count
    // this as the correct mode
    tinympl::bool_<
      Archive::is_sizing()
        or Archive::is_packing()
        or Archive::is_unpacking()
    >
  >::value;
dhollman commented 6 years ago

The non-intrusive serialize was removed from the interface. See the relevant DEP.

Thanks,

David

(sent from my phone — please excuse brevity & typos)

On Apr 29, 2018, at 4:34 PM, Jeremy notifications@github.com<mailto:notifications@github.com> wrote:

Non-intrusive serialized types are no longer working - aside from those already implemented in the the standard library serializers. If have a serializer for a custom type:

struct config { int aField; };

namespace darma_runtime { namespace serialization { template <> struct Serializer { template void serialize(config& cfg, ArchiveT& ar) const { ar | cfg.aField; } }; }}

This a) generates meaningless template spew, and b) if I print which fields are incorrect using the code

define print(x) std::cout << #x << "=" << std::boolalpha << \

get_serializer_style<config,SimpleSizingArchive>::x << std::endl

print(uses_multiple_styles); print(unserializable); print(uses_intrusive_serialize); print(uses_intrusive_pack_unpack); print(uses_nonintrusive);

I get the following output

uses_multiple_styles=false unserializable=true uses_intrusive_serialize=false uses_intrusive_pack_unpack=false uses_nonintrusive=false

Clearly nonintrusive should be true here. This code was working 6 months ago. I suspect the code below is broken, but it is not really comprehensible.

static constexpr auto usesnonintrusive = tinympl::and< // Only generate (even in unevaluated context) if issizing() is true tinympl::or< tinympl::bool_<!Archive::is_sizing()>, _has_nonintrusive_compute_size<T, Archive>

, // Only generate (even in unevaluated context) if ispacking() is true tinympl::or< tinympl::bool_<!Archive::is_packing()>, _has_nonintrusive_pack<T, Archive> , // Only generate (even in unevaluated context) if isunpacking() is true tinympl::or< tinympl::bool_<!Archive::is_unpacking()>, _has_nonintrusiveunpack<T, Archive> , // If all three are false, something has gone horribly wrong, so don't count // this as the correct mode tinympl::bool< Archive::is_sizing() or Archive::is_packing() or Archive::is_unpacking()

::value;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/DARMA-tasking/darma-frontend/issues/92, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAGIHj_zYt8NIgpZd6wMfp1fG5SFMktaks5ttk4dgaJpZM4TsASH.

jjwilke commented 6 years ago

The intrusive interface is working for custom types. Clearly a lot has changed - in particular, it now appears that Serializer uses static methods instead of const instance methods?

dhollman commented 6 years ago

Yes, those changes were both part of the simplification.

Thanks,

David

(sent from my phone — please excuse brevity & typos)

On Apr 29, 2018, at 8:28 PM, Jeremy notifications@github.com<mailto:notifications@github.com> wrote:

The intrusive interface is working for custom types. Clearly a lot has changed - in particular, it now appears that Serializer uses static methods instead of const instance methods?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://github.com/DARMA-tasking/darma-frontend/issues/92#issuecomment-385307330, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAGIHtoK6hPyG1j69iWah5noJHii1PqDks5ttoT3gaJpZM4TsASH.