SubWorld.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2014-2018 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef escript_SubWorld_H
#define escript_SubWorld_H
#include "AbstractDomain.h"
#include "AbstractReducer.h"
#include "EsysMPI.h"
namespace escript
{
class SubWorld : public REFCOUNT_BASE_CLASS(SubWorld)
{
public:
SubWorld(JMPI& globalcom, JMPI& comm, JMPI& corr,
unsigned int subworldcount, unsigned int local_id,
bool manualimport);
~SubWorld();
void setDomain(Domain_ptr d);
Domain_ptr getDomain();
JMPI& getMPI();
JMPI& getCorrMPI();
void addJob(boost::python::object j); // add a Job to the current batch
char runJobs(std::string& errmsg); // run all jobs in the current batch
void clearJobs(); // remove all jobs in the current batch
void addVariable(std::string&, Reducer_ptr& red);
void removeVariable(std::string& name);
void clearVariable(std::string& name);
std::list<std::pair<std::string, bool> > getVarList();
std::list<std::pair<std::string, std::string> > getVarInfo();
size_t getNumVars();
bool localTransport(std::string& errmsg); // gather exported values from jobs
bool checkRemoteCompatibility(std::string& errmsg); // check to ensure values
// in all worlds are compatible
bool deliverImports(std::string& errmsg); // load imports into Job objects
bool amLeader(); // true if this proc is the leader for its world
DataTypes::real_t getScalarVariable(const std::string& name);
boost::python::object getLocalObjectVariable(const std::string& name);
void debug(); // print out current state information
bool synchVariableInfo(std::string& err);
bool synchVariableValues(std::string& err);
void resetInterest();
void copyVariable(const std::string& src, const std::string& dest);
void newRunJobs();
private:
JMPI everyone; // communicator linking all procs in all subworlds
JMPI swmpi; // communicator linking all procs in this subworld
JMPI corrmpi; // communicator linking corresponding procs in all subworlds
// eg: If this proc is the first in its domain, then corrmpi
// links to the other "first in its domain" processes.
// (So one in each SubWorld).
escript::Domain_ptr domain;
std::vector<boost::python::object> jobvec; // jobs in the current batch
unsigned int swcount; // number of subwords
unsigned int localid; // position of this subworld in that sequence
typedef std::map<std::string, Reducer_ptr> str2reduce;
typedef std::map<std::string, unsigned char> str2char;
str2reduce reducemap; // map: name ->reducer for that variable
str2char varstate; // using the state values from AbstractReducer.h
bool manualimports;
#ifdef ESYS_MPI
std::vector<unsigned char> globalvarinfo; // info about which worlds want which vars
// [vars on process0][vars on process 1][vars on ...]
typedef std::map<unsigned char, int> countmap;
typedef std::map<std::string, countmap> str2countmap;
str2countmap globalvarcounts;
bool globalinfoinvalid;
bool makeComm(MPI_Comm& sourcecom, JMPI& sub,std::vector<int>& members);
// a group with NEW nodes at the front and INT and OLDINT at the back
// NONE worlds get an empty communicator
bool makeGroupComm1(MPI_Comm& srccom, int vnum, char mystate, JMPI& com);
// reduce on the first group and copy from cop[0] to others in cop
bool makeGroupReduceGroups(MPI_Comm& srccom, int vnum, char mystate, JMPI& red, JMPI& cop, bool& incopy);
// A group with a single OLD or OLDINT at the front and all the INT worlds
// following it
bool makeGroupComm2(MPI_Comm& srccom, int vnum, char mystate, JMPI& com, bool& ingroup);
#endif
// change the various views of a variable's state
void setMyVarState(const std::string& vname, char state);
void setVarState(const std::string& vname, char state, int swid);
void setAllVarsState(const std::string& name, char state);
};
typedef boost::shared_ptr<SubWorld> SubWorld_ptr;
} // namespace escript
#endif
escript::SubWorld::localid
unsigned int localid
Definition: SubWorld.h:134
escript::SubWorld::debug
void debug()
Definition: SubWorld.cpp:260
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
escript::SubWorld::manualimports
bool manualimports
Definition: SubWorld.h:141
NonReducedVariable.h
AbstractReducer.h
escript::SubWorld::swcount
unsigned int swcount
Definition: SubWorld.h:133
escript::SubWorld::SubWorld
SubWorld(JMPI &globalcom, JMPI &comm, JMPI &corr, unsigned int subworldcount, unsigned int local_id, bool manualimport)
Definition: SubWorld.cpp:36
escript::SubWorld::localTransport
bool localTransport(std::string &errmsg)
Definition: SubWorld.cpp:214
escript::SubWorld::getMPI
JMPI & getMPI()
Definition: SubWorld.cpp:52
escript::SubWorld::synchVariableValues
bool synchVariableValues(std::string &err)
Definition: SubWorld.cpp:608
escript::reducerstatus
Definition: AbstractReducer.h:43
escript::SubWorld::removeVariable
void removeVariable(std::string &name)
Definition: SubWorld.cpp:1017
escript::SubWorld::setDomain
void setDomain(Domain_ptr d)
Definition: SubWorld.cpp:62
escript::SubWorld::str2char
std::map< std::string, unsigned char > str2char
Definition: SubWorld.h:137
escript::SubWorld::getCorrMPI
JMPI & getCorrMPI()
Definition: SubWorld.cpp:57
escript::SubWorld::runJobs
char runJobs(std::string &errmsg)
Definition: SubWorld.cpp:955
escript::SubWorld::newRunJobs
void newRunJobs()
Definition: SubWorld.cpp:1055
escript::reducerstatus::NONE
const unsigned char NONE
Definition: AbstractReducer.h:61
ERROR
#define ERROR
Definition: finley/src/Mesh_readGmsh.cpp:34
escript::SubWorld::getLocalObjectVariable
boost::python::object getLocalObjectVariable(const std::string &name)
Definition: SubWorld.cpp:381
escript::SubWorld::swmpi
JMPI swmpi
Definition: SubWorld.h:124
escript::SubWorld::str2reduce
std::map< std::string, Reducer_ptr > str2reduce
Definition: SubWorld.h:136
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:55
escript::SubWorld::setVarState
void setVarState(const std::string &vname, char state, int swid)
Definition: SubWorld.cpp:124
SplitWorldException.h
escript::NonReducedVariable
Definition: NonReducedVariable.h:42
escript::SubWorld::getNumVars
size_t getNumVars()
Definition: SubWorld.cpp:985
escript::makeInfo
JMPI makeInfo(MPI_Comm comm, bool owncom)
Definition: EsysMPI.cpp:43
MPIDataReducer.h
REFCOUNT_BASE_CLASS
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:31
escript::reducerstatus::INTERESTED
const unsigned char INTERESTED
Definition: AbstractReducer.h:62
MPI_MAX
#define MPI_MAX
Definition: EsysMPI.h:54
escript::SubWorld::clearVariable
void clearVariable(std::string &name)
Definition: SubWorld.cpp:1028
escript::SubWorld::getVarInfo
std::list< std::pair< std::string, std::string > > getVarInfo()
Definition: SubWorld.cpp:1073
escript::Reducer_ptr
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:132
escript::SubWorld::domain
escript::Domain_ptr domain
Definition: SubWorld.h:129
escript::reducerstatus::OLD
const unsigned char OLD
Definition: AbstractReducer.h:63
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
escript::SubWorld::addJob
void addJob(boost::python::object j)
Definition: SubWorld.cpp:72
escript::SubWorld::reducemap
str2reduce reducemap
Definition: SubWorld.h:138
escript::SubWorld::resetInterest
void resetInterest()
Definition: SubWorld.cpp:1040
escript::SplitWorldException
Definition: SplitWorldException.h:42
AbstractDomain.h
escript::SubWorld::deliverImports
bool deliverImports(std::string &errmsg)
Definition: SubWorld.cpp:160
escript::SubWorld::synchVariableInfo
bool synchVariableInfo(std::string &err)
Definition: SubWorld.cpp:806
escript::SubWorld::~SubWorld
~SubWorld()
Definition: SubWorld.cpp:48
escript::reducerstatus::OLDINTERESTED
const unsigned char OLDINTERESTED
Definition: AbstractReducer.h:64
escript::SubWorld::clearJobs
void clearJobs()
Definition: SubWorld.cpp:77
escript::SubWorld::addVariable
void addVariable(std::string &, Reducer_ptr &red)
Definition: SubWorld.cpp:991
SubWorld.h
escript::SubWorld::amLeader
bool amLeader()
Definition: SubWorld.cpp:799
escript::SubWorld::jobvec
std::vector< boost::python::object > jobvec
Definition: SubWorld.h:130
escript::SubWorld::copyVariable
void copyVariable(const std::string &src, const std::string &dest)
Definition: SubWorld.cpp:1089
escript::SubWorld_ptr
boost::shared_ptr< SubWorld > SubWorld_ptr
Definition: SubWorld.h:161
escript::SubWorld::checkRemoteCompatibility
bool checkRemoteCompatibility(std::string &errmsg)
Definition: SubWorld.cpp:418
escript::SubWorld::getDomain
Domain_ptr getDomain()
Definition: SubWorld.cpp:67
escript
Definition: AbstractContinuousDomain.cpp:23
escript::SubWorld::getVarList
std::list< std::pair< std::string, bool > > getVarList()
Definition: SubWorld.cpp:1063
MPIScalarReducer.h
escript::SubWorld::varstate
str2char varstate
Definition: SubWorld.h:139
escript::SubWorld::setAllVarsState
void setAllVarsState(const std::string &name, char state)
Definition: SubWorld.cpp:87
escript::reducerstatus::NEW
const unsigned char NEW
Definition: AbstractReducer.h:65
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:42
escript::SubWorld::getScalarVariable
DataTypes::real_t getScalarVariable(const std::string &name)
Definition: SubWorld.cpp:333
escript::AbstractDomain
Base class for all escript domains.
Definition: AbstractDomain.h:64
escript::MPIScalarReducer
Definition: MPIScalarReducer.h:40
escript::getStringFromPyException
void getStringFromPyException(boost::python::error_already_set e, std::string &errormsg)
Definition: pyerr.cpp:41
escript::SubWorld::everyone
JMPI everyone
Definition: SubWorld.h:123
escript::SubWorld::corrmpi
JMPI corrmpi
Definition: SubWorld.h:125
pyerr.h
EsysMPI.h
escript::SubWorld::setMyVarState
void setMyVarState(const std::string &vname, char state)
Definition: SubWorld.cpp:82