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

Contents of /branches/subworld2/escriptcore/src/SplitWorld.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: 3418 byte(s)
Changes which were sitting in my trunk dir
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2014-2015 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef escript_SplitWorld_H
18 #define escript_SplitWorld_H
19 #include <boost/python.hpp>
20 #include <boost/smart_ptr.hpp>
21 #include "esysUtils/Esys_MPI.h"
22 #include "SubWorld.h"
23 #include "AbstractReducer.h"
24 namespace escript
25 {
26
27 /**
28 * Provides an interface to a collection of subworlds.
29 * Variables are declared and jobs are submitted using this interface.
30 * Internally, the work is done by a local subworld instance (and associated communicators which
31 * this process belongs to). The local subworld will communicate with subworlds
32 * in other processes as needed.
33 * The main reason for this class, is to insulate users from the MPI type thinking needed for
34 * subworlds and instead provide an interface which allows them to think about subworlds as a group.
35 */
36 class SplitWorld
37 {
38 public:
39 SplitWorld(unsigned int numgroups, MPI_Comm global=MPI_COMM_WORLD);
40 ~SplitWorld();
41 boost::python::object buildDomains(boost::python::tuple t, boost::python::dict kwargs);
42
43 void runJobs();
44
45 void addJob(boost::python::object creator, boost::python::tuple tup, boost::python::dict kw);
46
47 void addVariable(std::string name, boost::python::object creator, boost::python::tuple ntup, boost::python::dict kwargs);
48 void removeVariable(std::string name);
49 void clearVariable(std::string name);
50
51 void clearAllJobs();
52
53 double getScalarVariable(const std::string& name);
54
55 unsigned int getWorldCount();
56
57
58
59 private:
60 esysUtils::JMPI globalcom; // communicator linking all procs used in this splitworld
61 esysUtils::JMPI leadercom; // communicator linking the first proc in each subworld
62 escript::SubWorld_ptr localworld; // subworld which this process belongs to
63 unsigned int swcount; // number of subwords
64 unsigned int localid; // position of localworld in overall world sequence
65
66 // details of jobs to be created
67 std::vector<boost::python::object> create;
68 std::vector<boost::python::tuple> tupargs;
69 std::vector<boost::python::dict> kwargs;
70
71 unsigned int jobcounter; // note that the id of the first job is 1 not 0.
72 bool manualimport; // if false, all reduced vars will be shipped to all subworlds
73 void clearPendingJobs();
74 void distributeJobs();
75
76 };
77
78
79 /**
80 used to invoke the SplitWorld version from python (in lieu of a method based equivalent to raw_function)
81 */
82 boost::python::object raw_buildDomains(boost::python::tuple t, boost::python::dict kwargs);
83
84 /**
85 used to invoke the SplitWorld version from python (in lieu of a method based equivalent to raw_function)
86 */
87 boost::python::object raw_addJob(boost::python::tuple t, boost::python::dict kwargs);
88
89 /**
90 used to add a reducer for shared values.
91 */
92 boost::python::object raw_addVariable(boost::python::tuple t, boost::python::dict kwargs);
93 }
94 #endif

  ViewVC Help
Powered by ViewVC 1.1.26