32#ifndef MADNESS_WORLD_PARALLEL_ARCHIVE_H__INCLUDED
33#define MADNESS_WORLD_PARALLEL_ARCHIVE_H__INCLUDED
65 template <
typename Archive>
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)
153 template <
typename X=Archive>
154 typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
157 this->world = &
world;
159#if defined(HAVE_IBMBGP) || defined(HAVE_IBMBGQ)
166 if (
nio > maxio)
nio = maxio;
172 constexpr std::size_t
bufsize=512;
180 std::string msg =
"could not find file: " + std::string(
filename);
181 throw std::runtime_error(msg);
220 template <
typename X=Archive>
222 typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
225 constexpr std::size_t
bufsize=512;
231 status = (access(buf, F_OK|R_OK) == 0);
259 template <
typename objT>
270 template <
typename X=Archive>
272 typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
276 constexpr std::size_t
bufsize=512;
320 template <
class localarchiveT=BinaryFstreamOutputArchive>
350 if (basear::is_io_node()) basear::local_archive().flush();
365 template <
class localarchiveT=BinaryFstreamInputArchive>
396 template <
class T,
class localarchiveT>
412 template <
class T,
class localarchiveT>
429 template <
class T,
class localarchiveT>
442 template <
typename Q>
461 template <
typename Q>
476 template <
class T,
class localarchiveT>
489 template <
typename Q>
508 template <
typename Q>
524 template <
class T,
class localarchiveT>
540 template <
class T,
class localarchiveT>
558 template <
class T, std::
size_t n,
typename localarchiveT>
575 template <
class T, std::
size_t n,
typename localarchiveT>
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 output archive classes.
Definition archive.h:382
Base class for input and output parallel archives.
Definition parallel_archive.h:66
bool dofence() const
Check if we should fence around a read/write operation.
Definition parallel_archive.h:295
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
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
int nclient
Number of clients of this node, including self. Zero if not I/O node.
Definition parallel_archive.h:72
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
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
Archive & local_archive() const
Returns a reference to the local archive.
Definition parallel_archive.h:248
static const bool is_parallel_archive
Mark this class as a parallel archive.
Definition parallel_archive.h:75
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
int nio
Number of I/O nodes (always includes node zero).
Definition parallel_archive.h:69
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
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
BaseParallelArchive< localarchiveT > basear
Definition parallel_archive.h:323
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
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const std::size_t bufsize
Definition derivatives.cc:16
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:182
Namespace for all elements and tools of MADNESS.
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, constParallelOutputArchive< 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, constParallelOutputArchive< 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