escript  Revision_Unversioneddirectory
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 "esysUtils/Esys_MPI.h"
20 #include "escript/Data.h"
21 #include <boost/shared_ptr.hpp>
22 #include "AbstractReducer.h"
23 namespace escript
24 {
25 
26 // Reduces using pointwise MPI operations on double
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(esysUtils::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(Esys_MPI_rank localid, Esys_MPI_rank source, esysUtils::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(Esys_MPI_rank localid, Esys_MPI_rank target, esysUtils::JMPI& mpiinfo);
58  double getDouble();
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 
82 Reducer_ptr makeScalarReducer(std::string type);
83 
84 
85 }
86 
87 #endif // __ESCRIPT_SCALARREDUCER_H__
88 
Definition: MPIScalarReducer.h:27
void newRunJobs()
Definition: MPIScalarReducer.cpp:143
Reducer_ptr makeScalarReducer(std::string type)
Definition: MPIScalarReducer.cpp:35
bool reduceRemoteValues(MPI_Comm &com)
Definition: MPIScalarReducer.cpp:208
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:24
double value
Definition: MPIScalarReducer.h:74
virtual boost::python::object getPyObj()
Definition: MPIScalarReducer.cpp:274
Definition: AbstractReducer.h:40
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: MPIScalarReducer.cpp:235
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:117
int MPI_Comm
Definition: Esys_MPI.h:38
void reset()
Definition: MPIScalarReducer.cpp:195
MPI_Op reduceop
Definition: MPIScalarReducer.h:75
~MPIScalarReducer()
Definition: MPIScalarReducer.h:31
void setDomain(escript::Domain_ptr d)
Definition: MPIScalarReducer.cpp:112
MPIScalarReducer(MPI_Op op)
Definition: MPIScalarReducer.cpp:90
double getDouble()
Definition: MPIScalarReducer.cpp:268
bool groupSend(MPI_Comm &com, bool imsending)
bool recvFrom(Esys_MPI_rank localid, Esys_MPI_rank source, esysUtils::JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:243
bool checkRemoteCompatibility(esysUtils::JMPI &mpi_info, std::string &errstring)
Definition: MPIScalarReducer.cpp:201
int Esys_MPI_rank
Definition: Esys_MPI.h:59
int MPI_Op
Definition: Esys_MPI.h:40
std::string description()
Definition: MPIScalarReducer.cpp:117
bool sendTo(Esys_MPI_rank localid, Esys_MPI_rank target, esysUtils::JMPI &mpiinfo)
Definition: MPIScalarReducer.cpp:257
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: MPIScalarReducer.cpp:311
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: MPIScalarReducer.cpp:159
bool canClash()
Definition: MPIScalarReducer.cpp:322
bool valueCompatible(boost::python::object v)
Definition: MPIScalarReducer.cpp:148
bool had_an_export_this_round
Definition: MPIScalarReducer.h:77
boost::shared_ptr< JMPI_ > JMPI
Definition: Esys_MPI.h:79