Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 
24 #include "rocman.h"
25 
26 class ActionA: public Action {
27 public:
28  ActionA(int n, char *at[], int i[], void *p=0, char *name=NULL):
29  Action(n, at, i, p, name) {}
30  virtual void declare(Scheduler& sched) {
31  sched.writes(this, "b", 1);
32  sched.writes(this, "c", 1);
33  }
34 };
35 
36 class ActionB: public Action {
37 public:
38  ActionB(int n, char *at[], int i[], void *p=0, char *name=NULL): Action(n, at, i, p, name) {}
39  virtual void declare(Scheduler& sched) {
40  sched.reads(this, "b", 1);
41  sched.writes(this, "d", 1);
42  }
43 };
44 
45 class ActionC: public Action {
46 public:
47  ActionC(int n, char *at[], int i[], void *p=0, char *name=NULL): Action(n, at, i, p, name) {}
48  virtual void declare(Scheduler& sched) {
49  sched.reads(this, "c", 1);
50  sched.writes(this, "c", 1);
51  sched.writes(this, "e", 1);
52  }
53 };
54 
55 class ActionD: public Action {
56 public:
57  ActionD(int n, char *at[], int i[], void *p=0, char *name=NULL): Action(n, at, i, p, name) {}
58  virtual void declare(Scheduler& sched) {
59  sched.reads(this, "d", 1);
60  sched.reads(this, "c", 1);
61  }
62 };
63 
64 class ActionE: public SchedulerAction
65 {
66 public:
67  ActionE(Scheduler *s, int n, char *at[], int i[], void *p=0, char *name=NULL): SchedulerAction(s, n, at, i, p, name) {}
68  virtual void declare(Scheduler& sched) {
69  sched.reads(this, "e", 1);
70  }
71 };
72 
73 class ActionF: public Action {
74 public:
75  ActionF(int n, char *at[], int i[], void *p=0, char *name=NULL): Action(n, at, i, p, name) {}
76  virtual void declare(Scheduler& sched) {
77  sched.writes(this, "f", 1);
78  }
79 };
80 
81 class ActionG: public Action {
82 public:
83  ActionG(int n, char *at[], int i[], void *p=0, char *name=NULL): Action(n, at, i, p, name) {}
84  virtual void declare(Scheduler& sched) {
85  sched.reads(this, "f", 1);
86  }
87 };
88 
89 int main()
90 {
91  Scheduler * sched = new Scheduler;
92 
93  // root action
94  ActionA *a = new ActionA(0, NULL, NULL, NULL, "A");
95  sched->add_action(*a);
96  a->declare(*sched);
97 
98  char *attr_c[] = { "c" };
99  int idx_c[] = { 1 };
100  ActionC *c = new ActionC(1, attr_c, idx_c, NULL, "C");
101  sched->add_action(*c);
102  c->declare(*sched);
103 
104  char *attr_d[] = { "d", "c" };
105  int idx_d[] = { 1, 1 };
106  ActionD *d = new ActionD(2, attr_d, idx_d, NULL, "D");
107  sched->add_action(*d);
108  d->declare(*sched);
109 
110  char *attr_b[] = { "b" };
111  int idx_b[] = { 1 };
112  ActionB *b = new ActionB(1, attr_b, idx_b, NULL, "B");
113  sched->add_action(*b);
114  b->declare(*sched);
115 
116  // action E is a container action that has its own sub-schduler
117  // the sub scheduler contains action F and G
118  Scheduler * subsched = new Scheduler;
119 
120  ActionF *f = new ActionF(0, NULL, NULL, NULL, "F");
121  subsched->add_action(*f);
122  f->declare(*subsched);
123 
124  char *attr_g[] = { "f" };
125  int idx_g[] = { 1 };
126  ActionG *g = new ActionG(1, attr_g, idx_g, NULL, "G");
127  subsched->add_action(*g);
128  g->declare(*subsched);
129 
130  char *attr_e[] = { "f" };
131  int idx_e[] = { 1 };
132  ActionE *e = new ActionE(subsched, 1, attr_e, idx_e, NULL, "E");
133  sched->add_action(*e);
134  e->declare(*sched);
135 
136  // all creation done now
137  sched->schedule();
138 
139  // generate GDL file for visualization with iaSee tool
140  sched->print("out.gdl");
141 
142  sched->init_actions(1);
143 
144  sched->run_actions(1, 0.1);
145 
146  sched->finalize_actions();
147 }
148 
149 
150 
151 
152 
153 
154 
155 
virtual void declare(Scheduler &sched)
Definition: test.C:39
virtual void declare(Scheduler &sched)
Definition: test.C:68
virtual char * name()
Definition: Action.h:53
Definition: test.C:73
const NT & d
double s
Definition: blastest.C:80
virtual void declare(Scheduler &sched)
Definition: test.C:48
ActionB(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:38
Definition: test.C:45
virtual void schedule()
Definition: Scheduler.C:162
Definition: Action.h:32
void writes(Action *, const char *attr, int idx)
Definition: Scheduler.C:64
virtual void declare(Scheduler &sched)
Definition: test.C:30
void print(const char *fname)
Definition: Scheduler.C:244
Definition: test.C:81
void reads(Action *, const char *attr, int idx)
Definition: Scheduler.C:49
Definition: test.C:55
blockLoc i
Definition: read.cpp:79
ActionD(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:57
ActionF(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:75
const NT & n
ActionE(Scheduler *s, int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:67
void finalize_actions()
Definition: Scheduler.C:351
ActionA(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:28
virtual void declare(Scheduler &sched)
Definition: test.C:76
int main(int argc, char *argv[])
Definition: blastest.C:94
Definition: test.C:26
virtual void declare(Scheduler &sched)
Definition: test.C:58
Scheduler * sched
Definition: Action.h:81
Definition: test.C:64
virtual void declare(Scheduler &sched)
Definition: test.C:84
virtual void add_action(Action *)
Definition: Scheduler.C:41
void init_actions(double t)
Definition: Scheduler.C:324
void run_actions(double t, double dt)
Definition: Scheduler.C:339
ActionG(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:83
Definition: test.C:36
ActionC(int n, char *at[], int i[], void *p=0, char *name=NULL)
Definition: test.C:47