STORMM Source Documentation
Loading...
Searching...
No Matches
binary_encoding.h
1// -*-c++-*-
2#ifndef STORMM_BINARY_ENCODING_H
3#define STORMM_BINARY_ENCODING_H
4
5#include <cstdint>
6#include <string>
7#include <vector>
8#include "copyright.h"
9#include "DataTypes/common_types.h"
10#include "DataTypes/stormm_vector_types.h"
11#include "Synthesis/phasespace_synthesis.h"
12#include "Trajectory/coordinateframe.h"
13#include "Trajectory/coordinate_series.h"
14#include "Trajectory/phasespace.h"
15
16namespace stormm {
17namespace diskutil {
18
19using card::Hybrid;
20using card::HybridTargetLevel;
21using synthesis::PhaseSpaceSynthesis;
22using trajectory::CoordinateFrame;
23using trajectory::CoordinateFrameReader;
24using trajectory::CoordinateSeries;
25using trajectory::PhaseSpace;
26
29const char default_binary_file_descriptor[] = "No description provided";
30const char default_cf_descriptor[] = "CoordinateFrame with positions";
31const char default_ps_descriptor[] = "PhaseSpace with positions and velocities";
32const char default_cs_descriptor[] = "CoordinateSeries with positions";
33const char default_polyps_descriptor[] = "PhaseSpaceSynthesis with positions";
35
38public:
39
51 template <typename T>
52 BinaryFileContent(T content_in, bool repeating_in, const std::string description_in,
53 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
54
55 BinaryFileContent(size_t ct_vptr_in, size_t length_in, const void* vptr_in, bool repeating_in,
56 const std::string &description_in,
57 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
59
63 void setLowerBound(llint lower_bound_in);
64
68 void setUpperBound(llint upper_bound_in);
69
70private:
71 size_t ct_vptr;
74 uint16_t type_code;
90 size_t length;
91 std::string description;
92 void* vptr;
94 HybridTargetLevel tier;
96 llint lower_bound;
98 llint upper_bound;
100};
101
106public:
107
125 BinaryFileKey(const std::string &description_in = std::string(""));
126
127 template <typename T> BinaryFileKey(const T* content, size_t length,
128 const std::string &description_in = std::string(""),
129 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
130
131 template <typename T> BinaryFileKey(const std::vector<T> *content,
132 const std::string &description_in = std::string(""));
133
134 template <typename T> BinaryFileKey(const std::vector<T> &content,
135 const std::string &description_in = std::string(""));
136
137 template <typename T> BinaryFileKey(const Hybrid<T> *content,
138 const std::string &description_in = std::string(""),
139 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
140
141 template <typename T> BinaryFileKey(const Hybrid<T> &content,
142 const std::string &description_in = std::string(""),
143 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
144
146 const std::string &description_in = std::string(default_cf_descriptor),
147 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
148
150 const std::string &description_in = std::string(default_cf_descriptor),
151 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
152
153 BinaryFileKey(const PhaseSpace *ps,
154 const std::string &description_in = std::string(default_ps_descriptor),
155 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
156
157 BinaryFileKey(const PhaseSpace &ps,
158 const std::string &description_in = std::string(default_ps_descriptor),
159 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
160
161 template <typename T>
162 BinaryFileKey(const CoordinateSeries<T> *content,
163 const std::string &description_in = std::string(default_cs_descriptor),
164 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
165
166 template <typename T>
167 BinaryFileKey(const CoordinateSeries<T> &content,
168 const std::string &description_in = std::string(default_cs_descriptor),
169 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
170
171 BinaryFileKey(const PhaseSpaceSynthesis *content,
172 const std::string &description_in = std::string(default_polyps_descriptor),
173 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
174
175 BinaryFileKey(const PhaseSpaceSynthesis &content,
176 const std::string &description_in = std::string(default_polyps_descriptor),
177 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
179
189 void addArray(const void *vptr, size_t length, size_t ct_vptr, bool repeating_in,
190 const std::string &description_in = std::string(""),
191 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
192
193 template <typename T>
194 void addArray(const T* content, size_t length, bool repeating_in,
195 const std::string &description_in,
196 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
197
198 template <typename T>
199 void addArray(const std::vector<T> *content, bool repeating_in,
200 const std::string &description_in = std::string(""));
201
202 template <typename T>
203 void addArray(const std::vector<T> &content, bool repeating_in,
204 const std::string &description_in = std::string(""));
205
206 template <typename T>
207 void addArray(const Hybrid<T> *content, bool repeating_in,
208 const std::string &description_in = std::string(""),
209 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
210
211 template <typename T>
212 void addArray(const Hybrid<T> &content, bool repeating_in,
213 const std::string &description_in = std::string(""),
214 HybridTargetLevel tier_in = HybridTargetLevel::HOST);
216
226 template <typename T> void addScalar(T parm,
227 const std::string &description_in = std::string(""));
229
232 template <typename T2> void addTuple2(T2 parm,
233 const std::string &description_in = std::string(""));
234
237 template <typename T3> void addTuple3(T3 parm,
238 const std::string &description_in = std::string(""));
239
242 template <typename T4> void addTuple4(T4 parm,
243 const std::string &description_in = std::string(""));
244
245private:
246 std::string description;
250 std::vector<char> tiers;
261 std::vector<BinaryFileContent> singleton_items;
264 std::vector<BinaryFileContent> array_items;
266 size_t stride;
272 size_t toc_bytes;
275 size_t nonrepeating_bytes;
277 llint total_expected_bytes;
283 llint total_written_bytes;
287 llint toc_checksum;
290 llint content_checksum;
295 TrajectoryCompression packed_format;
297};
298
301char codifyHybridTargetLevel(HybridTargetLevel tier);
302
314uint16_t codifyTypeIndex(size_t ct, bool is_array, bool is_repeatable);
315
316} // namespace diskutil
317} // namespace stormm
318
319#include "binary_encoding.tpp"
320
321#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
BinaryFileContent(T content_in, bool repeating_in, const std::string description_in, HybridTargetLevel tier_in=HybridTargetLevel::HOST)
The constructor requires the type of data, its length, some way to make a pointer to the data itself,...
void setUpperBound(llint upper_bound_in)
Set the upper bound of memory for this content within a binary file.
Definition binary_encoding.cpp:23
void setLowerBound(llint lower_bound_in)
Set the lower bound of memory for this content within a binary file.
Definition binary_encoding.cpp:18
void addTuple2(T2 parm, const std::string &description_in=std::string(""))
Add a two-component tuple to the table of contents. Descriptions of input parameters follow from addS...
void addTuple4(T4 parm, const std::string &description_in=std::string(""))
Add a four-component tuple to the table of contents. Descriptions of input parameters follow from add...
void addArray(const void *vptr, size_t length, size_t ct_vptr, bool repeating_in, const std::string &description_in=std::string(""), HybridTargetLevel tier_in=HybridTargetLevel::HOST)
Add a new array to the current table of contents. The array will be appended by default,...
Definition binary_encoding.cpp:308
void addTuple3(T3 parm, const std::string &description_in=std::string(""))
Add a three-component tuple to the table of contents. Descriptions of input parameters follow from ad...
void addScalar(T parm, const std::string &description_in=std::string(""))
Add a critical scalar constant to the table of contents. Every added array gets its own sizing consta...
BinaryFileKey(const std::string &description_in=std::string(""))
The constructor can take one or more arrays as well as specific objects, for convenience.
Definition binary_encoding.cpp:28
A fixed-precision representation of coordinates, velocities, and forces to manage a set of simulation...
Definition phasespace_synthesis.h:325
Store the coordinates and box information for a frame, only. This abridged struct can serve when the ...
Definition coordinateframe.h:111
Store the coordinates and box information for a series of frames, in one of several levels of precisi...
Definition coordinate_series.h:137
An object to complement a topology and hold positions, velocities, and forces of all particles in a s...
Definition phasespace.h:141