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