escript  Revision_
MPIDataReducer.h
Go to the documentation of this file.
1 /*****************************************************************************
2 *
3 * Copyright (c) 2014-2018 by The University of Queensland
4 * http://www.uq.edu.au
5 *
6 * Primary Business: Queensland, Australia
7 * Licensed under the Apache License, version 2.0
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 * Development 2012-2013 by School of Earth Sciences
12 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
13 * Development from 2019 by School of Earth and Environmental Sciences
14 **
15 *****************************************************************************/
16 
17 #ifndef __ESCRIPT_MPIDATAREDUCER_H__
18 #define __ESCRIPT_MPIDATAREDUCER_H__
19 
20 #include "AbstractReducer.h"
21 #include "Data.h"
22 
23 namespace escript
24 {
25 
26 // Reduces using pointwise MPI operations
28 {
29 public:
32 
33  // This is not a constructor parameter because
34  // if these are created outside the subworld, they won't have
35  // access to a domain yet.
36  // I also want SplitWorld to be able to set this
38  bool valueCompatible(boost::python::object v);
39  bool reduceLocalValue(boost::python::object v, std::string& errstring);
40  void reset();
41  bool checkRemoteCompatibility(JMPI& mpi_info, std::string& errstring);
42 
43  void getCompatibilityInfo(std::vector<unsigned>& params);
44 
45  // talk to corresponding processes in other subworlds
46  bool reduceRemoteValues(MPI_Comm& com);
47 
48  // human readable description
49  std::string description();
50 
51  // Get a value for this variable from another process
52  // This is not a reduction and will replace any existing value
53  bool recvFrom(int localid, int source, JMPI& mpiinfo);
54 
55  // Send a value to this variable to another process
56  // This is not a reduction and will replace any existing value
57  bool sendTo(int localid, int target, JMPI& mpiinfo);
58  virtual boost::python::object getPyObj();
59 
60  // send from proc 0 in the communicator to all others
61  bool groupSend(MPI_Comm& com, bool imsending);
62 
63  bool canClash();
64 
65  // reduction with some procs submitting identity values
66  bool groupReduce(MPI_Comm& com, char mystate);
67 
68 
69  void newRunJobs();
70  void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
71 private:
76 };
77 
79 Reducer_ptr makeDataReducer(std::string type);
80 
81 }
82 
83 #endif // __ESCRIPT_MPIDATAREDUCER_H__
84 
escript::MPIDataReducer::sendTo
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIDataReducer.cpp:348
MPI_Status
int MPI_Status
Definition: EsysMPI.h:47
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
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::AbstractReducer
Definition: AbstractReducer.h:44
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:52
MPI_Op
int MPI_Op
Definition: EsysMPI.h:46
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:75
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:5855
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:3630
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:54
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:41
MPI_OP_NULL
#define MPI_OP_NULL
Definition: EsysMPI.h:58
SplitWorldException.h
escript::MPIDataReducer::dom
escript::const_Domain_ptr dom
Definition: MPIDataReducer.h:73
escript::FunctionSpace
Definition: FunctionSpace.h:36
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
escript::Data::complicate
void complicate()
Definition: Data.cpp:6053
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:119
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:44
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:74
escript::SplitWorldException
Definition: SplitWorldException.h:29
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:2018
escript::MPIDataReducer::value
escript::Data value
Definition: MPIDataReducer.h:72
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:115
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:49
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:215
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:44
escript::MPIDataReducer::~MPIDataReducer
~MPIDataReducer()
Definition: MPIDataReducer.h:31
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:5837
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:55
escript::MPIDataReducer::reduceop
MPI_Op reduceop
Definition: MPIDataReducer.h:74
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:44
escript::AbstractReducer::valueadded
bool valueadded
Definition: AbstractReducer.h:113
escript::MPIDataReducer
Definition: MPIDataReducer.h:28
escript::MPIDataReducer::reset
void reset()
Definition: MPIDataReducer.cpp:174