33 #ifndef MADNESS_WORLD_PARAR_H__INCLUDED
34 #define MADNESS_WORLD_PARAR_H__INCLUDED
57 template <
typename Archive>
81 MADNESS_ASSERT(world);
87 MADNESS_ASSERT(world);
93 MADNESS_ASSERT(world);
99 MADNESS_ASSERT(world);
117 void open(
World& world,
const char* filename,
int nwriter=1) {
118 this->world = &world;
120 #if defined(HAVE_IBMBGP) || defined(HAVE_IBMBGQ)
123 int maxio = world.
size()/8;
127 if (nio > maxio) nio = maxio;
128 if (nio > world.
size()) nio = world.
size();
130 MADNESS_ASSERT(filename);
131 MADNESS_ASSERT(strlen(filename)-1<
sizeof(fname));
132 strcpy(fname,filename);
134 MADNESS_ASSERT(strlen(filename)+7 <=
sizeof(buf));
135 sprintf(buf,
"%s.%5.5d", filename, world.
rank());
137 if (world.
rank() == 0) {
140 MADNESS_ASSERT(nio <= world.
size());
167 MADNESS_ASSERT(strlen(filename)+7 <=
sizeof(buf));
168 sprintf(buf,
"%s.%5.5d", filename, world.
rank());
170 if (world.
rank() == 0)
171 status = (access(buf, F_OK|R_OK) == 0);
180 MADNESS_ASSERT(world);
186 MADNESS_ASSERT(world);
192 template <
typename objT>
201 static void remove(
World& world,
const char* filename) {
202 if (world.rank() == 0) {
204 MADNESS_ASSERT(strlen(filename)+7 <=
sizeof(buf));
205 for (
ProcessID p=0; p<world.size(); ++p) {
206 sprintf(buf,
"%s.%5.5d", filename, p);
207 if (::
remove(buf))
break;
214 MADNESS_ASSERT(world);
215 remove(*world, fname);
220 return this->do_fence;
247 open(world, filename, nio);
272 open(world, filename, nio);
295 template <
typename Q>
304 template <
typename Q>
318 template <
typename Q>
327 template <
typename Q>
360 template <
class T, std::
size_t n>
369 template <
class T, std::
size_t n>
379 #endif // MADNESS_WORLD_PARAR_H__INCLUDED
WorldGopInterface & gop
Global operations.
Definition: worldfwd.h:462
bool is_io_node() const
Returns true if this node is doing physical IO.
Definition: parar.h:92
An archive for storing local or parallel data wrapping BinaryFstreamOutputArchive.
Definition: parar.h:241
BaseParallelArchive()
Definition: parar.h:69
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap dynamically allocated pointer as typed archive_array.
Definition: archive.h:820
void flush()
Definition: binfsar.cc:65
Objects that implement their own parallel archive interface should derive from this.
Definition: parar.h:52
Interface templates for the archives (serialization)
ProcessID io_node(ProcessID rank) const
Returns the process doing IO for given node.
Definition: parar.h:75
bool dofence() const
Definition: parar.h:219
void broadcast(objT &obj, ProcessID root) const
Same as world.gop.broadcast_serializable(obj, root)
Definition: parar.h:193
static void store(const Archive &ar, const T &t)
Definition: archive.h:709
ProcessID size() const
Returns the number of processes in this world (same as MPI_Comm_size())
Definition: worldfwd.h:533
Default implementation of pre/postamble.
Definition: archive.h:641
POD holding excitation energy and response vector for a single excitation.
Definition: tdhf_CIS.h:134
disable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:78
Implements archive wrapping a binary filestream.
ParallelOutputArchive()
Definition: parar.h:243
static void postamble_load(const ParallelInputArchive &ar)
Definition: parar.h:288
ParallelOutputArchive(World &world, const char *filename, int nio=1)
Creates a parallel archive for output with given base filename and number of IO nodes.
Definition: parar.h:246
void broadcast_serializable(objT &obj, ProcessID root)
Broadcast a serializable object.
Definition: worldgop.h:707
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
void close()
Closes the parallel archive.
Definition: parar.h:179
Base class for output archives classes.
Definition: archive.h:583
static const ParallelOutputArchive & wrap_store(const ParallelOutputArchive &ar, const archive_array< T > &t)
Definition: parar.h:343
static void load(const Archive &ar, const T &t)
Definition: archive.h:719
Base class for input and output parallel archives.
Definition: parar.h:58
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
Default implementation of wrap_store and wrap_load.
Definition: archive.h:728
void open(World &world, const char *filename, int nwriter=1)
Opens the parallel archive.
Definition: parar.h:117
Wrapper for dynamic arrays and pointers.
Definition: archive.h:451
static madness::enable_if< is_derived_from< Q, ParallelSerializableObject >, const ParallelOutputArchive & >::type wrap_store(const ParallelOutputArchive &ar, const Q &t)
Parallel objects are forwarded to their implementation of parallel store.
Definition: parar.h:298
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:37
int num_io_clients() const
Returns the number of IO clients for this node including self (zero if not an IO node) ...
Definition: parar.h:86
static const ParallelOutputArchive & wrap_store(const ParallelOutputArchive &ar, const T(&t)[n])
Definition: parar.h:362
Archive & local_archive() const
Returns a reference to local archive ... throws if not an IO node.
Definition: parar.h:185
ProcessID rank() const
Returns the process rank in this world (same as MPI_Comm_rank()))
Definition: worldfwd.h:526
World * get_world() const
Returns pointer to the world.
Definition: parar.h:98
static void preamble_load(const ParallelInputArchive &ar)
Definition: parar.h:287
static const bool is_parallel_archive
Definition: parar.h:67
static void preamble_store(const ParallelOutputArchive &ar)
Definition: parar.h:280
static void postamble_store(const ParallelOutputArchive &ar)
Definition: parar.h:281
void broadcast(void *buf, size_t nbyte, ProcessID root, bool dowork=true)
Broadcasts bytes from process root while still processing AM & tasks.
Definition: worldgop.cc:145
void set_dofence(bool dofence)
Definition: parar.h:223
Implements global operations.
void flush()
Definition: parar.h:250
enable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:60
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
static bool exists(World &world, const char *filename)
Returns true if the named, unopened archive exists on disk with read access ... collective.
Definition: parar.h:165
static madness::disable_if< is_derived_from< Q, ParallelSerializableObject >, const ParallelOutputArchive & >::type wrap_store(const ParallelOutputArchive &ar, const Q &t)
Serial objects write only from process 0.
Definition: parar.h:307
ProcessID my_io_node() const
Returns the process doing IO for this node.
Definition: parar.h:80