Psi4
Public Types | Public Member Functions | Protected Attributes | List of all members
psi::Parallel< DerivedType > Class Template Reference

#include <parallel.h>

Public Types

typedef Parallel< DerivedType > ThisType
 This typedef is the type of this class. More...
 

Public Member Functions

 Parallel ()
 Sets current comm to COMM_WORLD. More...
 
virtual ~Parallel ()
 No memory to free-up, does nothing. More...
 
virtual void sync (const std::string &CommName="NONE") const
 Provides MPI barrier functionality. More...
 
template<typename T >
void all_reduce (const T *localdata, const int nelem, T *target, const MPIOperation &op, const std::string &Name) const
 Performs and all reduce. More...
 
template<class T >
void all_gather (const T *localdata, const int nelem, T *target, const std::string &CommName="NONE") const
 Function for gathering a vector whose elements lie on different MPI processes. More...
 
template<class T >
void gather (const T *localdata, const int nelem, T *target, const int Root, const std::string &CommName="NONE") const
 Same as all_gather, except only root has copy. More...
 
template<class T >
void bcast (T *data, const int nelem, const int broadcaster, const std::string &CommName="NONE") const
 Function for broadcasting data held by one process to all other processes. More...
 
template<class T >
void bcast (T &data, const int broadcaster, const std::string &CommName="NONE") const
 
virtual int Iprobe (const int Sender, const int MessageTag, const std::string &Comm="NONE") const
 Sees if a message is available. More...
 
virtual int probe (const int Sender, const int MessageTag, const std::string &Comm="NONE") const
 Same as Iprobe, except blocking. More...
 
template<typename T >
void Isend (const int destination, const int tag, T *message=NULL, const int length=0, const std::string &Comm="NONE") const
 Non-blocking send. More...
 
template<typename T >
void send (const int destination, const int tag, T *message=NULL, const int length=0, const std::string &Comm="NONE") const
 blocking send More...
 
template<typename T >
void Irecv (const int source, const int tag, T *message=NULL, const int length=0, const std::string &Comm="NONE") const
 Non-blocking receive. More...
 
template<typename T >
void recv (const int source, const int tag, T *message=NULL, const int length=0, const std::string &Comm="NONE") const
 Blocking receive. More...
 
virtual int me (const std::string &CommName="NONE") const
 Returns the current MPI process number. More...
 
virtual int nproc (const std::string &CommName="NONE") const
 Returns the current number of MPI processes. More...
 
virtual int nthread () const
 Needed for legacy compatibility. Don't use. More...
 
std::string communicator () const
 Returns the current communicator. More...
 
int thread_id (const pthread_t &)
 
virtual void MakeComm (const std::string &, const int, const std::string &="NONE")
 
virtual void FreeComm (const std::string &="NONE")
 

Protected Attributes

std::vector< std::string > CurrentComm
 Array of our communicator names, in the order they are derived. More...
 

Member Typedef Documentation

template<typename DerivedType>
typedef Parallel<DerivedType> psi::Parallel< DerivedType >::ThisType

This typedef is the type of this class.

Constructor & Destructor Documentation

template<typename DerivedType>
psi::Parallel< DerivedType >::Parallel ( )
inline

Sets current comm to COMM_WORLD.

template<typename DerivedType>
virtual psi::Parallel< DerivedType >::~Parallel ( )
inlinevirtual

No memory to free-up, does nothing.

Member Function Documentation

template<typename DerivedType>
template<class T >
void psi::Parallel< DerivedType >::all_gather ( const T localdata,
const int  nelem,
T target,
const std::string &  CommName = "NONE" 
) const
inline

Function for gathering a vector whose elements lie on different MPI processes.

Parameters
[in]localdataChunk of data held locally
[in]nelemHow long the local chunk is
[in]targetA preallocated place for the gathered data
[in]CommNameMPI communicator this gather will be performed over (default=Current Comm)
template<typename DerivedType>
template<typename T >
void psi::Parallel< DerivedType >::all_reduce ( const T localdata,
const int  nelem,
T target,
const MPIOperation op,
const std::string &  Name 
) const
inline

Performs and all reduce.

For each MPI process:

\[ Target_i=\bigoplus_j Local_{ji}, \]

where the direct sum is meant as a general binary operation, and $Local_{ji}$ is the i-th element held on the j-th MPI process

Parameters
[in]localdataThe local data that is being reduced
[in]nelemThe length of the vector begin combined
[in]targetPreallocated place for putting the result
[in]opThe combining operation
[in]NameThe name of the communicator we are combining over
template<typename DerivedType>
template<class T >
void psi::Parallel< DerivedType >::bcast ( T data,
const int  nelem,
const int  broadcaster,
const std::string &  CommName = "NONE" 
) const
inline

Function for broadcasting data held by one process to all other processes.

Parameters
[in]dataA pre-allocated space for the data (if receiving) else, the data to send
[in]nelemThe length of the data that is being sent
[in]broadcasterWhich MPI process is sending the data
[in]CommNameThe name of the MPI communicator that the broadcast is over (default=current)
template<typename DerivedType>
template<class T >
void psi::Parallel< DerivedType >::bcast ( T data,
const int  broadcaster,
const std::string &  CommName = "NONE" 
) const
inline

See other bcast, difference is this is for serializable things like std::vector (untested!!!)

template<typename DerivedType>
std::string psi::Parallel< DerivedType >::communicator ( ) const
inline

Returns the current communicator.

template<typename DerivedType>
virtual void psi::Parallel< DerivedType >::FreeComm ( const std::string &  = "NONE")
inlinevirtual
template<typename DerivedType>
template<class T >
void psi::Parallel< DerivedType >::gather ( const T localdata,
const int  nelem,
T target,
const int  Root,
const std::string &  CommName = "NONE" 
) const
inline

Same as all_gather, except only root has copy.

template<typename DerivedType>
virtual int psi::Parallel< DerivedType >::Iprobe ( const int  Sender,
const int  MessageTag,
const std::string &  Comm = "NONE" 
) const
inlinevirtual

Sees if a message is available.

Parameters
[in]SenderThe value of the MPI process who we want a message from. Negative int for any source.
[in]MessageTagThe label of the message. Negative for any messsage
Returns
The identity of the sender, or -1 if there is no message
template<typename DerivedType>
template<typename T >
void psi::Parallel< DerivedType >::Irecv ( const int  source,
const int  tag,
T message = NULL,
const int  length = 0,
const std::string &  Comm = "NONE" 
) const
inline

Non-blocking receive.

Parameters
[in]sourceThe identity of the the message sender, negative values for any_source
[in]tagThe message label to receive, negative value for any_tag
[out]messageA preallocated position for the message,NULL if we are just sending a tag
[in]lengthThe length of the message, 0 if we are just sending a tag
template<typename DerivedType>
template<typename T >
void psi::Parallel< DerivedType >::Isend ( const int  destination,
const int  tag,
T message = NULL,
const int  length = 0,
const std::string &  Comm = "NONE" 
) const
inline

Non-blocking send.

Parameters
[in]destinationThe identity of the the message receiver, negative values for any_source
[in]tagThe message label to send, negative value for any_tag
[out]messageA preallocated position for the message,NULL for just a tag
[in]lengthThe length of the message, 0 for just a tag
template<typename DerivedType>
virtual void psi::Parallel< DerivedType >::MakeComm ( const std::string &  ,
const int  ,
const std::string &  = "NONE" 
)
inlinevirtual
template<typename DerivedType>
virtual int psi::Parallel< DerivedType >::me ( const std::string &  CommName = "NONE") const
inlinevirtual

Returns the current MPI process number.

template<typename DerivedType>
virtual int psi::Parallel< DerivedType >::nproc ( const std::string &  CommName = "NONE") const
inlinevirtual

Returns the current number of MPI processes.

template<typename DerivedType>
virtual int psi::Parallel< DerivedType >::nthread ( ) const
inlinevirtual

Needed for legacy compatibility. Don't use.

template<typename DerivedType>
virtual int psi::Parallel< DerivedType >::probe ( const int  Sender,
const int  MessageTag,
const std::string &  Comm = "NONE" 
) const
inlinevirtual

Same as Iprobe, except blocking.

template<typename DerivedType>
template<typename T >
void psi::Parallel< DerivedType >::recv ( const int  source,
const int  tag,
T message = NULL,
const int  length = 0,
const std::string &  Comm = "NONE" 
) const
inline

Blocking receive.

Parameters
[in]sourceThe identity of the the message sender, negative values for any_source
[in]tagThe message label to receive, negative value for any_tag
[out]messageA preallocated position for the message, NULL for
[in]lengthThe length of the message
template<typename DerivedType>
template<typename T >
void psi::Parallel< DerivedType >::send ( const int  destination,
const int  tag,
T message = NULL,
const int  length = 0,
const std::string &  Comm = "NONE" 
) const
inline

blocking send

Parameters
[in]destinationThe identity of the the message receiver, negative values for any_source
[in]tagThe message label to send, negative value for any_tag
[out]messageA preallocated position for the message, NULL for just a tag
[in]lengthThe length of the message, 0 for just a tag
template<typename DerivedType>
virtual void psi::Parallel< DerivedType >::sync ( const std::string &  CommName = "NONE") const
inlinevirtual

Provides MPI barrier functionality.

template<typename DerivedType>
int psi::Parallel< DerivedType >::thread_id ( const pthread_t &  )
inline

Member Data Documentation

template<typename DerivedType>
std::vector<std::string> psi::Parallel< DerivedType >::CurrentComm
protected

Array of our communicator names, in the order they are derived.


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