00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _SHELL_H
00011 #define _SHELL_H
00012
00013 #include "../basecode/global.h"
00014
00015 enum AssignmentType { SINGLE, VECTOR, REPEAT };
00016
00017
00018
00019
00020 extern DestFinfo* receiveGet();
00021
00022
00023 enum NodePolicy { MooseGlobal, MooseBlockBalance, MooseSingleNode };
00024 class NodeBalance {
00025 public:
00026 NodeBalance( unsigned int nd, NodePolicy np, unsigned int node )
00027 : numData( nd ), policy( np ), preferredNode( node )
00028 {;}
00029
00030 unsigned int numData;
00031 NodePolicy policy;
00032 unsigned int preferredNode;
00033 };
00034
00035 class Shell
00036 {
00037 public:
00038 Shell();
00039 ~Shell();
00040
00041 #ifdef CYMOOSE
00042
00052 Shell* initShell();
00053
00054
00070 Id create( string type, string name, unsigned int numData,
00071 NodePolicy nodePolicy = MooseBlockBalance,
00072 unsigned int preferredNode = 1 );
00073
00074
00075 #endif
00077 // Field functions
00079
00082 string doVersion();
00083
00088 string doRevision();
00092 void setCwe( ObjId cwe );
00093
00097 ObjId getCwe() const;
00098
00102 bool isRunning() const;
00103
00105
00107
00115 Id doCreate( string type, ObjId parent, string name,
00116 unsigned int numData,
00117 NodePolicy nodePolicy = MooseBlockBalance,
00118 unsigned int preferredNode = 1 );
00119
00127 bool doDelete( ObjId oid );
00128
00135 ObjId doAddMsg( const string& msgType,
00136 ObjId src, const string& srcField,
00137 ObjId dest, const string& destField );
00138
00142 void doQuit( );
00143
00149 void doStart( double runtime );
00150
00160 void doNonBlockingStart( double runtime );
00161
00167 void doReinit();
00168
00173 void doStop();
00174
00180 void doTerminate();
00181
00186 void doMove( Id orig, ObjId newParent );
00187
00194 Id doCopy( Id orig, ObjId newParent, string newName,
00195 unsigned int n, bool toGlobal, bool copyExtMsgs );
00196
00202 ObjId doFind( const string& path ) const;
00203
00218 void doUseClock( string path, string field, unsigned int tick );
00219
00227 Id doLoadModel( const string& fname, const string& modelpath,
00228 const string& solverClass = "" );
00229
00242 void doSaveModel( Id model, const string& fileName,
00243 bool qflag = 0 ) const;
00244
00248 int doWriteSBML( const string& fname, const string& modelpath );
00249 Id doReadSBML( const string& fname, const string& modelpath, const string& solverclass=""
00250 );
00251
00258 void doSyncDataHandler( Id tgt );
00259
00267 void doReacDiffMesh( Id baseCompartment );
00268
00276 void doSetParserIdleFlag( bool isParserIdle );
00277
00284 static void clearRestructuringQ();
00286
00288
00293 void start( double runTime );
00294
00301 void initAck();
00302
00307 void waitForAck();
00308
00313 void handleAck( unsigned int ackNode, unsigned int status );
00314
00318 bool isAckPending() const;
00319
00324 void handleQuit();
00325
00326 void handleCreate( const Eref& e,
00327 string type, ObjId parent, Id newElm, string name,
00328 NodeBalance nb, unsigned int parentMsgIndex );
00329 void destroy( const Eref& e, ObjId oid);
00330
00339 void innerCreate( string type, ObjId parent, Id newElm, string name,
00340 const NodeBalance& nb, unsigned int parentMsgIndex );
00341
00343 bool innerCopy( const vector< ObjId >& args, const string& newName,
00344 unsigned int n, bool toGlobal, bool copyExtMsgs );
00345
00352 const Msg* innerAddMsg( string msgType, ObjId src, string srcField,
00353 ObjId dest, string destField, unsigned int msgIndex );
00354
00360 void handleAddMsg( const Eref& e,
00361 string msgType,
00362 ObjId src, string srcField,
00363 ObjId dest, string destField,
00364 unsigned int msgIndex );
00365
00369 bool innerMove( Id orig, ObjId newParent );
00370
00374 void handleMove( const Eref& e,
00375 Id orig, ObjId newParent );
00376
00380 void handleSync( const Eref& e, Id elm, FuncId fid);
00381
00391 void handleCopy( const Eref& e,
00392 vector< ObjId > args, string newName, unsigned int n,
00393 bool toGlobal, bool copyExtMsgs );
00394
00398 bool innerUseClock( string path, string field,
00399 unsigned int tick, unsigned int msgIndex);
00400 void handleUseClock( const Eref& e,
00401 string path, string field, unsigned int tick,
00402 unsigned int msgIndex );
00403
00408 void addClockMsgs( const vector< ObjId >& list,
00409 const string& field, unsigned int tick, unsigned int msgIndex );
00410
00415 static void dropClockMsgs(
00416 const vector< ObjId >& list, const string& field );
00418
00420
00425 static void setHardware(
00426 unsigned int numCores, unsigned int numNodes,
00427 unsigned int myNode );
00428
00429 static unsigned int myNode();
00430 static unsigned int numNodes();
00431 static unsigned int numCores();
00432 static unsigned int numProcessThreads();
00433
00438 static void loadBalance();
00439
00440 static void launchParser();
00441
00446 static bool inBlockingParserCall();
00447
00457 static bool isSingleThreaded();
00458
00462 static bool keepLooping();
00463
00468 static bool isParserIdle();
00469
00475 static void launchThreads();
00476
00480 static unsigned int reduceInt( unsigned int val );
00481
00483
00484
00485
00486 void doSetClock( unsigned int tickNum, double dt );
00487
00488
00489
00490 void warning( const string& text );
00491 void error( const string& text );
00492
00493 static const Cinfo* initCinfo();
00494
00496
00498 static bool adopt( ObjId parent, Id child, unsigned int msgIndex );
00499 static bool adopt( Id parent, Id child, unsigned int msgIndex );
00500
00501 static const unsigned int OkStatus;
00502 static const unsigned int ErrorStatus;
00503
00504
00505 void setShellElement( Element* shelle );
00506
00508 static const ProcInfo* procInfo();
00509
00510 const ProcInfo* getProcInfo( unsigned int index ) const;
00511
00518 static bool chopString( const string& path, vector< string >& ret,
00519 char separator = '/' );
00520
00525 static bool isNameValid( const string& name );
00526
00541 static bool chopPath( const string& path, vector< string >& ret,
00542 vector< unsigned int >& index );
00543
00544
00545
00552 static void cleanSimulation();
00553
00557 void expectVector( bool flag );
00558
00559 private:
00560 Element* shelle_;
00561
00567 vector< double* > getBuf_;
00568
00573 bool gettingVector_;
00574
00579 unsigned int numGetVecReturns_;
00580
00586 static bool isBlockedOnParser_;
00587
00592 static bool keepLooping_;
00593
00597 static unsigned int numCores_;
00598
00604 static unsigned int numProcessThreads_;
00605
00610 static unsigned int numNodes_;
00611
00615 static unsigned int myNode_;
00616
00622 static ProcInfo p_;
00623
00624 static vector< ProcInfo > threadProcs_;
00625
00630 static unsigned int numAcks_;
00631 static vector< unsigned int > acked_;
00632
00633
00638 static bool doReinit_;
00639
00643 static double runtime_;
00644
00645 static bool isParserIdle_;
00646
00648 ObjId cwe_;
00649 };
00650
00651
00652
00653
00654
00655
00656
00657 #endif // _SHELL_H