Loading...
Searching...
No Matches
MPISupport.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: MPISupport.h,v 1.1.2.4 2006/03/02 18:52:57 anhi Exp $
//
#ifndef BALL_SYSTEM_MPISUPPORT_H
#define BALL_SYSTEM_MPISUPPORT_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_DATATYPE_STRING_H
# include <BALL/DATATYPE/string.h>
#endif
#ifndef BALL_MATHS_VECTOR3_H
# include <BALL/MATHS/vector3.h>
#endif
#ifndef BALL_COMMON_EXCEPTION_H
# include <BALL/COMMON/exception.h>
#endif
#include <iostream>
#include <mpi.h>
#if MPI_VERSION >= 2
# define BALL_HAS_MPI2_SUPPORT TRUE
#else
# undef BALL_HAS_MPI2_SUPPORT
#endif
namespace BALL
{
class System;
class Options;
class BALL_EXPORT MPISupport
{
public:
enum TAGS
{
TAG_SYSTEM,
TAG_OPTIONS
};
MPISupport(MPI_Comm default_communicator = MPI_COMM_WORLD);
MPISupport(int argc, char** argv,
MPI_Comm default_communicator = MPI_COMM_WORLD,
bool accept_communicator = true);
~MPISupport();
Index getRank();
Index getSize();
MPI_Comm getDefaultCommunicator();
void setDefaultCommunicator(MPI_Comm default_communicator);
bool getFinalizeOnDestruct();
void setFinalizeOnDestruct(bool new_value);
void setMpiInfo(const MPI_Info &mpi_info);
bool isMaster();
void init(int argc, char** argv, bool accept_communicator = true);
void setBarrier();
void sendSystem(const System& system, bool broadcast = true, int receiver = 0);
System* receiveSystem(bool broadcast = true, int source = MPI_ANY_SOURCE);
void sendOptions(const Options& options, bool broadcast = true, int receiver = 0);
Options* receiveOptions(bool broadcast = true, int source = MPI_ANY_SOURCE);
template <typename valuetype>
void distributeDatapoints(const std::vector<valuetype>& input, std::vector<valuetype>& our_share);
template <typename valuetype>
void acceptDatapoints(std::vector<valuetype>& our_share);
template <typename valuetype>
void combineDatapoints(const std::vector<valuetype>& our_share);
template <typename valuetype>
void acceptCombinedDatapoints(std::vector<valuetype>& combined_set, std::vector<valuetype>& our_share);
void* distributeDatapoints(const void* input, int size, Size& numpoints, MPI_Datatype datatype);
void* acceptDatapoints(Size& numpoints, MPI_Datatype datatype);
void combineDatapoints(const void* input, int size, MPI_Datatype datatype);
void* acceptCombinedDatapoints(const void* input, int size, Size& numpoints, MPI_Datatype datatype);
#ifdef BALL_HAS_MPI2_SUPPORT
Size spawn(const String& command, char *argv[], Size wanted_number_of_processes = 0, bool merge_communicator = true);
#endif
template <typename valuetype>
valuetype getSum(valuetype& local_value);
template <typename valuetype>
valuetype getProduct(valuetype& local_value);
template <typename valuetype>
valuetype getMaximum(valuetype& local_value);
template <typename valuetype>
valuetype getMinimum(valuetype& local_value);
protected:
void registerTypes_();
void sendPersistenceStream_(const std::ostringstream& stream,
int tag = MPI_ANY_TAG, bool broadcast = true, int receiver = 0);
void receivePersistenceStream_(std::istringstream& in, int tag = MPI_ANY_TAG,
bool broadcast = true, int source = 0);
Index rank_;
Index comm_size_;
bool finalize_on_destruct_;
MPI_Comm default_communicator_;
MPI_Info mpi_info_object_;
MPI_Datatype mpi_Vector3_float_type_;
MPI_Datatype mpi_Vector3_double_type_;
};
}
#endif
exception.h
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::MPISupport::mpi_Vector3_float_type_
MPI_Datatype mpi_Vector3_float_type_
Definition MPISupport.h:334
BALL::MPISupport::TAGS
TAGS
Definition MPISupport.h:51
BALL::MPISupport::TAG_OPTIONS
@ TAG_OPTIONS
Definition MPISupport.h:53
BALL::MPISupport::TAG_SYSTEM
@ TAG_SYSTEM
Definition MPISupport.h:52
BALL::MPISupport::getSize
Index getSize()
Return the number of processes in MPI_COMM_WORLD.
BALL::MPISupport::receiveSystem
System * receiveSystem(bool broadcast=true, int source=MPI_ANY_SOURCE)
BALL::MPISupport::rank_
Index rank_
Definition MPISupport.h:329
BALL::MPISupport::mpi_info_object_
MPI_Info mpi_info_object_
Definition MPISupport.h:333
BALL::MPISupport::getSum
valuetype getSum(valuetype &local_value)
BALL::MPISupport::distributeDatapoints
void * distributeDatapoints(const void *input, int size, Size &numpoints, MPI_Datatype datatype)
BALL::MPISupport::setBarrier
void setBarrier()
BALL::MPISupport::acceptCombinedDatapoints
void acceptCombinedDatapoints(std::vector< valuetype > &combined_set, std::vector< valuetype > &our_share)
BALL::MPISupport::~MPISupport
~MPISupport()
BALL::MPISupport::acceptDatapoints
void * acceptDatapoints(Size &numpoints, MPI_Datatype datatype)
BALL::MPISupport::combineDatapoints
void combineDatapoints(const std::vector< valuetype > &our_share)
BALL::MPISupport::getFinalizeOnDestruct
bool getFinalizeOnDestruct()
BALL::MPISupport::getRank
Index getRank()
Return the rank of this process.
BALL::MPISupport::acceptCombinedDatapoints
void * acceptCombinedDatapoints(const void *input, int size, Size &numpoints, MPI_Datatype datatype)
BALL::MPISupport::comm_size_
Index comm_size_
Definition MPISupport.h:330
BALL::MPISupport::setMpiInfo
void setMpiInfo(const MPI_Info &mpi_info)
BALL::MPISupport::getMaximum
valuetype getMaximum(valuetype &local_value)
BALL::MPISupport::MPISupport
MPISupport(MPI_Comm default_communicator=MPI_COMM_WORLD)
BALL::MPISupport::getDefaultCommunicator
MPI_Comm getDefaultCommunicator()
Return the default communicator used for MPI calls.
BALL::MPISupport::getMinimum
valuetype getMinimum(valuetype &local_value)
BALL::MPISupport::setFinalizeOnDestruct
void setFinalizeOnDestruct(bool new_value)
Decides whether MPI_Finalize will be called in the destructor.
BALL::MPISupport::registerTypes_
void registerTypes_()
BALL::MPISupport::finalize_on_destruct_
bool finalize_on_destruct_
Definition MPISupport.h:331
BALL::MPISupport::combineDatapoints
void combineDatapoints(const void *input, int size, MPI_Datatype datatype)
BALL::MPISupport::acceptDatapoints
void acceptDatapoints(std::vector< valuetype > &our_share)
BALL::MPISupport::receivePersistenceStream_
void receivePersistenceStream_(std::istringstream &in, int tag=MPI_ANY_TAG, bool broadcast=true, int source=0)
BALL::MPISupport::setDefaultCommunicator
void setDefaultCommunicator(MPI_Comm default_communicator)
Set the default communicator used for MPI calls.
BALL::MPISupport::mpi_Vector3_double_type_
MPI_Datatype mpi_Vector3_double_type_
Definition MPISupport.h:335
BALL::MPISupport::receiveOptions
Options * receiveOptions(bool broadcast=true, int source=MPI_ANY_SOURCE)
BALL::MPISupport::sendSystem
void sendSystem(const System &system, bool broadcast=true, int receiver=0)
BALL::MPISupport::isMaster
bool isMaster()
Returns true if this process is the master, false otherwise.
BALL::MPISupport::default_communicator_
MPI_Comm default_communicator_
Definition MPISupport.h:332
BALL::MPISupport::getProduct
valuetype getProduct(valuetype &local_value)
BALL::MPISupport::sendPersistenceStream_
void sendPersistenceStream_(const std::ostringstream &stream, int tag=MPI_ANY_TAG, bool broadcast=true, int receiver=0)
BALL::MPISupport::MPISupport
MPISupport(int argc, char **argv, MPI_Comm default_communicator=MPI_COMM_WORLD, bool accept_communicator=true)
BALL::MPISupport::sendOptions
void sendOptions(const Options &options, bool broadcast=true, int receiver=0)
BALL::MPISupport::distributeDatapoints
void distributeDatapoints(const std::vector< valuetype > &input, std::vector< valuetype > &our_share)
BALL::MPISupport::init
void init(int argc, char **argv, bool accept_communicator=true)
BALL::Options
Definition options.h:48
BALL::String
Definition string.h:57
BALL::System
Definition KERNEL/system.h:40
common.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105
string.h
vector3.h