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

188 eti optimize #189

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/checkpoint/dispatch/vrt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointBaseType>(); \
}

#define checkpoint_virtual_serialize_root_decl() \
auto _CheckpointVSBaseTypeFn() -> decltype(auto) { return this; } \
virtual void _checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
); \
virtual ::checkpoint::dispatch::vrt::TypeIdx _checkpointDynamicTypeIndex();

#define checkpoint_virtual_serialize_root_def(CLASS) \
void CLASS::_checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) { \
using _CheckpointBaseType = \
::checkpoint::dispatch::vrt::checkpoint_base_type_t<decltype(*this)>; \
::checkpoint::instantiateObjSerializer< \
_CheckpointBaseType, \
checkpoint_serializer_variadic_args() \
>(); \
::checkpoint::dispatch::vrt::assertTypeIdxMatch<_CheckpointBaseType>(expected_idx); \
auto dispatcher = \
::checkpoint::dispatch::vrt::serializer_registry::getObjIdx<_CheckpointBaseType>(ser_idx); \
dispatcher(s, *static_cast<_CheckpointBaseType*>(this)); \
} \
::checkpoint::dispatch::vrt::TypeIdx CLASS::_checkpointDynamicTypeIndex() { \
using _CheckpointBaseType = \
::checkpoint::dispatch::vrt::checkpoint_base_type_t<decltype(*this)>; \
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointBaseType>(); \
}

#define checkpoint_virtual_serialize_base(BASE) checkpoint_virtual_serialize_root()

namespace checkpoint { namespace dispatch { namespace vrt {
Expand Down
45 changes: 45 additions & 0 deletions src/checkpoint/dispatch/vrt/derived.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,51 @@
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointDerivedType>(); \
}

#define checkpoint_virtual_serialize_derived_decl() \
void _checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx base_ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) override; \
::checkpoint::dispatch::vrt::TypeIdx _checkpointDynamicTypeIndex() override;

#define checkpoint_virtual_serialize_derived_from_def(CLASS, PARENT) \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need variants with and without template <> here and probably above also.

template <> \
void CLASS::_checkpointDynamicSerialize( \
void* s, \
::checkpoint::dispatch::vrt::TypeIdx base_ser_idx, \
::checkpoint::dispatch::vrt::TypeIdx expected_idx \
) { \
using _CheckpointDerivedType = \
::checkpoint::dispatch::vrt::checkpoint_derived_type_t<decltype(this)>; \
::checkpoint::instantiateObjSerializer< \
_CheckpointDerivedType, \
checkpoint_serializer_variadic_args() \
>(); \
debug_checkpoint( \
"%s: BEGIN: _checkpointDynamicSerialize: serializer_idx=%d {\n", \
typeid(_CheckpointDerivedType).name(), base_ser_idx \
); \
::checkpoint::dispatch::vrt::assertTypeIdxMatch<_CheckpointDerivedType>(expected_idx); \
auto base_idx = ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<PARENT>(); \
PARENT::_checkpointDynamicSerialize(s, base_ser_idx, base_idx); \
auto dispatcher = \
::checkpoint::dispatch::vrt::serializer_registry::getBaseIdx<_CheckpointDerivedType>( \
base_ser_idx \
); \
dispatcher(s, *static_cast<_CheckpointDerivedType*>(this)); \
debug_checkpoint( \
"%s: END: _checkpointDynamicSerialize: serializer_idx=%d }\n", \
typeid(_CheckpointDerivedType).name(), base_ser_idx \
); \
} \
template <> \
::checkpoint::dispatch::vrt::TypeIdx CLASS::_checkpointDynamicTypeIndex() { \
using _CheckpointDerivedType = \
::checkpoint::dispatch::vrt::checkpoint_derived_type_t<decltype(this)>; \
return ::checkpoint::dispatch::vrt::objregistry::makeObjIdx<_CheckpointDerivedType>(); \
}

#define checkpoint_virtual_serialize_derived(DERIVED, PARENT) checkpoint_virtual_serialize_derived_from(PARENT)

namespace checkpoint { namespace dispatch { namespace vrt {
Expand Down