MADNESS  0.10.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
madness::archive::BaseParallelArchive< Archive > Class Template Reference

Base class for input and output parallel archives. More...

#include <parallel_archive.h>

Collaboration diagram for madness::archive::BaseParallelArchive< Archive >:
Collaboration graph
[legend]

Public Member Functions

template<typename X = Archive>
 BaseParallelArchive (typename std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, int > nio=0)
 Default constructor. More...
 
 BaseParallelArchive (World &world, Archive &ar, int nio)
 
template<typename objT >
void broadcast (objT &obj, ProcessID root) const
 Same as world.gop.broadcast_serializable(obj, root). More...
 
void close ()
 Closes the parallel archive. More...
 
bool dofence () const
 Check if we should fence around a read/write operation. More...
 
Worldget_world () const
 Returns a pointer to the world. More...
 
ProcessID io_node (ProcessID rank) const
 Returns the process doing I/O for given node. More...
 
bool is_io_node () const
 Returns true if this node is doing physical I/O. More...
 
Archive & local_archive () const
 Returns a reference to the local archive. More...
 
ProcessID my_io_node () const
 Returns the process doing I/O for this node. More...
 
int num_io_clients () const
 Returns the number of I/O clients for this node, including self (zero if not an I/O node). More...
 
template<typename X = Archive>
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. More...
 
void remove ()
 Removes the files associated with the current archive. More...
 
void set_dofence (bool dofence)
 Set the flag for fencing around a read/write operation. More...
 
void set_nclient (World &world)
 

Static Public Member Functions

template<typename X = Archive>
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. More...
 
template<typename X = Archive>
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. More...
 

Static Public Attributes

static const bool is_parallel_archive = true
 Mark this class as a parallel archive. More...
 

Private Attributes

Archive ar
 The local archive. More...
 
bool do_fence =true
 If true (default), a read/write of parallel objects fences before and after I/O. More...
 
char fname [256]
 Name of the archive. More...
 
int nclient
 Number of clients of this node, including self. Zero if not I/O node. More...
 
int nio
 Number of I/O nodes (always includes node zero). More...
 
Worldworld
 The world. More...
 

Detailed Description

template<typename Archive>
class madness::archive::BaseParallelArchive< Archive >

Base class for input and output parallel archives.

Template Parameters
ArchiveThe local archive. Only tested for BinaryFstreamInputArchive and BinaryFstreamOutputArchive.
Todo:
Should this class derive from BaseArchive?

Constructor & Destructor Documentation

◆ BaseParallelArchive() [1/2]

template<typename Archive >
madness::archive::BaseParallelArchive< Archive >::BaseParallelArchive ( World world,
Archive &  ar,
int  nio 
)
inline

◆ BaseParallelArchive() [2/2]

template<typename Archive >
template<typename X = Archive>
madness::archive::BaseParallelArchive< Archive >::BaseParallelArchive ( typename std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, int >  nio = 0)
inline

Default constructor.

Member Function Documentation

◆ broadcast()

template<typename Archive >
template<typename objT >
void madness::archive::BaseParallelArchive< Archive >::broadcast ( objT &  obj,
ProcessID  root 
) const
inline

Same as world.gop.broadcast_serializable(obj, root).

Template Parameters
objTType of object to broadcast.
Parameters
[in]objThe object to broadcast.
[in]rootThe root process for broadcasting.

References madness::WorldGopInterface::broadcast_serializable(), madness::archive::BaseParallelArchive< Archive >::get_world(), and madness::World::gop.

Referenced by madness::archive::ArchiveImpl< ParallelInputArchive< localarchiveT >, archive_array< T > >::wrap_load(), and madness::archive::ArchiveImpl< ParallelInputArchive< localarchiveT >, T >::wrap_load().

◆ close()

template<typename Archive >
void madness::archive::BaseParallelArchive< Archive >::close ( )
inline

◆ dofence()

template<typename Archive >
bool madness::archive::BaseParallelArchive< Archive >::dofence ( ) const
inline

◆ exists()

template<typename Archive >
template<typename X = Archive>
static std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value, bool> madness::archive::BaseParallelArchive< Archive >::exists ( World world,
const char *  filename 
)
inlinestatic

Returns true if the named, unopened archive exists on disk with read access.

This is a collective operation.

Parameters
[in]worldThe world.
[in]filenameName of the file.
Returns
True if the named, unopened archive exists and is readable.

References madness::WorldGopInterface::broadcast(), bufsize, madness::filename, madness::World::gop, MADNESS_CHECK, madness::World::rank(), status, and madness::archive::BaseParallelArchive< Archive >::world.

Referenced by madness::archive::BaseParallelArchive< Archive >::open().

◆ get_world()

template<typename Archive >
World* madness::archive::BaseParallelArchive< Archive >::get_world ( ) const
inline

◆ io_node()

template<typename Archive >
ProcessID madness::archive::BaseParallelArchive< Archive >::io_node ( ProcessID  rank) const
inline

Returns the process doing I/O for given node.

Currently assigned in a round-robin fashion to the first nio processes, except on IBM BG/P where we use every 64th.

Parameters
[in]rankThe node to check.
Returns
The process doing I/O for process rank.

References madness::archive::BaseParallelArchive< Archive >::nio.

Referenced by madness::archive::BaseParallelArchive< Archive >::my_io_node(), madness::archive::BaseParallelArchive< Archive >::set_nclient(), and madness::archive::ArchiveStoreImpl< ParallelOutputArchive< localarchiveT >, WorldContainer< keyT, valueT > >::store().

◆ is_io_node()

template<typename Archive >
bool madness::archive::BaseParallelArchive< Archive >::is_io_node ( ) const
inline

◆ local_archive()

template<typename Archive >
Archive& madness::archive::BaseParallelArchive< Archive >::local_archive ( ) const
inline

◆ my_io_node()

template<typename Archive >
ProcessID madness::archive::BaseParallelArchive< Archive >::my_io_node ( ) const
inline

◆ num_io_clients()

template<typename Archive >
int madness::archive::BaseParallelArchive< Archive >::num_io_clients ( ) const
inline

Returns the number of I/O clients for this node, including self (zero if not an I/O node).

Returns
The number of I/O clients for this node, including self (zero if not an I/O node).

References MADNESS_CHECK, madness::archive::BaseParallelArchive< Archive >::nclient, and madness::archive::BaseParallelArchive< Archive >::world.

Referenced by madness::archive::ArchiveStoreImpl< ParallelOutputArchive< localarchiveT >, WorldContainer< keyT, valueT > >::store().

◆ open()

template<typename Archive >
template<typename X = Archive>
std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value, void> madness::archive::BaseParallelArchive< Archive >::open ( World world,
const char *  filename,
int  nwriter = 1 
)
inline

Opens the parallel archive.

Attention
When writing to a new archive, the number of writers specified is used. When reading from an existing archive, the number of ionodes is adjusted to to be the same as the number that wrote the original archive. Presently, we don't have logic to handle reading an archive using fewer processes originally used to write it. If you want to fix this have a look in worlddc.h for the only spot that currently needs changing to make that work.
Note
The default number of I/O nodes is one and there is an arbitrary maximum of 50 set. On IBM BG/P the maximum is nproc/64.
Parameters
[in]worldThe world.
[in]filenameName of the file.
[in]nwriterThe number of writers.

References madness::archive::BaseParallelArchive< Archive >::ar, madness::WorldGopInterface::broadcast(), bufsize, madness::archive::BaseParallelArchive< Archive >::exists(), madness::filename, madness::archive::BaseParallelArchive< Archive >::fname, madness::World::gop, madness::archive::BaseParallelArchive< Archive >::is_io_node(), MADNESS_CHECK, madness::archive::BaseParallelArchive< Archive >::nio, madness::World::rank(), madness::archive::BaseParallelArchive< Archive >::set_nclient(), madness::World::size(), and madness::archive::BaseParallelArchive< Archive >::world.

Referenced by madness::archive::ParallelInputArchive< localarchiveT >::ParallelInputArchive(), madness::archive::ParallelOutputArchive< localarchiveT >::ParallelOutputArchive(), and test13().

◆ remove() [1/2]

template<typename Archive >
void madness::archive::BaseParallelArchive< Archive >::remove ( )
inline

◆ remove() [2/2]

template<typename Archive >
template<typename X = Archive>
static std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value, void> madness::archive::BaseParallelArchive< Archive >::remove ( World world,
const char *  filename 
)
inlinestatic

Deletes the files associated with the archive of the given name.

Presently assumes a shared file system since process zero does the deleting.

Parameters
[in]worldThe world.
[in]filenameBase name of the file.

References bufsize, madness::filename, MADNESS_CHECK, p(), madness::World::rank(), madness::archive::BaseParallelArchive< Archive >::remove(), madness::World::size(), and madness::archive::BaseParallelArchive< Archive >::world.

Referenced by test13(), and test_io().

◆ set_dofence()

template<typename Archive >
void madness::archive::BaseParallelArchive< Archive >::set_dofence ( bool  dofence)
inline

Set the flag for fencing around a read/write operation.

Parameters
[in]dofenceTrue if we should fence; false otherwise.

References madness::archive::BaseParallelArchive< Archive >::dofence().

◆ set_nclient()

template<typename Archive >
void madness::archive::BaseParallelArchive< Archive >::set_nclient ( World world)
inline

Member Data Documentation

◆ ar

template<typename Archive >
Archive madness::archive::BaseParallelArchive< Archive >::ar
mutableprivate

◆ do_fence

template<typename Archive >
bool madness::archive::BaseParallelArchive< Archive >::do_fence =true
private

If true (default), a read/write of parallel objects fences before and after I/O.

Referenced by madness::archive::BaseParallelArchive< Archive >::dofence().

◆ fname

template<typename Archive >
char madness::archive::BaseParallelArchive< Archive >::fname[256]
private

◆ is_parallel_archive

template<typename Archive >
const bool madness::archive::BaseParallelArchive< Archive >::is_parallel_archive = true
static

Mark this class as a parallel archive.

◆ nclient

template<typename Archive >
int madness::archive::BaseParallelArchive< Archive >::nclient
private

Number of clients of this node, including self. Zero if not I/O node.

Referenced by madness::archive::BaseParallelArchive< Archive >::num_io_clients(), and madness::archive::BaseParallelArchive< Archive >::set_nclient().

◆ nio

template<typename Archive >
int madness::archive::BaseParallelArchive< Archive >::nio
private

◆ world

template<typename Archive >
World* madness::archive::BaseParallelArchive< Archive >::world
private

The documentation for this class was generated from the following file: