escript  Revision_
MPIScalarReducer.h
Go to the documentation of this file.
1 /*****************************************************************************
2 *
3 * Copyright (c) 2014-2016 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_SCALARREDUCER_H__
17 #define __ESCRIPT_SCALARREDUCER_H__
18 
19 #include "AbstractReducer.h"
20 
21 namespace escript
22 {
23 
24 // Reduces using pointwise MPI operations on double
26 {
27 public:
30 
31  // This is not a constructor parameter because
32  // if these are created outside the subworld, they won't have
33  // access to a domain yet.
34  // I also want SplitWorld to be able to set this
35  void setDomain(Domain_ptr d);
36  bool valueCompatible(boost::python::object v);
37  bool reduceLocalValue(boost::python::object v, std::string& errstring);
38  void reset();
39  bool checkRemoteCompatibility(JMPI& mpiInfo, std::string& errstring);
40 
41  void getCompatibilityInfo(std::vector<unsigned>& params);
42 
43  // talk to corresponding processes in other subworlds
44  bool reduceRemoteValues(MPI_Comm& com);
45 
46  // human readable description
47  std::string description();
48 
49  // Get a value for this variable from another process
50  // This is not a reduction and will replace any existing value
51  bool recvFrom(int localid, int source, JMPI& mpiinfo);
52 
53  // Send a value to this variable to another process
54  // This is not a reduction and will replace any existing value
55  bool sendTo(int localid, int target, JMPI& mpiinfo);
56 
57  double getDouble();
58 
59  virtual boost::python::object getPyObj();
60 
61  // send from proc 0 in the communicator to all others
62  bool groupSend(MPI_Comm& com, bool imsending);
63 
64  bool canClash();
65 
66  // reduction with some procs submitting identity values
67  bool groupReduce(MPI_Comm& com, char mystate);
68 
69  void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
70 
71  void newRunJobs();
72 
73 private:
74  double value;
76  double identity;
78 };
79 
80 
81 Reducer_ptr makeScalarReducer(std::string type);
82 
83 }
84 
85 #endif // __ESCRIPT_SCALARREDUCER_H__
86 
Definition: MPIScalarReducer.h:25
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:238
void newRunJobs()
Definition: MPIScalarReducer.cpp:139
int MPI_Op
Definition: EsysMPI.h:43
Reducer_ptr makeScalarReducer(std::string type)
Definition: MPIScalarReducer.cpp:31
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIScalarReducer.cpp:203
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:250
double identity
Definition: MPIScalarReducer.h:76
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:36
bool groupReduce(MPI_Comm &com, char mystate)
Definition: AbstractContinuousDomain.cpp:22
double value
Definition: MPIScalarReducer.h:74
virtual boost::python::object getPyObj()
Definition: MPIScalarReducer.cpp:264
Definition: AbstractReducer.h:41
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:71
bool checkRemoteCompatibility(JMPI &mpiInfo, std::string &errstring)
Definition: MPIScalarReducer.cpp:196
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIScalarReducer.cpp:230
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:117
void reset()
Definition: MPIScalarReducer.cpp:190
MPI_Op reduceop
Definition: MPIScalarReducer.h:75
~MPIScalarReducer()
Definition: MPIScalarReducer.h:29
void setDomain(Domain_ptr d)
Definition: MPIScalarReducer.cpp:108
MPIScalarReducer(MPI_Op op)
Definition: MPIScalarReducer.cpp:86
double getDouble()
Definition: MPIScalarReducer.cpp:259
bool groupSend(MPI_Comm &com, bool imsending)
int MPI_Comm
Definition: EsysMPI.h:41
std::string description()
Definition: MPIScalarReducer.cpp:113
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIScalarReducer.cpp:298
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIScalarReducer.cpp:154
bool canClash()
Definition: MPIScalarReducer.cpp:309
bool valueCompatible(boost::python::object v)
Definition: MPIScalarReducer.cpp:144
bool had_an_export_this_round
Definition: MPIScalarReducer.h:77