297
|
1 #!/usr/bin/perl -w
|
|
2
|
|
3 use strict;
|
|
4
|
329
|
5 use XML::LibXML;
|
|
6
|
297
|
7 my $command = shift;
|
|
8 my $main = "main.cc";
|
|
9 my $task_config = "tasks.xml";
|
330
|
10 my $cerium_path = "/Users/e065746/Works/lab/hg/Cerium";
|
297
|
11
|
|
12 if ($command =~ /init/) {
|
|
13 &init;
|
|
14 } elsif ($command =~ /make/) {
|
|
15 &make;
|
|
16 } elsif ($command =~ /help/) {
|
|
17 &help;
|
|
18 } else {
|
|
19 &help;
|
|
20 }
|
|
21 exit 0;
|
|
22
|
|
23 sub help {
|
|
24 print "$0 init ... initialize cerium application\n";
|
|
25 }
|
|
26
|
|
27 sub init {
|
|
28 # setup initial cerium configuration
|
|
29 mkdir "Task";
|
330
|
30 if (! -e $main ) { &make_main; }
|
|
31 if (! -e $task_config ) { &make_task_config; }
|
297
|
32 }
|
|
33
|
|
34 sub make_main {
|
|
35 open(F,">$main") or die("Can't write $main\n");
|
330
|
36 print F <<'EOFEOF';
|
297
|
37 #include <stdio.h>
|
|
38 #include <stdlib.h>
|
|
39 #include <string.h>
|
|
40 #include "TaskManager.h"
|
|
41 #include "Func.h"
|
|
42
|
|
43 extern void task_init(void);
|
|
44
|
|
45 const char *usr_help_str = "Usage: ./main [-cpu spe_num] [-count N]\n\
|
330
|
46 -cpu Number of SPE (default 1) \n\"";
|
297
|
47
|
|
48 int
|
|
49 init(int argc, char **argv)
|
|
50 {
|
|
51 for (int i = 1; argv[i]; ++i) {
|
|
52 if (strcmp(argv[i], "-count") == 0) {
|
|
53 count = atoi(argv[++i]);
|
|
54 }
|
|
55
|
|
56 }
|
|
57
|
|
58 return 0;
|
|
59 }
|
|
60
|
|
61 void
|
|
62 hello_init(void)
|
|
63 {
|
|
64 HTask *hello;
|
|
65
|
|
66 for (int i = 0; i < count; i++) {
|
|
67 /**
|
|
68 * Create Task
|
|
69 * create_task(Task ID);
|
|
70 */
|
|
71 hello = manager->create_task(HELLO_TASK);
|
|
72
|
|
73 /**
|
|
74 * Select CPU
|
|
75 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
|
|
76 * if you do not call this, execute PPE.
|
|
77 */
|
|
78 hello->set_cpu(SPE_ANY);
|
|
79
|
|
80 /**
|
|
81 * Set 32bits parameter
|
|
82 * add_param(32bit parameter);
|
|
83 */
|
|
84 hello->add_param(i);
|
|
85
|
|
86 hello->spawn();
|
|
87 }
|
|
88 }
|
|
89
|
|
90 int
|
|
91 TMmain(int argc, char *argv[])
|
|
92 {
|
|
93 if (init(argc, argv) < 0) {
|
|
94 return -1;
|
|
95 }
|
|
96 task_init();
|
|
97 init();
|
|
98
|
|
99 return 0;
|
|
100 }
|
|
101 EOFEOF
|
|
102 }
|
|
103 } else {
|
|
104 &help;
|
|
105 }
|
|
106 exit 0;
|
|
107
|
|
108 sub help {
|
|
109 print "$0 init ... initialize cerium application\n";
|
|
110 }
|
|
111
|
|
112 sub init {
|
|
113 # setup initial cerium configuration
|
|
114 mkdir "Task";
|
|
115 if (! -e $main ) &make_main;
|
|
116 if (! -e $task_config ) &make_task_config;
|
|
117 }
|
|
118
|
|
119 sub make_main {
|
|
120 open(F,">$main") or die("Can't write $main\n");
|
330
|
121 print F <<'EOFEOF';
|
297
|
122 #include <stdio.h>
|
|
123 #include <stdlib.h>
|
|
124 #include <string.h>
|
|
125 #include "TaskManager.h"
|
|
126 #include "Func.h"
|
|
127
|
|
128 extern void task_init(void);
|
|
129
|
|
130 const char *usr_help_str = "Usage: ./main [-cpu spe_num] [-count N]\n\
|
|
131 -cpu Number of SPE (default 1) \n\";
|
|
132
|
|
133 int
|
|
134 init(int argc, char **argv)
|
|
135 {
|
|
136 for (int i = 1; argv[i]; ++i) {
|
|
137 if (strcmp(argv[i], "-count") == 0) {
|
|
138 count = atoi(argv[++i]);
|
|
139 }
|
|
140
|
|
141 }
|
|
142
|
|
143 return 0;
|
|
144 }
|
|
145
|
|
146 void
|
|
147 hello_init(void)
|
|
148 {
|
|
149 HTask *hello;
|
|
150
|
|
151 for (int i = 0; i < count; i++) {
|
|
152 /**
|
|
153 * Create Task
|
|
154 * create_task(Task ID);
|
|
155 */
|
|
156 hello = manager->create_task(HELLO_TASK);
|
|
157
|
|
158 /**
|
|
159 * Select CPU
|
|
160 * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
|
|
161 * if you do not call this, execute PPE.
|
|
162 */
|
|
163 hello->set_cpu(SPE_ANY);
|
|
164
|
|
165 /**
|
|
166 * Set 32bits parameter
|
|
167 * add_param(32bit parameter);
|
|
168 */
|
|
169 hello->add_param(i);
|
|
170
|
|
171 hello->spawn();
|
|
172 }
|
|
173 }
|
|
174
|
|
175 int
|
|
176 TMmain(int argc, char *argv[])
|
|
177 {
|
|
178 if (init(argc, argv) < 0) {
|
|
179 return -1;
|
|
180 }
|
|
181 task_init();
|
|
182 init();
|
|
183
|
|
184 return 0;
|
|
185 }
|
|
186 EOFEOF
|
|
187 }
|
|
188
|
|
189 sub make {
|
329
|
190
|
|
191 return if ( ! -e $task_config );
|
330
|
192
|
329
|
193 my $xml = XML::LibXML->new();
|
330
|
194 my $doc = $parser->parse_file("$cerium_path/lib/tasks.xml");
|
|
195 my $root = $doc->documentElement();
|
|
196 for my $e ($root->childNodes) {
|
|
197 print $e->nodeName, "\n";
|
|
198 }
|
297
|
199 }
|
|
200
|
|
201 __END__
|
|
202
|
|
203 =head1 NAME
|
|
204
|
|
205 cerium -- Cerium task manager configuration manager
|
|
206
|
|
207 =head1 SYNOPSIS
|
|
208
|
|
209 cerium init
|
|
210 cerium make
|
|
211 cerium help
|
|
212
|
|
213 =head1 DESCRIPTION
|
|
214
|
|
215 cerium init
|
|
216
|
|
217 =cut
|
|
218
|