/[escript]/branches/subworld2/escriptcore/src/AbstractReducer.h
ViewVC logotype

Contents of /branches/subworld2/escriptcore/src/AbstractReducer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5505 - (show annotations)
Wed Mar 4 23:05:47 2015 UTC (3 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 4016 byte(s)
Changes which were sitting in my trunk dir
1 /*****************************************************************************
2 *
3 * Copyright (c) 2014-2015 by University of Queensland
4 * http://www.uq.edu.au
5 *
6 * Primary Business: Queensland, Australia
7 * Licensed under the Open Software License version 3.0
8 * http://www.opensource.org/licenses/osl-3.0.php
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_REDUCER_H__
17 #define __ESCRIPT_REDUCER_H__
18
19 #include "esysUtils/Esys_MPI.h"
20 #include "escript/Data.h"
21 #include <boost/shared_ptr.hpp>
22
23 namespace escript
24 {
25
26
27 namespace reducerstatus
28 {
29
30 // Because these may be used in loops, the values must form a contiguous block (except ERROR)
31 const unsigned char NONE=0; // I have no value for this var and no interest in it
32 const unsigned char INTERESTED=1; // I am interested in this variable but I have no value for it
33 const unsigned char OLD=2; // I have a copy from elsewhere but no new values to contribute
34 const unsigned char OLDINTERESTED=3; // interested but only have a cached copy (no new values)
35 const unsigned char NEW=4; // I have a new value for this variable
36 const unsigned char ERROR='!'; // Something bad happened
37 }
38
39 // There is currently no way to get a completely generic result out of this
40 class AbstractReducer
41 {
42 public:
43 virtual ~AbstractReducer(){};
44 // Is the value compatible with this reduction function?
45 // does not guarantee the value is compatible with
46 // other values added so far
47 virtual bool valueCompatible(boost::python::object v)=0;
48 // merge the parameter with the answer we already have
49 virtual bool reduceLocalValue(boost::python::object v, std::string& errstring)=0;
50 // clear previous result ready for a new set of reductions
51 virtual void reset()=0;
52
53 virtual std::string description()=0;
54
55 // converse with other subworlds to ensure subtype information matches
56 // The main problem case here would be Data on different function spaces
57 // same communicator requirements for reduceRemoteValues
58 // Must give the same answer when called on any process in the subworlds
59 // Must only be called on
60 virtual bool checkRemoteCompatibility(esysUtils::JMPI& mpi_info, std::string& errstring)=0;
61
62
63 #ifdef ESYS_MPI
64 // send from proc 0 in the communicator to all others
65 virtual bool groupSend(MPI_Comm& com)=0;
66
67 // reduction with some procs submitting identity values
68 virtual bool groupReduce(MPI_Comm& com, char mystate)=0;
69 #endif
70
71 // call to merge with values on other subworlds
72 // It does not take a value argument because local values should have
73 // already been added with reduceLocal
74 // Must only be called on participating SubWorlds
75 // the mpi_info holds a communicator linking corresponding processes
76 // in every participating subworld
77 virtual bool reduceRemoteValues(esysUtils::JMPI& mpi_info, bool active)=0;
78
79 // true if at least one localValue has been added
80 // used to check if this subworld should participate in remote merges
81 bool hasValue();
82
83 // Get a value for this variable from another process
84 // This is not a reduction and will replace any existing value
85 virtual bool recvFrom(Esys_MPI_rank localid, Esys_MPI_rank source, esysUtils::JMPI& mpiinfo)=0;
86
87 // Send a value to this variable to another process
88 // This is not a reduction and will replace any existing value
89 virtual bool sendTo(Esys_MPI_rank localid, Esys_MPI_rank target, esysUtils::JMPI& mpiinfo)=0;
90
91 virtual double getDouble();
92
93 virtual boost::python::object getPyObj()=0;
94
95 virtual void clear();
96
97 virtual bool localOnly()
98 {
99 return false;
100 }
101 protected:
102
103 bool valueadded;
104 static const int PARAMTAG;
105 };
106
107
108 typedef boost::shared_ptr<AbstractReducer> Reducer_ptr;
109
110 }
111
112 #endif // __ESCRIPT_REDUCER_H__
113

  ViewVC Help
Powered by ViewVC 1.1.26