comparison src/parallel_execution/generate_context.pl @ 406:9b35e6581b5c

Use task member of context by par goto meta Use task member of context for par goto meta ate_stub.pl
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Wed, 06 Sep 2017 15:11:27 +0900
parents fc4fcd441700
children 85b0ddbf458e
comparison
equal deleted inserted replaced
405:8915fce522b3 406:9b35e6581b5c
162 162
163 open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!"); 163 open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!");
164 print $fd $context_c; 164 print $fd $context_c;
165 165
166 my $meta_call = <<"EOFEOF"; 166 my $meta_call = <<"EOFEOF";
167 __code par_meta(struct Context* context, enum Code spawns, enum Code next) {
168 Gearef(context, Queue)->queue = (union Data*)context->tasks;
169 Gearef(context, Queue)->whenEmpty = next;
170 Gearef(context, Queue)->next = spawns;
171 goto (context->code[context->tasks->isEmpty])(context);
172 }
173
174 __code meta(struct Context* context, enum Code next) { 167 __code meta(struct Context* context, enum Code next) {
175 // printf("meta %d\\n",next); 168 // printf("meta %d\\n",next);
176 goto (context->code[next])(context); 169 if (context->task == NULL) {
170 goto (context->code[next])(context);
171 }
172 context->task = NULL;
173 goto (context->code[Gearef(context, TaskManager)->taskManager->TaskManager.spawnTasks])(context);
177 } 174 }
178 175
179 __code start_code(struct Context* context) { 176 __code start_code(struct Context* context) {
180 goto meta(context, context->next); 177 goto meta(context, context->next);
181 } 178 }
196 } 193 }
197 194
198 // end context_c 195 // end context_c
199 EOFEOF 196 EOFEOF
200 197
201 print $fd $meta_call; 198 print $fd $meta_call;
202 199
203 open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!"); 200 open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!");
204 print $fd "enum DataType {\n"; 201 print $fd "enum DataType {\n";
205 print $fd " D_Code,\n"; 202 print $fd " D_Code,\n";
206 for my $data ( sort keys %dataGear ) { 203 for my $data ( sort keys %dataGear ) {
207 print $fd " D_${data},\n"; 204 print $fd " D_${data},\n";
208 } 205 }
209 print $fd "};\n\n"; 206 print $fd "};\n\n";
210 207
211 open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!"); 208 open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!");
212 for my $data ( sort keys %dataGear ) { 209 for my $data ( sort keys %dataGear ) {
213 print $fd "typedef struct ${data} ${data};\n"; 210 print $fd "typedef struct ${data} ${data};\n";
214 } 211 }
215 212
216 open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!"); 213 open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!");
217 for my $data ( sort keys %dataGear ) { 214 for my $data ( sort keys %dataGear ) {
218 print $fd " ALLOC_DATA(context, ${data});\n"; 215 print $fd " ALLOC_DATA(context, ${data});\n";
219 } 216 }
220 } 217 }
221 218
222 # end 219 # end