comparison bin/cerium @ 297:54725883131b draft

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