Shell Class Reference

#include <Shell.h>

Collaboration diagram for Shell:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Shell ()
 ~Shell ()
string doVersion ()
string doRevision ()
void setCwe (ObjId cwe)
ObjId getCwe () const
bool isRunning () const
Id doCreate (string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
bool doDelete (ObjId oid)
ObjId doAddMsg (const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
void doQuit ()
void doStart (double runtime)
void doNonBlockingStart (double runtime)
void doReinit ()
void doStop ()
void doTerminate ()
void doMove (Id orig, ObjId newParent)
Id doCopy (Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
ObjId doFind (const string &path) const
void doUseClock (string path, string field, unsigned int tick)
Id doLoadModel (const string &fname, const string &modelpath, const string &solverClass="")
void doSaveModel (Id model, const string &fileName, bool qflag=0) const
int doWriteSBML (const string &fname, const string &modelpath)
Id doReadSBML (const string &fname, const string &modelpath, const string &solverclass="")
void doSyncDataHandler (Id tgt)
void doReacDiffMesh (Id baseCompartment)
void doSetParserIdleFlag (bool isParserIdle)
void start (double runTime)
void initAck ()
void waitForAck ()
void handleAck (unsigned int ackNode, unsigned int status)
bool isAckPending () const
void handleQuit ()
void handleCreate (const Eref &e, string type, ObjId parent, Id newElm, string name, NodeBalance nb, unsigned int parentMsgIndex)
void destroy (const Eref &e, ObjId oid)
void innerCreate (string type, ObjId parent, Id newElm, string name, const NodeBalance &nb, unsigned int parentMsgIndex)
bool innerCopy (const vector< ObjId > &args, const string &newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
 Does actual work of copying. Returns true on success.
const MsginnerAddMsg (string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
void handleAddMsg (const Eref &e, string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
bool innerMove (Id orig, ObjId newParent)
void handleMove (const Eref &e, Id orig, ObjId newParent)
void handleSync (const Eref &e, Id elm, FuncId fid)
void handleCopy (const Eref &e, vector< ObjId > args, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
bool innerUseClock (string path, string field, unsigned int tick, unsigned int msgIndex)
void handleUseClock (const Eref &e, string path, string field, unsigned int tick, unsigned int msgIndex)
void addClockMsgs (const vector< ObjId > &list, const string &field, unsigned int tick, unsigned int msgIndex)
void doSetClock (unsigned int tickNum, double dt)
void warning (const string &text)
void error (const string &text)
void setShellElement (Element *shelle)
const ProcInfogetProcInfo (unsigned int index) const
void expectVector (bool flag)

Static Public Member Functions

static void clearRestructuringQ ()
static void dropClockMsgs (const vector< ObjId > &list, const string &field)
static void setHardware (unsigned int numCores, unsigned int numNodes, unsigned int myNode)
static unsigned int myNode ()
static unsigned int numNodes ()
static unsigned int numCores ()
static unsigned int numProcessThreads ()
static void loadBalance ()
static void launchParser ()
static bool inBlockingParserCall ()
static bool isSingleThreaded ()
static bool keepLooping ()
static bool isParserIdle ()
static void launchThreads ()
static unsigned int reduceInt (unsigned int val)
static const CinfoinitCinfo ()
static bool adopt (ObjId parent, Id child, unsigned int msgIndex)
static bool adopt (Id parent, Id child, unsigned int msgIndex)
 Adaptor for above function. Also static function.
static const ProcInfoprocInfo ()
 Static func for returning the ProcInfo of the shell.
static bool chopString (const string &path, vector< string > &ret, char separator= '/')
static bool isNameValid (const string &name)
static bool chopPath (const string &path, vector< string > &ret, vector< unsigned int > &index)
static void cleanSimulation ()

Static Public Attributes

static const unsigned int OkStatus = ~0
static const unsigned int ErrorStatus = ~1

Constructor & Destructor Documentation

Shell::Shell (  ) 
Shell::~Shell (  ) 

Member Function Documentation

void Shell::addClockMsgs ( const vector< ObjId > &  list,
const string &  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Utility function to set up messages to schedule a list of Ids using the specified field and tick

bool Shell::adopt ( Id  parent,
Id  child,
unsigned int  msgIndex 
) [static]

Adaptor for above function. Also static function.

References adopt().

Here is the call graph for this function:

bool Shell::adopt ( ObjId  parent,
Id  child,
unsigned int  msgIndex 
) [static]

Static utility function. Attaches child element to parent element. Must only be called from functions executing in parallel on all nodes, as it does a local message addition MsgIndex is needed to be sure that the same msg identifies parent-child connection on all nodes.

References Finfo::addMsg(), ObjId::element(), Id::element(), ObjId::eref(), Cinfo::findFinfo(), Element::getName(), initCinfo(), and Msg::mid().

Referenced by adopt(), buildFinfoElement(), init(), Msg::initMsgManagers(), innerCopyElements(), Cinfo::makeCinfoElements(), testSetGetExtField(), and testStrSet().

Here is the call graph for this function:

static bool Shell::chopPath ( const string &  path,
vector< string > &  ret,
vector< unsigned int > &  index 
) [static]

Chop up the path into a vector of Element names, and also fills out a matching vector of indices. If at any level of the path there are no indices or the index is zero, the index entry * remains empty. Otherwise the entry contains a vector with index values for this level of the path. The zeroth position of this index vector is the slowest varying, i.e., most significant. Returns true if it starts at '/'.

Example: /foo/bar[10]/zod[3][4][5] would return: ret: {"foo", "bar", "zod" } index: { {}, {10}, {3,4,5} }

Referenced by testChopPath().

static bool Shell::chopString ( const string &  path,
vector< string > &  ret,
char  separator = '/' 
) [static]

Chops up the names in the string into the vector of strings, using the specified separator. Returns true if it is an absolute path, that is, starts with the separator.

Referenced by simpleWildcardFind(), and testChopString().

void Shell::cleanSimulation (  )  [static]

Cleans up all Elements except /root itself, /clock, /classes, and /Msgs. In due course will also do suitable reinitialization of tick and other values.

References Neutral::children(), Eref::data(), and doDelete().

Here is the call graph for this function:

static void Shell::clearRestructuringQ (  )  [static]

Works through internal queue of operations that modify the structure of the simulation. These operations have to be carefully separated from any other functions or messaging, so this happens while all other threads are blocked.

void Shell::destroy ( const Eref e,
ObjId  oid 
)

References Eref::data(), Neutral::destroy(), ObjId::eref(), and ObjId::id.

Referenced by initCinfo().

Here is the call graph for this function:

ObjId Shell::doAddMsg ( const string &  msgType,
ObjId  src,
const string &  srcField,
ObjId  dest,
const string &  destField 
)

Sets up a Message of specified type. Later need to consider doing this through MsgSpecs only. Here the 'args' vector handles whatever arguments we may need to pass to the specified msgType.

Referenced by benchmarkMsg(), ReadSwc::build(), ReadCspace::expandEnzyme(), ReadCspace::expandReaction(), makeCompt(), ReadCspace::makePlots(), makeReacTest(), testAssortedMsg(), testClock(), testCopyMsgOps(), testGetMsg(), testGetMsgs(), testMMenzProcess(), testMpiFibonacci(), testMsgElementListing(), testPoolVolumeScaling(), testReacVolumeScaling(), testShellAddMsg(), testStats(), and testTwoReacGetNeighbors().

Id Shell::doCopy ( Id  orig,
ObjId  newParent,
string  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Copies orig Element to newParent. n specifies how many copies are made. copyExtMsgs specifies whether to also copy messages from orig to objects outside the copy tree. Usually we don't do this.

Referenced by testCopy(), testCopyFieldElement(), testCopyMsgOps(), and testGetMsg().

Id Shell::doCreate ( string  type,
ObjId  parent,
string  name,
unsigned int  numData,
NodePolicy  nodePolicy = MooseBlockBalance,
unsigned int  preferredNode = 1 
)
bool Shell::doDelete ( ObjId  oid  ) 
ObjId Shell::doFind ( const string &  path  )  const

Looks up the Id specified by the given path. May include relative references and the internal cwe (current working Element) on the shell

Referenced by Id::Id(), and testTreeTraversal().

Id Shell::doLoadModel ( const string &  fname,
const string &  modelpath,
const string &  solverClass = "" 
)

Loads in a model to a specified path. Tries to figure out model type from fname or contents of file. Currently knows about kkit, cspace. Soon to learn .p, SBML, NeuroML. Later to learn NineML

void Shell::doMove ( Id  orig,
ObjId  newParent 
)

shifts orig Element (including offspring) to newParent. All old hierarchy, data, Msgs etc are preserved below the orig.

References Neutral::child(), Id::element(), ObjId::element(), ObjId::eref(), Element::getName(), Neutral::isDescendant(), ObjId::path(), and warning().

Referenced by ReadKkit::assignPoolCompartments(), ReadKkit::assignReacCompartments(), testMove(), and testObjIdToAndFromPath().

Here is the call graph for this function:

void Shell::doNonBlockingStart ( double  runtime  ) 

Starts off simulation, to run for 'runtime' more than current time. This version returns at once, and the parser can go on to do other things. It has to check with the Shell::isRunning function (accessible as a MOOSE field) to find out if it is finished. Can call 'doStop', 'doTerminate' or 'doReinit' at any time to stop the run with increasing levels of prejudice.

void Shell::doQuit (  ) 

Cleanly quits simulation, wrapping up all nodes and threads.

References logger, and SetGet0::set().

Referenced by launchParser(), main(), and testShellParserQuit().

Here is the call graph for this function:

void Shell::doReacDiffMesh ( Id  baseCompartment  ) 

This function builds a reac-diffusion mesh starting at the specified ChemCompt, which houses MeshEntry FieldElements. Assumes that the dimensions of the baseCompartment have just been redefined, and we now need to go through and update the child reaction system.

Id Shell::doReadSBML ( const string &  fname,
const string &  modelpath,
const string &  solverclass = "" 
)
void Shell::doReinit (  ) 

Reinitializes simulation: time goes to zero, all scheduled objects are set to initial conditions. If simulation is already running, first stops it.

References logger, and SetGet0::set().

Referenced by benchmarkMsg(), ReadKkit::run(), testCopyMsgOps(), testGetMsg(), testMMenzProcess(), testRunGsolve(), testRunKsolve(), testSetupReac(), and testStats().

Here is the call graph for this function:

string Shell::doRevision (  ) 

Returns SVN revision number of the software. This information is useful for developers. In release versions it defaults to "0".

References SVN_REVISION.

void Shell::doSaveModel ( Id  model,
const string &  fileName,
bool  qflag = 0 
) const

Saves specified model to specified file, using filetype identified by filename extension. Currently known filetypes are: .g: Kkit model

Still to come: .p: GENESIS neuron morphology and channel spec file .sbml: SBML file .nml: NeuroML file .9ml: NineML file .snml: SigNeurML

void Shell::doSetClock ( unsigned int  tickNum,
double  dt 
)
void Shell::doSetParserIdleFlag ( bool  isParserIdle  ) 

This function is called by the parser to tell the ProcessLoop to wait a bit between cycles. Used when we are waiting for user input and there is no point in having the ProcessLoop go at full speed. When flag is true, then the ProcessLoop will sleep a bit, when false it will work at full speed.

void Shell::doStart ( double  runtime  ) 

Starts off simulation, to run for 'runtime' more than current time. This version is blocking, and returns only when the simulation is done.

References logger.

Referenced by benchmarkMsg(), ReadKkit::run(), testCopyMsgOps(), testFibonacci(), testGetMsg(), testMMenzProcess(), testMpiFibonacci(), testRunGsolve(), testRunKsolve(), testSetupReac(), testShellAddMsg(), testShellParserStart(), and testStats().

void Shell::doStop (  ) 

Cleanly stops simulation, ready to take up again from where the stop occurred. Waits till current operations are done.

References SetGet0::set().

Here is the call graph for this function:

void Shell::doSyncDataHandler ( Id  tgt  ) 

This function synchronizes fieldDimension on the DataHandler across nodes. Used after function calls that might alter the number of Field entries in the table.. The tgt is the FieldElement whose fieldDimension needs updating.

void Shell::doTerminate (  ) 

Terminate ongoing simulation, with prejudice. Uncleanly stops simulation. Things may be in a mess with different objects at different times, but it stops at once.

void Shell::doUseClock ( string  path,
string  field,
unsigned int  tick 
)

Deprecated. Fallback Find function which treats index brackets as part of name string, and does not try to extract integer indices. ObjId doFindWithoutIndexing( const string& path ) const; Connects up process messages from the specified Tick to the targets on the path. Does so for whole Elements, not individual entries in the Element array. The target on the path usually has the 'process' field but other options are allowed, like 'init'

Referenced by benchmarkMsg(), main(), setMethod(), testCopyMsgOps(), testGetMsg(), testMMenzProcess(), testMpiFibonacci(), testRunGsolve(), testRunKsolve(), testShellAddMsg(), testShellParserStart(), and testStats().

string Shell::doVersion (  ) 

Returns version number of the software.

References MOOSE_VERSION.

int Shell::doWriteSBML ( const string &  fname,
const string &  modelpath 
)

Write given model to SBML file. Returns success value.

static void Shell::dropClockMsgs ( const vector< ObjId > &  list,
const string &  field 
) [static]

Utility function to unschedule the specified elist operating on the specified field, typically 'process'

void Shell::error ( const string &  text  ) 
void Shell::expectVector ( bool  flag  ) 

set the gettingVector_ flag

ObjId Shell::getCwe (  )  const

Returns the current working Element of the Shell

Referenced by initCinfo().

const ProcInfo* Shell::getProcInfo ( unsigned int  index  )  const
void Shell::handleAck ( unsigned int  ackNode,
unsigned int  status 
)

Generic handler for ack msgs from various nodes. Keeps track of which nodes have responded.

void Shell::handleAddMsg ( const Eref e,
string  msgType,
ObjId  src,
string  srcField,
ObjId  dest,
string  destField,
unsigned int  msgIndex 
)

Connects src to dest on appropriate fields, with specified msgType. This wrapper function sends the ack back to the master node.

Referenced by initCinfo().

void Shell::handleCopy ( const Eref e,
vector< ObjId args,
string  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Deep copy of source element to target, renaming it to newName. The Args are orig, newParent, newElm where the newElm is the Id passed in for the root of the copy. All subsequent created Elements should have successive Ids. The copy may generate an array with n entries. Normally only copies msgs within the tree, but if the flag copyExtMsgs is true then it copies external Msgs too.

Referenced by initCinfo().

void Shell::handleCreate ( const Eref e,
string  type,
ObjId  parent,
Id  newElm,
string  name,
NodeBalance  nb,
unsigned int  parentMsgIndex 
)

Referenced by initCinfo().

void Shell::handleMove ( const Eref e,
Id  orig,
ObjId  newParent 
)

Handler to move Element orig onto the newParent.

References innerMove().

Referenced by initCinfo().

Here is the call graph for this function:

void Shell::handleQuit (  ) 

Wraps up operations. Doesn't quit instantly, completes the current process cycle first.

Referenced by initCinfo().

void Shell::handleSync ( const Eref e,
Id  elm,
FuncId  fid 
)

Handles sync of DataHandler indexing across nodes

void Shell::handleUseClock ( const Eref e,
string  path,
string  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Referenced by initCinfo().

bool Shell::inBlockingParserCall (  )  [static]

True when the parser is in a call which is being blocked because it requires the event loop to complete some actions.

void Shell::initAck (  ) 

Initialize acks. This call should be done before the 'send' goes out, because with the wonders of threading we might get a response to the 'send' before this call is executed. This MUST be followed by a waitForAck call.

const Cinfo * Shell::initCinfo (  )  [static]
const Msg* Shell::innerAddMsg ( string  msgType,
ObjId  src,
string  srcField,
ObjId  dest,
string  destField,
unsigned int  msgIndex 
)

Connects src to dest on appropriate fields, with specified msgType. This inner function does NOT send an ack. Returns true on success

bool Shell::innerCopy ( const vector< ObjId > &  args,
const string &  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Does actual work of copying. Returns true on success.

void Shell::innerCreate ( string  type,
ObjId  parent,
Id  newElm,
string  name,
const NodeBalance nb,
unsigned int  parentMsgIndex 
)

Function that does the actual work of creating a new Element. The Class of the Moose objects formed is specified by type. The NodeBalance specifies how many entries and how they are distributed across nodes. The parentMsgIndex specifies the index for the parent-child message.

bool Shell::innerMove ( Id  orig,
ObjId  newParent 
)

Moves Element orig onto the newParent.

References Finfo::addMsg(), Msg::deleteMsg(), Id::element(), ObjId::element(), ObjId::eref(), Element::findCaller(), Cinfo::findFinfo(), DestFinfo::getFid(), Element::getName(), initCinfo(), and Msg::mid().

Referenced by handleMove().

Here is the call graph for this function:

bool Shell::innerUseClock ( string  path,
string  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Sets up scheduling for elements on the path.

bool Shell::isAckPending (  )  const

Test for receipt of acks from all nodes

static bool Shell::isNameValid ( const string &  name  )  [static]

Checks that the provided name is valid for an object. This returns false if it finds the reserved path chars /#[]

static bool Shell::isParserIdle (  )  [static]

Flag to indicate if the parser is idle. If so, the main ProcessLoop should also slow down to avoid pounding on the CPUs

bool Shell::isRunning (  )  const

Returns flag to indicate whether simulation is still running

References Eref::data(), Id::element(), and Id::eref().

Referenced by initCinfo().

Here is the call graph for this function:

static bool Shell::isSingleThreaded (  )  [static]

True in single-threaded mode. This is a special mode of the system in which it does not start up the event loop at all, and the whole thing operates on one thread, which is ultimately under the control of the parser. Note that this is distinct from running on one core. It is possible, and even recommended, to run in multithread mode even when the system has just one core to run it on.

bool Shell::keepLooping (  )  [static]

True as long as the main process loop is looping

Referenced by main().

void Shell::launchParser (  )  [static]

Launches Parser. Blocking when the parser blocks.

References Eref::data(), doQuit(), and Id::eref().

Referenced by main().

Here is the call graph for this function:

static void Shell::launchThreads (  )  [static]

This function sets up the threading for the entire system. It creates all the worker threads and the threads for handling MPI and handling shell requests.

void Shell::loadBalance (  )  [static]

Stub for eventual function to handle load balancing. This must be called to set up default groups.

Regular shell function that requires that the information about the hardware have been loaded in. For now the function just assigns SimGroups

Referenced by init().

unsigned int Shell::myNode (  )  [static]
unsigned int Shell::numCores (  )  [static]

Referenced by nonMpiTests().

unsigned int Shell::numNodes (  )  [static]
static unsigned int Shell::numProcessThreads (  )  [static]
static const ProcInfo* Shell::procInfo (  )  [static]

Static func for returning the ProcInfo of the shell.

static unsigned int Shell::reduceInt ( unsigned int  val  )  [static]

Checks for highest 'val' on all nodes

void Shell::setCwe ( ObjId  cwe  ) 

Assigns the current working Element of the Shell

Referenced by initCinfo(), and testTreeTraversal().

void Shell::setHardware ( unsigned int  numCores,
unsigned int  numNodes,
unsigned int  myNode 
) [static]

Assigns the hardware availability. Assumes that each node will have the same number of cores available.

Referenced by init(), and nonMpiTests().

void Shell::setShellElement ( Element shelle  ) 

Referenced by init().

void Shell::start ( double  runTime  ) 

Sets of a simulation for duration runTime. Handles cases including single-thread, multithread, and multinode

void Shell::waitForAck (  ) 

test for completion of request. This MUST be preceded by an initAck call.

void Shell::warning ( const string &  text  ) 

Referenced by doMove().


Member Data Documentation

const unsigned int Shell::ErrorStatus = ~1 [static]
const unsigned int Shell::OkStatus = ~0 [static]

The documentation for this class was generated from the following files:

Generated on 1 Jul 2015 for MOOSE by  doxygen 1.6.1