comparison bin/cerium @ 331:4f2423ed1c86 draft

cerium script fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 12 Jun 2009 16:05:03 +0900
parents 786d0bc9766a
children 5950b6ff7fec
comparison
equal deleted inserted replaced
330:786d0bc9766a 331:4f2423ed1c86
98 98
99 return 0; 99 return 0;
100 } 100 }
101 EOFEOF 101 EOFEOF
102 } 102 }
103 } else {
104 &help;
105 }
106 exit 0;
107 103
108 sub help {
109 print "$0 init ... initialize cerium application\n";
110 }
111 104
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");
121 print F <<'EOFEOF';
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 105
189 sub make { 106 sub make {
190 107
191 return if ( ! -e $task_config ); 108 return if ( ! -e $task_config );
192 109
193 my $xml = XML::LibXML->new(); 110 my $parser = XML::LibXML->new();
194 my $doc = $parser->parse_file("$cerium_path/lib/tasks.xml"); 111 my $doc = $parser->parse_file("$cerium_path/lib/tasks.xml");
195 my $root = $doc->documentElement(); 112 my $root = $doc->documentElement();
196 for my $e ($root->childNodes) { 113 for my $e ($root->childNodes) {
197 print $e->nodeName, "\n"; 114 print $e->nodeName, "\n";
198 } 115 }
199 } 116 }
117
200 118
201 __END__ 119 __END__
202 120
203 =head1 NAME 121 =head1 NAME
204 122