escript  Revision_
MPIScalarReducer.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_SCALARREDUCER_H__
18 #define __ESCRIPT_SCALARREDUCER_H__
19 
20 #include "AbstractReducer.h"
21 
22 namespace escript
23 {
24 
25 // Reduces using pointwise MPI operations on double
27 {
28 public:
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
36  void setDomain(Domain_ptr d);
37  bool valueCompatible(boost::python::object v);
38  bool reduceLocalValue(boost::python::object v, std::string& errstring);
39  void reset();
40  bool checkRemoteCompatibility(JMPI& mpiInfo, 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 
58  double getDouble();
59 
60  virtual boost::python::object getPyObj();
61 
62  // send from proc 0 in the communicator to all others
63  bool groupSend(MPI_Comm& com, bool imsending);
64 
65  bool canClash();
66 
67  // reduction with some procs submitting identity values
68  bool groupReduce(MPI_Comm& com, char mystate);
69 
70  void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
71 
72  void newRunJobs();
73 
74 private:
75  double value;
77  double identity;
79 };
80 
81 
83 Reducer_ptr makeScalarReducer(std::string type);
84 
85 }
86 
87 #endif // __ESCRIPT_SCALARREDUCER_H__
88 
int MPI_Op
Definition: EsysMPI.h:46
int MPI_Comm
Definition: EsysMPI.h:44
Definition: AbstractReducer.h:44
Definition: MPIScalarReducer.h:27
~MPIScalarReducer()
Definition: MPIScalarReducer.h:30
bool had_an_export_this_round
Definition: MPIScalarReducer.h:78
double getDouble()
Definition: MPIScalarReducer.cpp:260
bool groupReduce(MPI_Comm &com, char mystate)
std::string description()
Definition: MPIScalarReducer.cpp:114
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIScalarReducer.cpp:231
bool checkRemoteCompatibility(JMPI &mpiInfo, std::string &errstring)
Definition: MPIScalarReducer.cpp:197
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:251
virtual boost::python::object getPyObj()
Definition: MPIScalarReducer.cpp:265
bool valueCompatible(boost::python::object v)
Definition: MPIScalarReducer.cpp:145
MPI_Op reduceop
Definition: MPIScalarReducer.h:76
MPIScalarReducer(MPI_Op op)
Definition: MPIScalarReducer.cpp:87
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:239
double identity
Definition: MPIScalarReducer.h:77
void newRunJobs()
Definition: MPIScalarReducer.cpp:140
double value
Definition: MPIScalarReducer.h:75
bool groupSend(MPI_Comm &com, bool imsending)
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIScalarReducer.cpp:299
bool canClash()
Definition: MPIScalarReducer.cpp:310
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIScalarReducer.cpp:204
void reset()
Definition: MPIScalarReducer.cpp:191
void setDomain(Domain_ptr d)
Definition: MPIScalarReducer.cpp:109
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIScalarReducer.cpp:155
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
Definition: AbstractContinuousDomain.cpp:23
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:119
Reducer_ptr makeScalarReducer(std::string type)
Definition: MPIScalarReducer.cpp:32
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:41
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:74