annotate src/parallel_execution/dependency.c @ 169:ea7b11f3e717

Using Queue Interface
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 22 Nov 2016 09:48:37 +0900
parents 473b7d990a1f
children 747067fe46bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
1 #include <stdio.h>
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "context.h"
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "origin_cs.h"
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 __code meta_waitFor(struct Context* context, struct Queue* queue, enum Code next) {
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 114
diff changeset
6 context->data[D_Queue] = (union Data *)queue;
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 goto (context->code[next])(context);
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 __code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) {
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
11 element->data = (union Data *)slave;
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 // enqueue waitMe
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
13 goto meta_waitFor(context, master->waitMe, PutQueue1);
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 __code waitFor1_stub(struct Context* context) {
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 // next think
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
20 //__code waitFor2(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) {
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
21 // element->task = master;
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
22 // task->next = context->next;
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
23 // // enqueue waitI
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
24 // goto meta_waitFor(context, task->waitI, PutQueue1);
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
25 //}
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
26 //
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
27 //__code waitFor2_stub(struct Context* context) {
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
28 // // next think
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
29 //}
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
31 __code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) {
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 114
diff changeset
32 context->data[D_Queue] = (union Data *)queue;
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
33 goto meta(context, context->next);
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
36 __code spawnTask(struct Context* context, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) {
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
37 struct Queue *queue;
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
38 if (task->idsCount == 0) {
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 // enqueue activeQueue
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
40 queue = activeQueue;
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
41 } else {
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 // enqueue waitQueue
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
43 queue = waitQueue;
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
45 queue->data = element->data;
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
46 queue->next = context->next;
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 148
diff changeset
47 goto meta_spawnTask(context, queue, queue->put);
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 __code spawnTask_stub(struct Context* context) {
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
51 goto spawnTask(context,
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 114
diff changeset
52 &context->data[D_Element]->element,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 114
diff changeset
53 &context->data[D_ActiveQueue]->queue,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 114
diff changeset
54 &context->data[D_WaitQueue]->queue);
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
57 __code taskA(struct Context* context) {
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 printf("TaskA\n");
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 goto meta(context, context->next);
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
62 __code taskB(struct Context* context) {
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 printf("TaskB\n");
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 goto meta(context, context->next);
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
67 __code taskC(struct Context* context) {
111
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 printf("TaskC\n");
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 goto meta(context, context->next);
556e203de999 Add dependency.c
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }