MADNESS  0.10.1
parallel_archive.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 */
31 
32 #ifndef MADNESS_WORLD_PARALLEL_ARCHIVE_H__INCLUDED
33 #define MADNESS_WORLD_PARALLEL_ARCHIVE_H__INCLUDED
34 
35 /**
36  \file parallel_archive.h
37  \brief Implements \c ParallelInputArchive and \c ParallelOutputArchive for parallel serialization of data.
38  \ingroup serialization
39 */
40 
41 #include <type_traits>
42 #include <madness/world/archive.h>
44 #include <madness/world/world.h>
45 #include <madness/world/worldgop.h>
46 
47 #include <unistd.h>
48 #include <cstring>
49 #include <cstdio>
50 
51 namespace madness {
52  namespace archive {
53 
54  /// \addtogroup serialization
55  /// @{
56 
57  /// Objects that implement their own parallel archive interface should derive from this class.
59 
60 
61  /// Base class for input and output parallel archives.
62 
63  /// \tparam Archive The local archive. Only tested for \c BinaryFstreamInputArchive and \c BinaryFstreamOutputArchive.
64  /// \todo Should this class derive from \c BaseArchive?
65  template <typename Archive>
67  World* world; ///< The world.
68  mutable Archive ar; ///< The local archive.
69  int nio; ///< Number of I/O nodes (always includes node zero).
70  bool do_fence=true; ///< If true (default), a read/write of parallel objects fences before and after I/O.
71  char fname[256]; ///< Name of the archive.
72  int nclient; ///< Number of clients of this node, including self. Zero if not I/O node.
73 
74  public:
75  static const bool is_parallel_archive = true; ///< Mark this class as a parallel archive.
76 
78  : world(&world)
79  , ar(ar)
80  , nio(nio)
81  {
82  fname[0] = 0;
84  }
85 
86 
87  /// Default constructor.
88  template <typename X=Archive>
89  BaseParallelArchive(typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,int> nio=0)
90  : world(nullptr), ar(), nio(nio), do_fence(true) {
91  }
92 
93  /// Returns the process doing I/O for given node.
94 
95  /// Currently assigned in a round-robin fashion to the first
96  /// \c nio processes, except on IBM BG/P where we use every 64th.
97  /// \param[in] rank The node to check.
98  /// \return The process doing I/O for process \c rank.
99  ProcessID io_node(ProcessID rank) const {
100  return rank%nio;
101  }
102 
103  /// Returns the process doing I/O for this node.
104 
105  /// \return The process doing I/O for this node.
108  return io_node(world->rank());
109  }
110 
111  /// Returns the number of I/O clients for this node, including self (zero if not an I/O node).
112 
113  /// \return The number of I/O clients for this node, including self (zero if not an I/O node).
114  int num_io_clients() const {
116  return nclient;
117  }
118 
119  /// Returns true if this node is doing physical I/O.
120 
121  /// \return True if this node is doing physical I/O.
122  bool is_io_node() const {
124  return world->rank() == my_io_node();
125  }
126 
127  /// Returns a pointer to the world.
128 
129  /// \return A pointer to the world.
130  World* get_world() const {
132  return world;
133  }
134 
135  /// Opens the parallel archive.
136 
137  /// \attention When writing to a new archive, the number of writers
138  /// specified is used. When reading from an existing archive,
139  /// the number of `ionode`s is adjusted to to be the same as
140  /// the number that wrote the original archive. Presently,
141  /// we don't have logic to handle reading an archive using
142  /// fewer processes originally used to write it. If you
143  /// want to fix this have a look in worlddc.h for the only
144  /// spot that currently needs changing to make that work.
145  ///
146  /// \note The default number of I/O nodes is one and there is an
147  /// arbitrary maximum of 50 set. On IBM BG/P the maximum
148  /// is nproc/64.
149  /// \param[in] world The world.
150  /// \param[in] filename Name of the file.
151  /// \param[in] nwriter The number of writers.
152 
153  template <typename X=Archive>
154  typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
155  void>
156  open(World& world, const char* filename, int nwriter=1) {
157  this->world = &world;
158  nio = nwriter;
159 #if defined(HAVE_IBMBGP) || defined(HAVE_IBMBGQ)
160  /* Jeff believes that BG is designed to handle up to *
161  * one file per node and I assume no more than 8 ppn */
162  int maxio = world.size()/8;
163 #else
164  int maxio = 50;
165 #endif
166  if (nio > maxio) nio = maxio; // Sanity?
167  if (nio > world.size()) nio = world.size();
168 
170  MADNESS_CHECK(strlen(filename)-1<sizeof(fname));
171  strcpy(fname,filename); // Save the filename for later
172  constexpr std::size_t bufsize=512;
173  char buf[bufsize];
174  MADNESS_CHECK(strlen(filename)+7 <= sizeof(buf));
175  snprintf(buf, bufsize, "%s.%5.5d", filename, world.rank());
176 
177  // if file doesn't exist we have a race condition if this code is handled by a try/catch block
178  // check if file exists outside the (world.rank()==0) block
179  if (ar.is_input_archive and (not exists(world,filename))) {
180  std::string msg = "could not find file: " + std::string(filename);
181  throw std::runtime_error(msg);
182  }
183  if (world.rank() == 0) {
184  ar.open(buf);
185  ar & nio; // read/write nio from/to the archive
186  MADNESS_CHECK(nio <= world.size());
187  }
188 
189  // Ensure all agree on value of nio that may also have changed if reading
190  world.gop.broadcast(nio, 0);
191 
192  // Other reader/writers can now open the local archive
193  if (is_io_node() && world.rank()) {
194  ar.open(buf);
195  }
196 
198  }
199 
200  // Count #client
202  ProcessID me = world.rank();
203  nclient=0;
204  for (ProcessID p=0; p<world.size(); ++p) if (io_node(p) == me) ++nclient;
205 
206  // if (is_io_node()) {
207  // madness::print("I am an IO node with",nclient,"clients and file",buf);
208  // }
209  // else {
210  // madness::print("I am a client served by",my_io_node(),fname);
211  // }
212  }
213 
214  /// Returns true if the named, unopened archive exists on disk with read access.
215 
216  /// This is a collective operation.
217  /// \param[in] world The world.
218  /// \param[in] filename Name of the file.
219  /// \return True if the named, unopened archive exists and is readable.
220  template <typename X=Archive>
221  static
222  typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
223  bool>
224  exists(World& world, const char* filename) {
225  constexpr std::size_t bufsize=512;
226  char buf[bufsize];
227  MADNESS_CHECK(strlen(filename)+7 <= sizeof(buf));
228  snprintf(buf,bufsize, "%s.%5.5d", filename, world.rank());
229  bool status;
230  if (world.rank() == 0)
231  status = (access(buf, F_OK|R_OK) == 0);
232 
234 
235  return status;
236  }
237 
238  /// Closes the parallel archive.
239  void close() {
241  if (is_io_node()) ar.close();
242  }
243 
244  /// Returns a reference to the local archive.
245 
246  /// \throw MadnessException If not an I/O node.
247  /// \return A reference to the local archive.
248  Archive& local_archive() const {
251  return ar;
252  }
253 
254  /// Same as `world.gop.broadcast_serializable(obj, root)`.
255 
256  /// \tparam objT Type of object to broadcast.
257  /// \param[in] obj The object to broadcast.
258  /// \param[in] root The root process for broadcasting.
259  template <typename objT>
260  void broadcast(objT& obj, ProcessID root) const {
261  get_world()->gop.broadcast_serializable(obj, root);
262  }
263 
264  /// Deletes the files associated with the archive of the given name.
265 
266  /// Presently assumes a shared file system since process zero does the
267  /// deleting.
268  /// \param[in] world The world.
269  /// \param[in] filename Base name of the file.
270  template <typename X=Archive>
271  static
272  typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
273  void>
274  remove(World& world, const char* filename) {
275  if (world.rank() == 0) {
276  constexpr std::size_t bufsize=512;
277  char buf[bufsize];
278  MADNESS_CHECK(strlen(filename)+7 <= sizeof(buf));
279  for (ProcessID p=0; p<world.size(); ++p) {
280  snprintf(buf,bufsize, "%s.%5.5d", filename, p);
281  if (::remove(buf)) break;
282  }
283  }
284  }
285 
286  /// Removes the files associated with the current archive.
287  void remove() {
289  remove(*world, fname);
290  }
291 
292  /// Check if we should fence around a read/write operation.
293 
294  /// \return True if we should fence; false otherwise.
295  bool dofence() const {
296  return this->do_fence;
297  }
298 
299  /// Set the flag for fencing around a read/write operation.
300 
301  /// \param[in] dofence True if we should fence; false otherwise.
302  void set_dofence(bool dofence) {
303  do_fence = dofence;
304  }
305  };
306 
307 
308  /// An archive for storing local or parallel data wrapping a \c BinaryFstreamOutputArchive.
309 
310  /// \note Writes of process-local objects only store the data from process zero.
311  ///
312  /// \note Writes of parallel containers (presently only \c WorldContainer) store all data.
313  ///
314  /// Each of the server or I/O nodes creates a
315  /// \c BinaryFstreamOutputArchive with the name `filename.rank`. Client
316  /// processes send their data to servers in a round-robin fashion.
317  ///
318  /// Process zero records the number of writers so that, when the archive is opened
319  /// for reading, the number of readers is forced to match.
320  template <class localarchiveT=BinaryFstreamOutputArchive>
321  class ParallelOutputArchive : public BaseParallelArchive<localarchiveT>, public BaseOutputArchive {
322  public:
324 
325  /// Default constructor.
326  //ParallelOutputArchive() {}
327 
328  ParallelOutputArchive(World& world, localarchiveT& ar, int nio=1) : basear(world, ar, nio) {}
329 
330  /// Creates a parallel archive for output with given base filename and number of I/O nodes.
331 
332  /// \param[in] world The world.
333  /// \param[in] filename Base name of the file.
334  /// \param[in] nio The number of I/O nodes.
335  ParallelOutputArchive(World& world, const char* filename, int nio=1) {
337  }
338 
339  /// Creates a parallel archive for output with given base filename and number of I/O nodes.
340 
341  /// \param[in] world The world.
342  /// \param[in] filename Base name of the file.
343  /// \param[in] nio The number of I/O nodes.
344  ParallelOutputArchive(World& world, const std::string filename, int nio=1) {
345  basear::open(world, filename.c_str(), nio);
346  }
347 
348  /// Flush any data in the archive.
349  void flush() {
350  if (basear::is_io_node()) basear::local_archive().flush();
351  }
352  };
353 
354  /// An archive for storing local or parallel data, wrapping a \c BinaryFstreamInputArchive.
355 
356  /// \note Reads of process-local objects load the values originally stored by process zero,
357  /// which is then broadcast to all processes.
358  ///
359  /// \note Reads of parallel containers (presently only \c WorldContainer) load all data.
360  ///
361  /// The number of I/O nodes or readers is presently ignored. It is
362  /// forced to be the same as the original number of writers and,
363  /// therefore, you cannot presently read an archive from a parallel job
364  /// with fewer total processes than the number of writers.
365  template <class localarchiveT=BinaryFstreamInputArchive>
366  class ParallelInputArchive : public BaseParallelArchive<localarchiveT>, public BaseInputArchive {
367  public:
369  /// Default constructor.
370  //ParallelInputArchive() {}
371 
372  ParallelInputArchive(World& world, localarchiveT& ar, int nio=1) : basear(world, ar, nio) {}
373 
374  /// Creates a parallel archive for input.
375 
376  /// \param[in] world The world.
377  /// \param[in] filename Base name of the file.
378  /// \param[in] nio The number of writers. Ignored, see above.
379  ParallelInputArchive(World& world, const char* filename, int nio=1) {
381  }
382 
383  /// Creates a parallel archive for input.
384 
385  /// \param[in] world The world.
386  /// \param[in] filename Base name of the file.
387  /// \param[in] nio The number of writers. Ignored, see above.
388  ParallelInputArchive(World& world, const std::string filename, int nio=1) {
389  basear::open(world, filename.c_str(), nio);
390  }
391  };
392 
393  /// Disable type info for parallel output archives.
394 
395  /// \tparam T The data type.
396  template <class T, class localarchiveT>
397  struct ArchivePrePostImpl<ParallelOutputArchive<localarchiveT>,T> {
398  /// Store the preamble for this data type in the parallel archive.
399 
400  /// \param[in] ar The archive.
402 
403  /// Store the postamble for this data type in the parallel archive.
404 
405  /// \param[in] ar The archive.
406  static inline void postamble_store(const ParallelOutputArchive<localarchiveT>& ar) {}
407  };
408 
409  /// Disable type info for parallel input archives.
410 
411  /// \tparam T The data type.
412  template <class T, class localarchiveT>
413  struct ArchivePrePostImpl<ParallelInputArchive<localarchiveT>,T> {
414  /// Load the preamble for this data type in the parallel archive.
415 
416  /// \param[in] ar The archive.
417  static inline void preamble_load(const ParallelInputArchive<localarchiveT>& ar) {}
418 
419  /// Load the postamble for this data type in the parallel archive.
420 
421  /// \param[in] ar The archive.
422  static inline void postamble_load(const ParallelInputArchive<localarchiveT>& ar) {}
423  };
424 
425  /// Specialization of \c ArchiveImpl for parallel output archives.
426 
427  /// \attention No type-checking is performed.
428  /// \tparam T The data type.
429  template <class T, class localarchiveT>
430  struct ArchiveImpl<ParallelOutputArchive<localarchiveT>, T> {
431  /// Store the data in the archive.
432 
433  /// Parallel objects are forwarded to their implementation of parallel store.
434  ///
435  /// The function only appears (due to \c enable_if) if \c Q is a parallel
436  /// serializable object.
437  /// \todo Is \c Q necessary? I'm sure it is, but can't figure out why at a first glance.
438  /// \tparam Q Description needed.
439  /// \param[in] ar The parallel archive.
440  /// \param[in] t The parallel object to store.
441  /// \return The parallel archive.
442  template <typename Q>
443  static inline
444  typename std::enable_if<std::is_base_of<ParallelSerializableObject, Q>::value, const ParallelOutputArchive<localarchiveT>&>::type
447  return ar;
448  }
449 
450  /// Store the data in the archive.
451 
452  /// Serial objects write only from process 0.
453  ///
454  /// The function only appears (due to \c enable_if) if \c Q is not
455  /// a parallel serializable object.
456  /// \todo Same question about \c Q.
457  /// \tparam Q Description needed.
458  /// \param[in] ar The parallel archive.
459  /// \param[in] t The serial data.
460  /// \return The parallel archive.
461  template <typename Q>
462  static inline
463  typename std::enable_if<!std::is_base_of<ParallelSerializableObject, Q>::value, const ParallelOutputArchive<localarchiveT>&>::type
465  if (ar.get_world()->rank()==0) {
466  ar.local_archive() & t;
467  }
468  return ar;
469  }
470  };
471 
472  /// Specialization of \c ArchiveImpl for parallel input archives.
473 
474  /// \attention No type-checking is performed.
475  /// \tparam T The data type.
476  template <class T, class localarchiveT>
477  struct ArchiveImpl<ParallelInputArchive<localarchiveT>, T> {
478  /// Load the data from the archive.
479 
480  /// Parallel objects are forwarded to their implementation of parallel load.
481  ///
482  /// The function only appears (due to \c enable_if) if \c Q is a parallel
483  /// serializable object.
484  /// \todo Is \c Q necessary? I'm sure it is, but can't figure out why at a first glance.
485  /// \tparam Q Description needed.
486  /// \param[in] ar The parallel archive.
487  /// \param[out] t Where to put the loaded parallel object.
488  /// \return The parallel archive.
489  template <typename Q>
490  static inline
491  typename std::enable_if<std::is_base_of<ParallelSerializableObject, Q>::value, const ParallelInputArchive<localarchiveT>&>::type
494  return ar;
495  }
496 
497  /// Load the data from the archive.
498 
499  /// Serial objects are read only from process 0 and then broadcasted.
500  ///
501  /// The function only appears (due to \c enable_if) if \c Q is not
502  /// a parallel serializable object.
503  /// \todo Same question about \c Q.
504  /// \tparam Q Description needed.
505  /// \param[in] ar The parallel archive.
506  /// \param[out] t Where to put the loaded data.
507  /// \return The parallel archive.
508  template <typename Q>
509  static inline
510  typename std::enable_if<!std::is_base_of<ParallelSerializableObject, Q>::value, const ParallelInputArchive<localarchiveT>&>::type
512  if (ar.get_world()->rank()==0) {
513  ar.local_archive() & t;
514  }
515  ar.broadcast(const_cast<T&>(t), 0);
516  return ar;
517  }
518  };
519 
520 
521  /// Write the archive array only from process zero.
522 
523  /// \tparam T The array data type.
524  template <class T, class localarchiveT>
525  struct ArchiveImpl< ParallelOutputArchive<localarchiveT>, archive_array<T> > {
526  /// Store the \c archive_array in the parallel archive.
527 
528  /// \param[in] ar The parallel archive.
529  /// \param[in] t The array to store.
530  /// \return The parallel archive.
532  if (ar.get_world()->rank() == 0) ar.local_archive() & t;
533  return ar;
534  }
535  };
536 
537  /// Read the archive array and broadcast.
538 
539  /// \tparam T The array data type.
540  template <class T, class localarchiveT>
541  struct ArchiveImpl< ParallelInputArchive<localarchiveT>, archive_array<T> > {
542  /// Load the \c archive_array from the parallel archive and broadcast it.
543 
544  /// \param[in] ar The parallel archive.
545  /// \param[out] t Where to put the loaded array.
546  /// \return The parallel archive.
548  if (ar.get_world()->rank() == 0) ar.local_archive() & t;
549  ar.broadcast(t, 0);
550  return ar;
551  }
552  };
553 
554  /// Forward a fixed-size array to \c archive_array.
555 
556  /// \tparam T The array data type.
557  /// \tparam n The number of items in the array.
558  template <class T, std::size_t n, typename localarchiveT>
559  struct ArchiveImpl<ParallelOutputArchive<localarchiveT>, T[n]> {
560  /// Store the array in the parallel archive.
561 
562  /// \param[in] ar The parallel archive.
563  /// \param[in] t The array to store.
564  /// \return The parallel archive.
566  ar << wrap(&t[0],n);
567  return ar;
568  }
569  };
570 
571  /// Forward a fixed-size array to \c archive_array.
572 
573  /// \tparam T The array data type.
574  /// \tparam n The number of items in the array.
575  template <class T, std::size_t n, typename localarchiveT>
576  struct ArchiveImpl<ParallelInputArchive<localarchiveT>, T[n]> {
577  /// Load the array from the parallel archive.
578 
579  /// \param[in] ar The parallel archive.
580  /// \param[out] t Where to put the loaded array.
581  /// \return The parallel archive.
583  ar >> wrap(&t[0],n);
584  return ar;
585  }
586  };
587 
588  /// @}
589  }
590 }
591 
592 #endif // MADNESS_WORLD_PARALLEL_ARCHIVE_H__INCLUDED
Interface templates for the archives (serialization).
Implements an archive wrapping a binary filestream.
void broadcast_serializable(objT &obj, ProcessID root)
Broadcast a serializable object.
Definition: worldgop.h:754
void broadcast(void *buf, size_t nbyte, ProcessID root, bool dowork=true, Tag bcast_tag=-1)
Broadcasts bytes from process root while still processing AM & tasks.
Definition: worldgop.cc:173
A parallel world class.
Definition: world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition: world.h:328
WorldGopInterface & gop
Global operations.
Definition: world.h:205
Base class for input archive classes.
Definition: archive.h:374
Base class for output archive classes.
Definition: archive.h:382
Base class for input and output parallel archives.
Definition: parallel_archive.h:66
std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, void > open(World &world, const char *filename, int nwriter=1)
Opens the parallel archive.
Definition: parallel_archive.h:156
bool dofence() const
Check if we should fence around a read/write operation.
Definition: parallel_archive.h:295
void remove()
Removes the files associated with the current archive.
Definition: parallel_archive.h:287
Archive ar
The local archive.
Definition: parallel_archive.h:68
bool do_fence
If true (default), a read/write of parallel objects fences before and after I/O.
Definition: parallel_archive.h:70
Archive & local_archive() const
Returns a reference to the local archive.
Definition: parallel_archive.h:248
int nclient
Number of clients of this node, including self. Zero if not I/O node.
Definition: parallel_archive.h:72
static std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, void > remove(World &world, const char *filename)
Deletes the files associated with the archive of the given name.
Definition: parallel_archive.h:274
World * get_world() const
Returns a pointer to the world.
Definition: parallel_archive.h:130
bool is_io_node() const
Returns true if this node is doing physical I/O.
Definition: parallel_archive.h:122
static std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, bool > exists(World &world, const char *filename)
Returns true if the named, unopened archive exists on disk with read access.
Definition: parallel_archive.h:224
void close()
Closes the parallel archive.
Definition: parallel_archive.h:239
int num_io_clients() const
Returns the number of I/O clients for this node, including self (zero if not an I/O node).
Definition: parallel_archive.h:114
World * world
The world.
Definition: parallel_archive.h:67
BaseParallelArchive(typename std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, int > nio=0)
Default constructor.
Definition: parallel_archive.h:89
void set_nclient(World &world)
Definition: parallel_archive.h:201
ProcessID io_node(ProcessID rank) const
Returns the process doing I/O for given node.
Definition: parallel_archive.h:99
char fname[256]
Name of the archive.
Definition: parallel_archive.h:71
void broadcast(objT &obj, ProcessID root) const
Same as world.gop.broadcast_serializable(obj, root).
Definition: parallel_archive.h:260
void set_dofence(bool dofence)
Set the flag for fencing around a read/write operation.
Definition: parallel_archive.h:302
ProcessID my_io_node() const
Returns the process doing I/O for this node.
Definition: parallel_archive.h:106
BaseParallelArchive(World &world, Archive &ar, int nio)
Definition: parallel_archive.h:77
static const bool is_parallel_archive
Mark this class as a parallel archive.
Definition: parallel_archive.h:75
int nio
Number of I/O nodes (always includes node zero).
Definition: parallel_archive.h:69
An archive for storing local or parallel data, wrapping a BinaryFstreamInputArchive.
Definition: parallel_archive.h:366
ParallelInputArchive(World &world, localarchiveT &ar, int nio=1)
Default constructor.
Definition: parallel_archive.h:372
ParallelInputArchive(World &world, const std::string filename, int nio=1)
Creates a parallel archive for input.
Definition: parallel_archive.h:388
ParallelInputArchive(World &world, const char *filename, int nio=1)
Creates a parallel archive for input.
Definition: parallel_archive.h:379
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition: parallel_archive.h:321
ParallelOutputArchive(World &world, localarchiveT &ar, int nio=1)
Default constructor.
Definition: parallel_archive.h:328
ParallelOutputArchive(World &world, const std::string filename, int nio=1)
Creates a parallel archive for output with given base filename and number of I/O nodes.
Definition: parallel_archive.h:344
void flush()
Flush any data in the archive.
Definition: parallel_archive.h:349
ParallelOutputArchive(World &world, const char *filename, int nio=1)
Creates a parallel archive for output with given base filename and number of I/O nodes.
Definition: parallel_archive.h:335
Objects that implement their own parallel archive interface should derive from this class.
Definition: parallel_archive.h:58
Wrapper for dynamic arrays and pointers.
Definition: archive.h:890
const std::size_t bufsize
Definition: derivatives.cc:16
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition: derivatives.cc:72
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap a dynamically allocated pointer as a typed archive_array.
Definition: archive.h:913
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition: madness_exception.h:190
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static const char * filename
Definition: legendre.cc:96
std::string type(const PairType &n)
Definition: PNOParameters.h:18
void load(Function< T, NDIM > &f, const std::string name)
Definition: mra.h:2751
double Q(double a)
Definition: relops.cc:20
static std::enable_if< std::is_base_of< ParallelSerializableObject, Q >::value, const ParallelInputArchive< localarchiveT > & >::type wrap_load(const ParallelInputArchive< localarchiveT > &ar, const Q &t)
Load the data from the archive.
Definition: parallel_archive.h:492
static std::enable_if<!std::is_base_of< ParallelSerializableObject, Q >::value, const ParallelInputArchive< localarchiveT > & >::type wrap_load(const ParallelInputArchive< localarchiveT > &ar, const Q &t)
Load the data from the archive.
Definition: parallel_archive.h:511
static const ParallelInputArchive< localarchiveT > & wrap_load(const ParallelInputArchive< localarchiveT > &ar, const T(&t)[n])
Load the array from the parallel archive.
Definition: parallel_archive.h:582
static const ParallelInputArchive< localarchiveT > & wrap_load(const ParallelInputArchive< localarchiveT > &ar, const archive_array< T > &t)
Load the archive_array from the parallel archive and broadcast it.
Definition: parallel_archive.h:547
static std::enable_if< std::is_base_of< ParallelSerializableObject, Q >::value, const ParallelOutputArchive< localarchiveT > & >::type wrap_store(const ParallelOutputArchive< localarchiveT > &ar, const Q &t)
Store the data in the archive.
Definition: parallel_archive.h:445
static std::enable_if<!std::is_base_of< ParallelSerializableObject, Q >::value, const ParallelOutputArchive< localarchiveT > & >::type wrap_store(const ParallelOutputArchive< localarchiveT > &ar, const Q &t)
Store the data in the archive.
Definition: parallel_archive.h:464
static const ParallelOutputArchive< localarchiveT > & wrap_store(const ParallelOutputArchive< localarchiveT > &ar, const T(&t)[n])
Store the array in the parallel archive.
Definition: parallel_archive.h:565
static const ParallelOutputArchive< localarchiveT > & wrap_store(const ParallelOutputArchive< localarchiveT > &ar, const archive_array< T > &t)
Store the archive_array in the parallel archive.
Definition: parallel_archive.h:531
Default implementations of wrap_store and wrap_load.
Definition: archive.h:726
Default load of an object via serialize(ar, t).
Definition: archive.h:666
static void postamble_load(const ParallelInputArchive< localarchiveT > &ar)
Load the postamble for this data type in the parallel archive.
Definition: parallel_archive.h:422
static void preamble_load(const ParallelInputArchive< localarchiveT > &ar)
Load the preamble for this data type in the parallel archive.
Definition: parallel_archive.h:417
static void postamble_store(const ParallelOutputArchive< localarchiveT > &ar)
Store the postamble for this data type in the parallel archive.
Definition: parallel_archive.h:406
static void preamble_store(const ParallelOutputArchive< localarchiveT > &ar)
Store the preamble for this data type in the parallel archive.
Definition: parallel_archive.h:401
Default implementation of the pre/postamble for type checking.
Definition: archive.h:509
Default store of an object via serialize(ar, t).
Definition: archive.h:611
int me
Definition: test_binsorter.cc:10
const char * status[2]
Definition: testperiodic.cc:43
Declares the World class for the parallel runtime environment.
Implements global operations.
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:43