IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Archive.h
Go to the documentation of this file.
1//
2// Class Archive
3// Class to (de-)serialize in MPI communication.
4//
5// When data is exchanged between MPI ranks, it is stored in one dimensional
6// arrays. These have the type detail::Archive, which are wrappers around
7// one dimensional Kokkos views of type char. The data is then transferred using
8// MPI send/recv calls. Note that the archive type differs from other buffers in
9// that they have type char and thus contain raw bytes, unlike other typed buffers
10// such as detail::FieldBufferData used by HaloCells.
11//
12#ifndef IPPL_ARCHIVE_H
13#define IPPL_ARCHIVE_H
14
15#include "Types/IpplTypes.h"
16#include "Types/ViewTypes.h"
17
18#include "Types/Vector.h"
19
20namespace ippl {
21 namespace detail {
27
28 template <class... Properties>
29 class Archive {
30 public:
31 using buffer_type = typename ViewType<char, 1, Properties...>::view_type;
32 using pointer_type = typename buffer_type::pointer_type;
33
34 Archive(size_type size = 0);
35
40 template <typename T, class... ViewArgs>
41 void serialize(const Kokkos::View<T*, ViewArgs...>& view, size_type nsends);
42
51 template <typename T, unsigned Dim, class... ViewArgs>
52 void serialize(const Kokkos::View<Vector<T, Dim>*, ViewArgs...>& view,
53 size_type nsends);
54
59 template <typename T, class... ViewArgs>
60 void deserialize(Kokkos::View<T*, ViewArgs...>& view, size_type nrecvs);
61
70 template <typename T, unsigned Dim, class... ViewArgs>
71 void deserialize(Kokkos::View<Vector<T, Dim>*, ViewArgs...>& view, size_type nrecvs);
72
76 pointer_type getBuffer() { return buffer_m.data(); }
77
81 size_type getSize() const { return writepos_m; }
82
83 size_type getBufferSize() const { return buffer_m.size(); }
84
85 void resizeBuffer(size_type size) { Kokkos::resize(buffer_m, size); }
86
87 void reallocBuffer(size_type size) { Kokkos::realloc(buffer_m, size); }
88
89 void resetWritePos() { writepos_m = 0; }
90 void resetReadPos() { readpos_m = 0; }
91
92 ~Archive() = default;
93
94 private:
101 };
102 } // namespace detail
103} // namespace ippl
104
105#include "Archive.hpp"
106
107#endif
constexpr unsigned Dim
Definition Archive.h:20
std::size_t size_type
Definition IpplTypes.h:13
void serialize(const Kokkos::View< T *, ViewArgs... > &view, size_type nsends)
Definition Archive.hpp:20
void resizeBuffer(size_type size)
Definition Archive.h:85
void serialize(const Kokkos::View< Vector< T, Dim > *, ViewArgs... > &view, size_type nsends)
Definition Archive.hpp:37
typename ViewType< char, 1, Properties... >::view_type buffer_type
Definition Archive.h:31
void deserialize(Kokkos::View< T *, ViewArgs... > &view, size_type nrecvs)
Definition Archive.hpp:63
size_type getBufferSize() const
Definition Archive.h:83
size_type getSize() const
Definition Archive.h:81
Archive(size_type size=0)
Definition Archive.hpp:13
void reallocBuffer(size_type size)
Definition Archive.h:87
typename buffer_type::pointer_type pointer_type
Definition Archive.h:32
pointer_type getBuffer()
Definition Archive.h:76
void deserialize(Kokkos::View< Vector< T, Dim > *, ViewArgs... > &view, size_type nrecvs)
Definition Archive.hpp:85