MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
testScheduling.cpp File Reference
#include "header.h"
#include "testScheduling.h"
#include "Clock.h"
#include "SparseMatrix.h"
#include "SparseMsg.h"
#include "SingleMsg.h"
#include "../builtins/Arith.h"
#include "../shell/Shell.h"
+ Include dependency graph for testScheduling.cpp:

Go to the source code of this file.

Functions

void testClock ()
 
void testClockMessaging ()
 
void testMpiScheduling ()
 
void testScheduling ()
 
void testSchedulingProcess ()
 

Variables

static DestFinfo processFinfo ("process","handles process call", new EpFunc1< TestSched, ProcPtr >(&TestSched::process))
 
static const CinfotestSchedCinfo = TestSched::initCinfo()
 

Function Documentation

void testClock ( )

Check that clock scheduling works.

Definition at line 80 of file testScheduling.cpp.

References Clock::activeTicks_, Clock::buildTicks(), Eref::data(), Shell::doAddMsg(), doubleEq(), Id::eref(), Clock::getCurrentTime(), Clock::handleReinit(), Clock::handleStart(), Id::nextId(), Clock::numTicks, Field< A >::set(), LookupField< L, A >::set(), and Clock::ticks_.

Referenced by testScheduling().

81 {
82  const double runtime = 20.0;
83  Id clock(1);
84 
85  bool ret = Field< double >::set( clock, "baseDt", 1.0);
86  assert( ret );
87  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 0, 2.0);
88  assert( ret );
89  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 3, 1.0);
90  assert( ret );
91  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 1, 2.0);
92  assert( ret );
93  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 2, 5.0);
94  assert( ret );
95  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 4, 3.0);
96  assert( ret );
97  ret = LookupField< unsigned int, double >::set( clock, "tickDt", 7, 5.0);
98  assert( ret );
99 
100  /*
101  Id tabid = Id::nextId();
102  Element* tse = new Element( tsid, testSchedCinfo, "tse", 1 );
103 
104  Eref ts( tse, 0 );
105 
106  FuncId f( processFinfo.getFid() );
107  const Finfo* proc0 = clock.element()->cinfo()->findFinfo( "process0" );
108  assert( proc0 );
109  const SrcFinfo* sproc0 = dynamic_cast< const SrcFinfo* >( proc0 );
110  assert( sproc0 );
111  unsigned int b0 = sproc0->getBindIndex();
112  SingleMsg *m0 = new SingleMsg( er0.eref(), ts );
113  er0.element()->addMsgAndFunc( m0->mid(), f, er0.dataId.value()*2 + b0);
114  SingleMsg *m1 = new SingleMsg( er1.eref(), ts );
115  er1.element()->addMsgAndFunc( m1->mid(), f, er1.dataId.value()*2 + b0);
116  SingleMsg *m2 = new SingleMsg( er2.eref(), ts );
117  er2.element()->addMsgAndFunc( m2->mid(), f, er2.dataId.value()*2 + b0);
118  SingleMsg *m3 = new SingleMsg( er3.eref(), ts );
119  er3.element()->addMsgAndFunc( m3->mid(), f, er3.dataId.value()*2 + b0);
120  SingleMsg *m4 = new SingleMsg( er4.eref(), ts );
121  er4.element()->addMsgAndFunc( m4->mid(), f, er4.dataId.value()*2 + b0);
122  SingleMsg *m5 = new SingleMsg( er5.eref(), ts );
123  er5.element()->addMsgAndFunc( m5->mid(), f, er5.dataId.value()*2 + b0);
124 
125 
126 
127  assert( cdata->tickPtr_[0].mgr()->ticks_[0] == reinterpret_cast< const Tick* >( er3.data() ) );
128  assert( cdata->tickPtr_[1].mgr()->ticks_[0] == reinterpret_cast< const Tick* >( er2.data() ) );
129  assert( cdata->tickPtr_[1].mgr()->ticks_[1] == reinterpret_cast< const Tick* >( er1.data() ) );
130  assert( cdata->tickPtr_[2].mgr()->ticks_[0] == reinterpret_cast< const Tick* >( er4.data() ) );
131  assert( cdata->tickPtr_[3].mgr()->ticks_[0] == reinterpret_cast< const Tick* >( er0.data() ) );
132  assert( cdata->tickPtr_[3].mgr()->ticks_[1] == reinterpret_cast< const Tick* >( er5.data() ) );
133  */
134 
135  Eref clocker = clock.eref();
136  Clock* cdata = reinterpret_cast< Clock* >( clocker.data() );
137  assert ( cdata->ticks_.size() == Clock::numTicks );
138  cdata->buildTicks( clocker );
139  assert( cdata->activeTicks_.size() == 0 ); // No messages
140 
141  // Now put in the scheduling tester and messages.
142  Id test = Id::nextId();
143  Element* teste = new GlobalDataElement( test, testSchedCinfo, "test", 1 );
144  assert( teste );
145  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
146 
147  shell->doAddMsg( "oneToAll", clock, "process0", test, "process" );
148  shell->doAddMsg( "oneToAll", clock, "process1", test, "process" );
149  shell->doAddMsg( "oneToAll", clock, "process2", test, "process" );
150  shell->doAddMsg( "oneToAll", clock, "process3", test, "process" );
151  shell->doAddMsg( "oneToAll", clock, "process4", test, "process" );
152  shell->doAddMsg( "oneToAll", clock, "process7", test, "process" );
153  // clock.element()->digestMessages();
154  cdata->handleReinit( clocker );
155  assert( cdata->activeTicks_.size() == 6 ); // No messages
156  assert( cdata->activeTicks_[0] == 2 );
157  assert( cdata->activeTicks_[1] == 2 );
158  assert( cdata->activeTicks_[2] == 5 );
159  assert( cdata->activeTicks_[3] == 1 );
160  assert( cdata->activeTicks_[4] == 3 );
161  assert( cdata->activeTicks_[5] == 5 );
162  cdata->handleStart( clocker, runtime, false );
163  assert( doubleEq( cdata->getCurrentTime(), runtime ) );
164  test.destroy();
165  for ( unsigned int i = 0; i < Clock::numTicks; ++i )
166  cdata->ticks_[i] = 0;
167  cdata->buildTicks( clocker );
168  cout << "." << flush;
169 }
char * data() const
Definition: Eref.cpp:41
static bool set(const ObjId &dest, const string &field, L index, A arg)
Definition: SetGet.h:467
static const unsigned int numTicks
Definition: Clock.h:121
void handleReinit(const Eref &e)
dest function for message to trigger reinit.
Definition: Clock.cpp:808
Definition: Clock.h:25
double getCurrentTime() const
Definition: Clock.cpp:512
Eref eref() const
Definition: Id.cpp:125
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:245
void handleStart(const Eref &e, double runtime, bool notify)
dest function for message to run simulation for specified time
Definition: Clock.cpp:699
vector< unsigned int > activeTicks_
Definition: Clock.h:158
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
static Id nextId()
Definition: Id.cpp:132
static const Cinfo * testSchedCinfo
void buildTicks(const Eref &e)
Definition: Clock.cpp:675
vector< unsigned int > ticks_
Definition: Clock.h:152
Definition: Eref.h:26
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
Definition: Shell.cpp:269
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testClockMessaging ( )

Definition at line 171 of file testScheduling.cpp.

References Eref::data(), Shell::doCreate(), Shell::doDelete(), and Id::eref().

Referenced by testScheduling().

172 {
173  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
174  // Clock* cdata = reinterpret_cast< Clock* >( Id(1).eref().data() );
175  Id syns = shell->doCreate( "SimpleSynHandler", Id(), "syns0", 10 );
176  Id fire = shell->doCreate( "IntFire", Id(), "fire0", 10 );
177 
178  shell->doDelete( syns );
179  shell->doDelete( fire );
180  cout << "." << flush;
181 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testMpiScheduling ( )

Definition at line 193 of file testScheduling.cpp.

Referenced by mpiTests().

194 {
195 }

+ Here is the caller graph for this function:

void testScheduling ( )

Definition at line 183 of file testScheduling.cpp.

References testClock(), and testClockMessaging().

Referenced by nonMpiTests().

184 {
186  testClock();
187 }
void testClockMessaging()
void testClock()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void testSchedulingProcess ( )

Definition at line 189 of file testScheduling.cpp.

Referenced by processTests().

190 {
191 }

+ Here is the caller graph for this function:

Variable Documentation

DestFinfo processFinfo("process","handles process call", new EpFunc1< TestSched, ProcPtr >(&TestSched::process))
static
const Cinfo* testSchedCinfo = TestSched::initCinfo()
static

Definition at line 52 of file testScheduling.cpp.

Referenced by TestSched::initCinfo().