File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#include " ttg.h"
44#include " ttg/view.h"
55
6+ #include " ttg/serialization.h"
7+
68#include " cuda_kernel.h"
79
810struct value_t {
911 ttg::buffer<double > db; // TODO: rename
1012 int quark;
1113
1214 template <typename Archive>
13- void ttg_serialize (Archive& ar) {
15+ void serialize (Archive& ar, const unsigned int version ) {
1416 ar& quark;
1517 ar& db; // input:
1618 }
1719};
1820
21+ #ifdef TTG_SERIALIZATION_SUPPORTS_MADNESS
1922/* devicebuf is non-POD so provide serialization
2023 * information for members not a devicebuf */
2124namespace madness ::archive {
@@ -24,7 +27,7 @@ namespace madness::archive {
2427 static inline void serialize (const Archive& ar, value_t & obj) { ar& obj.quark & obj.db ; };
2528 };
2629} // namespace madness::archive
27-
30+ # endif // TTG_SERIALIZATION_SUPPORTS_MADNESS
2831
2932TEST_CASE (" Device" , " coro" ) {
3033
Original file line number Diff line number Diff line change @@ -349,6 +349,25 @@ struct buffer {
349349
350350 /* serialization support */
351351
352+ #ifdef TTG_SERIALIZATION_SUPPORTS_BOOST
353+ template <typename Archive>
354+ void serialize (Archive& ar, const unsigned int version) {
355+ if constexpr (ttg::detail::is_output_archive_v<Archive>) {
356+ std::size_t s = size ();
357+ ar& s;
358+ assert (m_ttg_copy != nullptr ); // only tracked objects allowed
359+ m_ttg_copy->iovec_add (ttg::iovec{s*sizeof (T), current_device_ptr ()});
360+ } else {
361+ std::size_t s;
362+ ar & s;
363+ /* initialize internal pointers and then reset */
364+ reset (s);
365+ assert (m_ttg_copy != nullptr ); // only tracked objects allowed
366+ m_ttg_copy->iovec_add (ttg::iovec{s*sizeof (T), current_device_ptr ()});
367+ }
368+ }
369+ #endif // TTG_SERIALIZATION_SUPPORTS_BOOST
370+
352371#ifdef TTG_SERIALIZATION_SUPPORTS_CEREAL
353372 template <class Archive >
354373 std::enable_if_t <std::is_base_of_v<cereal::detail::InputArchiveBase, Archive> ||
You can’t perform that action at this time.
0 commit comments