MPIDataReducer.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_MPIDATAREDUCER_H__
#define __ESCRIPT_MPIDATAREDUCER_H__
#include "AbstractReducer.h"
#include "Data.h"
namespace escript
{
// Reduces using pointwise MPI operations
class MPIDataReducer : public AbstractReducer
{
public:
MPIDataReducer(MPI_Op op);
~MPIDataReducer() {}
// 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(escript::Domain_ptr d);
bool valueCompatible(boost::python::object v);
bool reduceLocalValue(boost::python::object v, std::string& errstring);
void reset();
bool checkRemoteCompatibility(JMPI& mpi_info, 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);
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 newRunJobs();
void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
private:
escript::Data value;
escript::const_Domain_ptr dom;
MPI_Op reduceop;
bool had_an_export_this_round;
};
Reducer_ptr makeDataReducer(std::string type);
}
#endif // __ESCRIPT_MPIDATAREDUCER_H__
escript::MPIDataReducer::sendTo
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIDataReducer.cpp:348
MPI_Status
int MPI_Status
Definition: EsysMPI.h:45
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1160
escript::makeDataReducer
Reducer_ptr makeDataReducer(std::string type)
Definition: MPIDataReducer.cpp:47
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
MPI_Op
int MPI_Op
Definition: EsysMPI.h:44
AbstractReducer.h
escript::MPIDataReducer::newRunJobs
void newRunJobs()
Definition: MPIDataReducer.cpp:80
escript::MPIDataReducer::groupReduce
bool groupReduce(MPI_Comm &com, char mystate)
Definition: MPIDataReducer.cpp:568
escript::Data::tag
void tag()
If possible convert this Data to DataTagged. This will only allow Constant data to be converted to ta...
Definition: Data.cpp:1204
escript::Data::getLength
DataTypes::RealVectorType::size_type getLength() const
Return the number of doubles stored for this Data.
Definition: Data.cpp:1367
escript::Data::getDomain
const_Domain_ptr getDomain() const
Return the domain.
Definition: Data.h:487
escript::MPIDataReducer::had_an_export_this_round
bool had_an_export_this_round
Definition: MPIDataReducer.h:103
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:705
escript::Data::getNumberOfTaggedValues
size_t getNumberOfTaggedValues() const
For tagged Data returns the number of tags with values. For non-tagged data will return 0 (even Data ...
Definition: Data.cpp:5859
escript::Data::setTaggedValueFromCPP
void setTaggedValueFromCPP(int tagKey, const DataTypes::ShapeType &pointshape, const DataTypes::RealVectorType &value, int dataOffset=0)
Assign the given value to the tag. Implicitly converts this object to type DataTagged if it is consta...
Definition: Data.cpp:3634
escript::DataTypes::DataVectorAlt< real_t >
escript::Data::isTagged
bool isTagged() const
Return true if this Data is tagged.
Definition: Data.cpp:1125
escript::MPIDataReducer::reduceLocalValue
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIDataReducer.cpp:119
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:52
escript::MPIDataReducer::setDomain
void setDomain(escript::Domain_ptr d)
Definition: MPIDataReducer.cpp:85
escript::Data::isConstant
bool isConstant() const
Return true if this Data is constant.
Definition: Data.cpp:1139
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:55
MPI_OP_NULL
#define MPI_OP_NULL
Definition: EsysMPI.h:56
SplitWorldException.h
escript::MPIDataReducer::dom
escript::const_Domain_ptr dom
Definition: MPIDataReducer.h:101
escript::FunctionSpace
Definition: FunctionSpace.h:49
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
escript::Data::complicate
void complicate()
Definition: Data.cpp:6057
MPIDataReducer.h
escript::MPIDataReducer::getPyObj
virtual boost::python::object getPyObj()
Definition: MPIDataReducer.cpp:414
escript::Reducer_ptr
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:132
escript::MPIDataReducer::getCompatibilityInfo
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIDataReducer.cpp:257
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::Data::resolve
void resolve()
If this data is lazy, then convert it to ready data. What type of ready data depends on the expressio...
Definition: Data.cpp:1230
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:71
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
escript::SplitWorldException
Definition: SplitWorldException.h:42
escript::MPIDataReducer::reduceRemoteValues
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIDataReducer.cpp:227
escript::DataTypes::noValues
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:91
escript::MPIDataReducer::groupSend
bool groupSend(MPI_Comm &com, bool imsending)
Definition: MPIDataReducer.cpp:423
escript::Data::getDataRO
const DataTypes::real_t * getDataRO(DataTypes::real_t dummy=0) const
Return a pointer to the beginning of the underlying data.
Definition: Data.h:2016
escript::MPIDataReducer::value
escript::Data value
Definition: MPIDataReducer.h:100
escript::Data::isEmpty
bool isEmpty() const
Definition: Data.cpp:1132
escript::MPIDataReducer::description
std::string description()
Definition: MPIDataReducer.cpp:90
escript::AbstractReducer::PARAMTAG
static const int PARAMTAG
Definition: AbstractReducer.h:128
escript::MPIDataReducer::canClash
bool canClash()
Definition: MPIDataReducer.cpp:592
escript::MPIDataReducer::valueCompatible
bool valueCompatible(boost::python::object v)
Definition: MPIDataReducer.cpp:100
escript::MPIDataReducer::copyValueFrom
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIDataReducer.cpp:573
MPI_DOUBLE
#define MPI_DOUBLE
Definition: EsysMPI.h:47
escript::MPIDataReducer::MPIDataReducer
MPIDataReducer(MPI_Op op)
Definition: MPIDataReducer.cpp:66
escript
Definition: AbstractContinuousDomain.cpp:23
escript::DataTypes::DataVectorAlt::size
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:243
escript::Data::isExpanded
bool isExpanded() const
Return true if this Data is expanded.
Definition: Data.cpp:1111
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:95
escript::Data::isLazy
bool isLazy() const
Return true if this Data is lazy.
Definition: Data.cpp:1146
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:42
escript::MPIDataReducer::~MPIDataReducer
~MPIDataReducer()
Definition: MPIDataReducer.h:59
Data.h
escript::MPIDataReducer::checkRemoteCompatibility
bool checkRemoteCompatibility(JMPI &mpi_info, std::string &errstring)
Definition: MPIDataReducer.cpp:180
escript::Data::copy
void copy(const Data &other)
Make this object a deep copy of "other".
Definition: Data.cpp:777
escript::MPIDataReducer::recvFrom
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: MPIDataReducer.cpp:299
escript::Data::getExpandedVectorReference
DataTypes::RealVectorType & getExpandedVectorReference(DataTypes::real_t dummy=0)
Ensures that the Data is expanded and returns its underlying vector Does not check for exclusive writ...
Definition: Data.cpp:5841
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:82
escript::MPIDataReducer::reduceop
MPI_Op reduceop
Definition: MPIDataReducer.h:102
escript::Data::expand
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition: Data.cpp:1180
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:58
escript::AbstractReducer::valueadded
bool valueadded
Definition: AbstractReducer.h:126
escript::MPIDataReducer
Definition: MPIDataReducer.h:41
escript::MPIDataReducer::reset
void reset()
Definition: MPIDataReducer.cpp:174