MPIScalarReducer.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2014-2018 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __ESCRIPT_SCALARREDUCER_H__
#define __ESCRIPT_SCALARREDUCER_H__
#include "AbstractReducer.h"
namespace escript
{
// Reduces using pointwise MPI operations on double
class MPIScalarReducer : public AbstractReducer
{
public:
MPIScalarReducer(MPI_Op op);
~MPIScalarReducer(){};
// This is not a constructor parameter because
// if these are created outside the subworld, they won't have
// access to a domain yet.
// I also want SplitWorld to be able to set this
void setDomain(Domain_ptr d);
bool valueCompatible(boost::python::object v);
bool reduceLocalValue(boost::python::object v, std::string& errstring);
void reset();
bool checkRemoteCompatibility(JMPI& mpiInfo, std::string& errstring);
void getCompatibilityInfo(std::vector<unsigned>& params);
// talk to corresponding processes in other subworlds
bool reduceRemoteValues(MPI_Comm& com);
// human readable description
std::string description();
// Get a value for this variable from another process
// This is not a reduction and will replace any existing value
bool recvFrom(int localid, int source, JMPI& mpiinfo);
// Send a value to this variable to another process
// This is not a reduction and will replace any existing value
bool sendTo(int localid, int target, JMPI& mpiinfo);
double getDouble();
virtual boost::python::object getPyObj();
// send from proc 0 in the communicator to all others
bool groupSend(MPI_Comm& com, bool imsending);
bool canClash();
// reduction with some procs submitting identity values
bool groupReduce(MPI_Comm& com, char mystate);
void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
void newRunJobs();
private:
double value;
MPI_Op reduceop;
double identity;
bool had_an_export_this_round;
};
Reducer_ptr makeScalarReducer(std::string type);
}
#endif // __ESCRIPT_SCALARREDUCER_H__
escript::MPIScalarReducer::~MPIScalarReducer
~MPIScalarReducer()
Definition: MPIScalarReducer.h:58
MPI_Status
int MPI_Status
Definition: EsysMPI.h:45
escript::MPIScalarReducer::setDomain
void setDomain(Domain_ptr d)
Definition: MPIScalarReducer.cpp:109
MPI_Op
int MPI_Op
Definition: EsysMPI.h:44
escript::makeScalarReducer
Reducer_ptr makeScalarReducer(std::string type)
Definition: MPIScalarReducer.cpp:32
AbstractReducer.h
escript::MPIScalarReducer::reset
void reset()
Definition: MPIScalarReducer.cpp:191
escript::MPIScalarReducer::description
std::string description()
Definition: MPIScalarReducer.cpp:114
escript::MPIScalarReducer::getDouble
double getDouble()
Definition: MPIScalarReducer.cpp:260
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:52
escript::MPIScalarReducer::recvFrom
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:239
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:55
escript::MPIScalarReducer::MPIScalarReducer
MPIScalarReducer(MPI_Op op)
Definition: MPIScalarReducer.cpp:87
MPI_OP_NULL
#define MPI_OP_NULL
Definition: EsysMPI.h:56
SplitWorldException.h
escript::MPIScalarReducer::canClash
bool canClash()
Definition: MPIScalarReducer.cpp:310
escript::MPIScalarReducer::identity
double identity
Definition: MPIScalarReducer.h:105
escript::MPIScalarReducer::valueCompatible
bool valueCompatible(boost::python::object v)
Definition: MPIScalarReducer.cpp:145
escript::MPIScalarReducer::sendTo
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:251
escript::MPIScalarReducer::getPyObj
virtual boost::python::object getPyObj()
Definition: MPIScalarReducer.cpp:265
MPI_MAX
#define MPI_MAX
Definition: EsysMPI.h:54
escript::MPIScalarReducer::groupReduce
bool groupReduce(MPI_Comm &com, char mystate)
escript::Reducer_ptr
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:132
escript::MPIScalarReducer::value
double value
Definition: MPIScalarReducer.h:103
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
escript::SplitWorldException
Definition: SplitWorldException.h:42
escript::MPIScalarReducer::getCompatibilityInfo
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIScalarReducer.cpp:231
escript::MPIScalarReducer::reduceRemoteValues
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIScalarReducer.cpp:204
escript::AbstractReducer::PARAMTAG
static const int PARAMTAG
Definition: AbstractReducer.h:128
escript::MPIScalarReducer::newRunJobs
void newRunJobs()
Definition: MPIScalarReducer.cpp:140
MPI_DOUBLE
#define MPI_DOUBLE
Definition: EsysMPI.h:47
MPI_MIN
#define MPI_MIN
Definition: EsysMPI.h:53
escript::MPIScalarReducer::copyValueFrom
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIScalarReducer.cpp:299
escript::MPIScalarReducer::had_an_export_this_round
bool had_an_export_this_round
Definition: MPIScalarReducer.h:106
escript::MPIScalarReducer::groupSend
bool groupSend(MPI_Comm &com, bool imsending)
escript
Definition: AbstractContinuousDomain.cpp:23
MPIScalarReducer.h
escript::reducerstatus::NEW
const unsigned char NEW
Definition: AbstractReducer.h:65
escript::MPIScalarReducer::checkRemoteCompatibility
bool checkRemoteCompatibility(JMPI &mpiInfo, std::string &errstring)
Definition: MPIScalarReducer.cpp:197
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:42
escript::MPIScalarReducer
Definition: MPIScalarReducer.h:40
escript::AbstractReducer::valueadded
bool valueadded
Definition: AbstractReducer.h:126
escript::MPIScalarReducer::reduceLocalValue
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIScalarReducer.cpp:155
escript::MPIScalarReducer::reduceop
MPI_Op reduceop
Definition: MPIScalarReducer.h:104