OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
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 {
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
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
This file defines multi-dimensional arrays to store mesh and particle attributes.
Implementations for FFT constructor/destructor and transforms.
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
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
buffer_type buffer_m
serialized data
Definition: Archive.h:100
size_type writepos_m
write position for serialization
Definition: Archive.h:96
void resetWritePos()
Definition: Archive.h:89
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
size_type readpos_m
read position for deserialization
Definition: Archive.h:98
pointer_type getBuffer()
Definition: Archive.h:76
constexpr unsigned Dim