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 by Centre for Geoscience Computing (GeoComp)
13 *
14 *****************************************************************************/
15 
16 #ifndef __ESCRIPT_MPIDATAREDUCER_H__
17 #define __ESCRIPT_MPIDATAREDUCER_H__
18 
19 #include "AbstractReducer.h"
20 #include "Data.h"
21 
22 namespace escript
23 {
24 
25 // Reduces using pointwise MPI operations
26 class MPIDataReducer : public AbstractReducer
27 {
28 public:
30  ~MPIDataReducer() {}
31 
32  // This is not a constructor parameter because
33  // if these are created outside the subworld, they won't have
34  // access to a domain yet.
35  // I also want SplitWorld to be able to set this
37  bool valueCompatible(boost::python::object v);
38  bool reduceLocalValue(boost::python::object v, std::string& errstring);
39  void reset();
40  bool checkRemoteCompatibility(JMPI& mpi_info, std::string& errstring);
41 
42  void getCompatibilityInfo(std::vector<unsigned>& params);
43 
44  // talk to corresponding processes in other subworlds
45  bool reduceRemoteValues(MPI_Comm& com);
46 
47  // human readable description
48  std::string description();
49 
50  // Get a value for this variable from another process
51  // This is not a reduction and will replace any existing value
52  bool recvFrom(int localid, int source, JMPI& mpiinfo);
53 
54  // Send a value to this variable to another process
55  // This is not a reduction and will replace any existing value
56  bool sendTo(int localid, int target, JMPI& mpiinfo);
57  virtual boost::python::object getPyObj();
58 
59  // send from proc 0 in the communicator to all others
60  bool groupSend(MPI_Comm& com, bool imsending);
61 
62  bool canClash();
63 
64  // reduction with some procs submitting identity values
65  bool groupReduce(MPI_Comm& com, char mystate);
66 
67 
68  void newRunJobs();
69  void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
70 private:
75 };
76 
77 Reducer_ptr makeDataReducer(std::string type);
78 
79 }
80 
81 #endif // __ESCRIPT_MPIDATAREDUCER_H__
82 
escript::MPIDataReducer::sendTo
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIDataReducer.cpp:346
MPI_Status
int MPI_Status
Definition: EsysMPI.h:43
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1163
escript::makeDataReducer
Reducer_ptr makeDataReducer(std::string type)
Definition: MPIDataReducer.cpp:45
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:73
MPI_Op
int MPI_Op
Definition: EsysMPI.h:42
AbstractReducer.h
escript::MPIDataReducer::newRunJobs
void newRunJobs()
Definition: MPIDataReducer.cpp:78
escript::MPIDataReducer::groupReduce
bool groupReduce(MPI_Comm &com, char mystate)
Definition: MPIDataReducer.cpp:566
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:1207
escript::Data::getLength
DataTypes::RealVectorType::size_type getLength() const
Return the number of doubles stored for this Data.
Definition: Data.cpp:1370
escript::Data::getDomain
const_Domain_ptr getDomain() const
Return the domain.
Definition: Data.h:473
escript::MPIDataReducer::had_an_export_this_round
bool had_an_export_this_round
Definition: MPIDataReducer.h:97
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:691
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:5862
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:3637
escript::DataTypes::DataVectorAlt< real_t >
escript::Data::isTagged
bool isTagged() const
Return true if this Data is tagged.
Definition: Data.cpp:1128
escript::MPIDataReducer::reduceLocalValue
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIDataReducer.cpp:117
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:50
escript::MPIDataReducer::setDomain
void setDomain(escript::Domain_ptr d)
Definition: MPIDataReducer.cpp:83
escript::Data::isConstant
bool isConstant() const
Return true if this Data is constant.
Definition: Data.cpp:1142
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:47
MPI_OP_NULL
#define MPI_OP_NULL
Definition: EsysMPI.h:54
SplitWorldException.h
escript::MPIDataReducer::dom
escript::const_Domain_ptr dom
Definition: MPIDataReducer.h:95
escript::FunctionSpace
Definition: FunctionSpace.h:45
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:461
escript::Data::complicate
void complicate()
Definition: Data.cpp:6060
MPIDataReducer.h
escript::MPIDataReducer::getPyObj
virtual boost::python::object getPyObj()
Definition: MPIDataReducer.cpp:412
escript::Reducer_ptr
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:128
escript::MPIDataReducer::getCompatibilityInfo
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIDataReducer.cpp:255
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:62
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:1233
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:65
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:70
escript::SplitWorldException
Definition: SplitWorldException.h:38
escript::MPIDataReducer::reduceRemoteValues
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIDataReducer.cpp:225
escript::DataTypes::noValues
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:89
escript::MPIDataReducer::groupSend
bool groupSend(MPI_Comm &com, bool imsending)
Definition: MPIDataReducer.cpp:421
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:2002
escript::MPIDataReducer::value
escript::Data value
Definition: MPIDataReducer.h:94
escript::Data::isEmpty
bool isEmpty() const
Definition: Data.cpp:1135
escript::MPIDataReducer::description
std::string description()
Definition: MPIDataReducer.cpp:88
escript::AbstractReducer::PARAMTAG
static const int PARAMTAG
Definition: AbstractReducer.h:124
escript::MPIDataReducer::canClash
bool canClash()
Definition: MPIDataReducer.cpp:590
escript::MPIDataReducer::valueCompatible
bool valueCompatible(boost::python::object v)
Definition: MPIDataReducer.cpp:98
escript::MPIDataReducer::copyValueFrom
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIDataReducer.cpp:571
MPI_DOUBLE
#define MPI_DOUBLE
Definition: EsysMPI.h:45
escript::MPIDataReducer::MPIDataReducer
MPIDataReducer(MPI_Op op)
Definition: MPIDataReducer.cpp:64
escript
Definition: AbstractContinuousDomain.cpp:22
escript::DataTypes::DataVectorAlt::size
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:237
escript::Data::isExpanded
bool isExpanded() const
Return true if this Data is expanded.
Definition: Data.cpp:1114
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:93
escript::Data::isLazy
bool isLazy() const
Return true if this Data is lazy.
Definition: Data.cpp:1149
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:40
escript::MPIDataReducer::~MPIDataReducer
~MPIDataReducer()
Definition: MPIDataReducer.h:53
Data.h
escript::MPIDataReducer::checkRemoteCompatibility
bool checkRemoteCompatibility(JMPI &mpi_info, std::string &errstring)
Definition: MPIDataReducer.cpp:178
escript::Data::copy
void copy(const Data &other)
Make this object a deep copy of "other".
Definition: Data.cpp:780
escript::MPIDataReducer::recvFrom
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: MPIDataReducer.cpp:297
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:5844
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:76
escript::MPIDataReducer::reduceop
MPI_Op reduceop
Definition: MPIDataReducer.h:96
escript::Data::expand
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition: Data.cpp:1183
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:50
escript::AbstractReducer::valueadded
bool valueadded
Definition: AbstractReducer.h:122
escript::MPIDataReducer
Definition: MPIDataReducer.h:37
escript::MPIDataReducer::reset
void reset()
Definition: MPIDataReducer.cpp:172