Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/context.c @ 130:2bb5e4f0fd35
Stackinterface
author | ikkun |
---|---|
date | Mon, 10 Oct 2016 20:19:26 +0900 |
parents | 36ac17d37be4 |
children | a4507906938c |
rev | line source |
---|---|
86 | 1 #include <stdlib.h> |
2 | |
3 #include "context.h" | |
4 | |
5 extern __code code1_stub(struct Context*); | |
6 extern __code code2_stub(struct Context*); | |
7 extern __code code3_stub(struct Context*); | |
8 extern __code code4(struct Context*); | |
9 extern __code code5(struct Context*); | |
10 extern __code find(struct Context*); | |
11 extern __code not_find(struct Context*); | |
12 extern __code code6(struct Context*); | |
13 extern __code meta(struct Context*); | |
14 extern __code put_stub(struct Context*); | |
15 extern __code replaceNode_stub(struct Context*); | |
124 | 16 extern __code replaceNode1_stub(struct Context*); |
86 | 17 extern __code insertNode_stub(struct Context*); |
18 extern __code rotateLeft_stub(struct Context*); | |
19 extern __code rotateRight_stub(struct Context*); | |
20 extern __code colorFlip_stub(struct Context*); | |
21 extern __code fixUp_stub(struct Context*); | |
22 extern __code changeReference_stub(struct Context*); | |
23 extern __code insert1_stub(struct Context*); | |
24 extern __code insert2_stub(struct Context*); | |
25 extern __code insert3_stub(struct Context*); | |
124 | 26 extern __code insert31_stub(struct Context*); |
86 | 27 extern __code insert4_stub(struct Context*); |
124 | 28 extern __code insert4_01_stub(struct Context*); |
29 extern __code insert4_02_stub(struct Context*); | |
86 | 30 extern __code insert4_1_stub(struct Context*); |
31 extern __code insert4_2_stub(struct Context*); | |
32 extern __code insert5_stub(struct Context*); | |
33 extern __code stackClear_stub(struct Context*); | |
34 extern __code get_stub(struct Context*); | |
35 extern __code search_stub(struct Context*); | |
36 extern __code delete_stub(struct Context*); | |
37 extern __code delete1_stub(struct Context*); | |
38 extern __code delete2_stub(struct Context*); | |
39 extern __code delete3_stub(struct Context*); | |
40 extern __code replaceNodeForDelete1_stub(struct Context*); | |
41 extern __code replaceNodeForDelete2_stub(struct Context*); | |
42 extern __code findMax1_stub(struct Context*); | |
43 extern __code findMax2_stub(struct Context*); | |
44 extern __code deleteCase1_stub(struct Context*); | |
45 extern __code deleteCase2_stub(struct Context*); | |
46 extern __code deleteCase3_stub(struct Context*); | |
47 extern __code deleteCase4_stub(struct Context*); | |
48 extern __code deleteCase5_stub(struct Context*); | |
49 extern __code deleteCase6_stub(struct Context*); | |
50 extern __code createWorker_stub(struct Context*); | |
51 extern __code taskManager_stub(struct Context*); | |
90 | 52 extern __code createData1_stub(struct Context*); |
53 extern __code createData2_stub(struct Context*); | |
54 extern __code createTask1_stub(struct Context*); | |
55 extern __code createTask2_stub(struct Context*); | |
112 | 56 extern __code createTask3_stub(struct Context*); |
57 extern __code createTask4_stub(struct Context*); | |
90 | 58 extern __code putQueue1_stub(struct Context*); |
59 extern __code putQueue2_stub(struct Context*); | |
60 extern __code putQueue3_stub(struct Context*); | |
61 extern __code putQueue4_stub(struct Context*); | |
91 | 62 extern __code getQueue_stub(struct Context*); |
112 | 63 extern __code spawnTask_stub(struct Context*); |
92 | 64 extern __code twice_stub(struct Context*); |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
65 extern __code start_time_stub(struct Context*); |
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
66 extern __code end_time_stub(struct Context*); |
86 | 67 extern __code exit_code(struct Context*); |
68 | |
69 __code initContext(struct Context* context) { | |
70 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; | |
101 | 71 context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); |
72 context->data = NEWN(ALLOCATE_SIZE, union Data*); | |
73 context->heapStart = NEWN(context->heapLimit, char); | |
74 context->heap = context->heapStart; | |
86 | 75 |
76 context->codeNum = Exit; | |
77 | |
78 context->code[Code1] = code1_stub; | |
92 | 79 context->code[Code2] = code2_stub; |
86 | 80 /* context->code[Code3] = code3_stub; */ |
81 /* context->code[Code4] = code4; */ | |
82 /* context->code[Code5] = code5; */ | |
83 /* context->code[Find] = find; */ | |
84 /* context->code[Not_find] = not_find; */ | |
85 /* context->code[Code6] = code6; */ | |
112 | 86 context->code[PutTree] = put_stub; |
87 context->code[Replace] = replaceNode_stub; | |
124 | 88 context->code[Replace1] = replaceNode1_stub; |
112 | 89 context->code[Insert] = insertNode_stub; |
90 context->code[RotateL] = rotateLeft_stub; | |
91 context->code[RotateR] = rotateRight_stub; | |
86 | 92 context->code[InsertCase1] = insert1_stub; |
93 context->code[InsertCase2] = insert2_stub; | |
94 context->code[InsertCase3] = insert3_stub; | |
124 | 95 context->code[InsertCase31] = insert31_stub; |
86 | 96 context->code[InsertCase4] = insert4_stub; |
124 | 97 context->code[InsertCase4_01]= insert4_01_stub; |
98 context->code[InsertCase4_02]= insert4_02_stub; | |
86 | 99 context->code[InsertCase4_1] = insert4_1_stub; |
100 context->code[InsertCase4_2] = insert4_2_stub; | |
101 context->code[InsertCase5] = insert5_stub; | |
102 context->code[StackClear] = stackClear_stub; | |
112 | 103 context->code[Get] = get_stub; |
92 | 104 context->code[Search] = search_stub; |
86 | 105 /* context->code[Delete] = delete_stub; */ |
106 /* context->code[Delete1] = delete1_stub; */ | |
107 /* context->code[Delete2] = delete2_stub; */ | |
108 /* context->code[Delete3] = delete3_stub; */ | |
109 /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */ | |
110 /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */ | |
111 /* context->code[FindMax1] = findMax1_stub; */ | |
112 /* context->code[FindMax2] = findMax2_stub; */ | |
113 /* context->code[DeleteCase1] = deleteCase1_stub; */ | |
114 /* context->code[DeleteCase2] = deleteCase2_stub; */ | |
115 /* context->code[DeleteCase3] = deleteCase3_stub; */ | |
116 /* context->code[DeleteCase4] = deleteCase4_stub; */ | |
117 /* context->code[DeleteCase5] = deleteCase5_stub; */ | |
118 /* context->code[DeleteCase6] = deleteCase6_stub; */ | |
119 context->code[CreateWorker] = createWorker_stub; | |
120 context->code[TaskManager] = taskManager_stub; | |
90 | 121 context->code[CreateData1] = createData1_stub; |
122 context->code[CreateData2] = createData2_stub; | |
123 context->code[CreateTask1] = createTask1_stub; | |
124 context->code[CreateTask2] = createTask2_stub; | |
112 | 125 context->code[CreateTask3] = createTask3_stub; |
126 context->code[CreateTask4] = createTask4_stub; | |
90 | 127 context->code[PutQueue1] = putQueue1_stub; |
128 context->code[PutQueue2] = putQueue2_stub; | |
129 context->code[PutQueue3] = putQueue3_stub; | |
130 context->code[PutQueue4] = putQueue4_stub; | |
91 | 131 context->code[GetQueue] = getQueue_stub; |
112 | 132 context->code[SpawnTask] = spawnTask_stub; |
92 | 133 context->code[Twice] = twice_stub; |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
134 context->code[StartTime] = start_time_stub; |
112 | 135 context->code[EndTime] = end_time_stub; |
136 context->code[Exit] = exit_code; | |
86 | 137 |
101 | 138 struct Worker* worker = ALLOC_DATA(context, Worker); |
87 | 139 worker->num = 0; |
140 worker->contexts = 0; | |
141 | |
101 | 142 struct Allocate* allocate = ALLOC_DATA(context, Allocate); |
87 | 143 allocate->size = 0; |
144 | |
130 | 145 struct SingleLinkedStack* stack = ALLOC_DATA(context, SignleLinkedStack); |
146 stack->top = NULL; | |
147 stack->i.push = _; | |
148 stack->i.pop = _; | |
149 stack->i.isEmpty = _; | |
150 | |
101 | 151 struct Tree* tree = ALLOC_DATA(context, Tree); |
86 | 152 tree->root = 0; |
87 | 153 |
124 | 154 struct Traverse* traverse = ALLOC_DATA(context, Traverse); |
155 traverse->nodeStack = NULL; | |
101 | 156 |
157 struct Node* node = ALLOC_DATA(context, Node); | |
87 | 158 node->key = 0; |
159 node->value = 0; | |
160 node->left = 0; | |
161 node->right = 0; | |
101 | 162 |
163 struct LoopCounter* counter = ALLOC_DATA(context, LoopCounter); | |
86 | 164 counter->i = 0; |
87 | 165 |
101 | 166 struct Element* element = ALLOC_DATA(context, Element); |
114
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
167 element->data = 0; |
90 | 168 element->next = 0; |
169 | |
101 | 170 ALLOC_DATA(context, Time); |
171 | |
172 struct Queue* activeQueue = ALLOC_DATA_TYPE(context, ActiveQueue, Queue); | |
90 | 173 activeQueue->first = 0; |
174 activeQueue->last = 0; | |
175 activeQueue->count = 0; | |
101 | 176 |
109
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
177 struct Queue* waitQueue = ALLOC_DATA_TYPE(context, WaitQueue, Queue); |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
178 waitQueue->first = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
179 waitQueue->last = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
180 waitQueue->count = 0; |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
181 |
059b26a250cc
Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
101
diff
changeset
|
182 context->dataNum = Queue; |
86 | 183 } |