Mercurial > hg > GearsTemplate
annotate src/parallel_execution/context.h @ 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 | 8915fce522b3 |
children | 85b0ddbf458e |
rev | line source |
---|---|
86 | 1 /* Context definition for llrb example */ |
132 | 2 #ifndef CONTEXT_H |
3 #define CONTEXT_H | |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
194
diff
changeset
|
4 #include <stdlib.h> |
86 | 5 #include <pthread.h> |
304
9755206813cb
helper_string.h for ANSI C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
6 #ifdef USE_CUDAWorker |
98 | 7 #include <cuda.h> |
101 | 8 #endif |
86 | 9 |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
10 #define ALLOCATE_SIZE 20000000 |
101 | 11 #define NEW(type) (type*)(calloc(1, sizeof(type))) |
12 #define NEWN(n, type) (type*)(calloc(n, sizeof(type))) | |
13 | |
133 | 14 #define ALLOC_DATA(context, dseg) ({\ |
15 struct Meta* meta = (struct Meta*)context->heap;\ | |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
16 meta->type = D_##dseg;\ |
236 | 17 meta->size = 1;\ |
133 | 18 context->heap += sizeof(struct Meta);\ |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
19 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; }) |
101 | 20 |
133 | 21 #define ALLOC_DATA_TYPE(context, dseg, t) ({\ |
22 struct Meta* meta = (struct Meta*)context->heap;\ | |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
23 meta->type = D_##t;\ |
236 | 24 meta->size = 1;\ |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
25 context->heap += sizeof(struct Meta);\ |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
26 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; }) |
86 | 27 |
132 | 28 #define ALLOCATE(context, t) ({ \ |
133 | 29 struct Meta* meta = (struct Meta*)context->heap;\ |
30 context->heap += sizeof(struct Meta);\ | |
31 union Data* data = context->heap; \ | |
32 context->heap += sizeof(struct t); \ | |
148
473b7d990a1f
fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
147
diff
changeset
|
33 meta->type = D_##t; \ |
236 | 34 meta->size = 1; \ |
133 | 35 data; }) |
132 | 36 |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
37 #define ALLOCATE_ARRAY(context, t, len) ({ \ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
38 struct Meta* meta = (struct Meta*)context->heap;\ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
39 context->heap += sizeof(struct Meta);\ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
40 union Data* data = context->heap; \ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
41 context->heap += sizeof(struct t)*len; \ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
42 meta->type = D_##t; \ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
43 meta->size = len; \ |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
44 data; }) |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
45 |
233 | 46 #define ALLOC(context, t) (&ALLOCATE(context, t)->t) |
47 | |
237 | 48 #define ALLOC_ARRAY(context, dseg, len) ({\ |
236 | 49 struct Meta* meta = (struct Meta*)context->heap;\ |
50 context->heap += sizeof(struct Meta);\ | |
51 union Data* data = context->heap; \ | |
244 | 52 context->heap += sizeof(struct dseg *)*len; \ |
236 | 53 meta->type = D_##dseg; \ |
237 | 54 meta->size = len; \ |
236 | 55 data; }) |
56 | |
327
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
57 #define ALLOCATE_DATA_GEAR(context, t) ({ \ |
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
58 union Data* data = ALLOCATE(context, t); \ |
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
59 struct Meta* meta = GET_META(data); \ |
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
60 meta->wait = createSingleLinkedQueue(context); \ |
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
61 data; }) |
534601ed8c50
Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
62 |
288 | 63 #define GET_META(dseg) ((struct Meta*)(((void*)dseg) - sizeof(struct Meta))) |
64 #define GET_TYPE(dseg) (GET_META(dseg)->type) | |
352
3e01e963eb2d
Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
344
diff
changeset
|
65 #define GET_SIZE(dseg) (GET_META(dseg)->size) |
288 | 66 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait) |
132 | 67 |
149 | 68 #define Gearef(context, t) (&(context)->data[D_##t]->t) |
186 | 69 |
232 | 70 // (struct SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack |
71 | |
72 #define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name) | |
73 | |
186 | 74 #include "c/enumCode.h" |
86 | 75 |
76 enum Relational { | |
77 EQ, | |
78 GT, | |
79 LT, | |
80 }; | |
81 | |
186 | 82 #include "c/enumData.h" |
86 | 83 |
84 struct Context { | |
85 enum Code next; | |
230 | 86 struct Worker* worker; |
87 struct TaskManager* taskManager; | |
86 | 88 int codeNum; |
89 __code (**code) (struct Context*); | |
90 void* heapStart; | |
91 void* heap; | |
92 long heapLimit; | |
87 | 93 int dataNum; |
236 | 94 int idgCount; //number of waiting dataGear |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
95 int idg; |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
96 int maxIdg; |
282
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
97 int odg; |
288 | 98 int maxOdg; |
242 | 99 int workerId; |
406
9b35e6581b5c
Use task member of context by par goto meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
100 struct Context* task; |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
101 struct Queue* tasks; |
308 | 102 #ifdef USE_CUDAWorker |
103 int num_exec; | |
104 CUmodule module; | |
105 CUfunction function; | |
309 | 106 #endif |
86 | 107 union Data **data; |
372
d6ce4273e7d1
Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
369
diff
changeset
|
108 |
d6ce4273e7d1
Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
369
diff
changeset
|
109 /* multi dimension parameter */ |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
110 int iterate; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
111 struct Iterator* iterator; |
86 | 112 }; |
113 | |
114 union Data { | |
133 | 115 struct Meta { |
116 enum DataType type; | |
236 | 117 long size; |
176 | 118 struct Queue* wait; // tasks waiting this dataGear |
133 | 119 } meta; |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
254
diff
changeset
|
120 struct Context Context; |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
121 struct Time { |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
122 union Data* time; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
123 enum Code start; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
124 enum Code end; |
102 | 125 enum Code next; |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
126 } Time; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
127 struct TimeImpl { |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
128 double time; |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
129 } TimeImpl; |
86 | 130 struct LoopCounter { |
131 int i; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
132 } LoopCounter; |
176 | 133 struct TaskManager { |
320
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
134 #ifdef USE_CUDA_MAIN_THREAD |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
135 volatile |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
136 #endif |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
137 union Data* taskManager; |
234 | 138 enum Code spawn; // start NEW context on the worker |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
139 enum Code spawnTasks; // start NEW tasks on the worker |
176 | 140 enum Code shutdown; |
405
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
141 enum Code incrementTaskCount; |
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
142 enum Code decrementTaskCount; |
184 | 143 enum Code next; |
353
b07078bd1f2c
Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
352
diff
changeset
|
144 enum Code next1; |
233 | 145 enum Code task; |
146 struct Context* context; | |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
147 struct Queue* tasks; |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
148 union Data* data; |
233 | 149 int worker; |
150 int cpu; | |
151 int gpu; | |
152 int io; | |
237 | 153 int maxCPU; |
184 | 154 } TaskManager; |
182 | 155 struct TaskManagerImpl { |
388 | 156 enum Code next; |
233 | 157 int numWorker; |
242 | 158 int sendWorkerIndex; |
405
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
159 int taskCount; |
239 | 160 pthread_mutex_t mutex; |
184 | 161 struct Queue* activeQueue; |
162 struct Queue* taskQueue; | |
244 | 163 struct Worker** workers; |
352
3e01e963eb2d
Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
344
diff
changeset
|
164 struct LoopCounter* loopCounter; |
184 | 165 } TaskManagerImpl; |
86 | 166 struct Worker { |
232 | 167 union Data* worker; |
222
77faa28128b4
Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
218
diff
changeset
|
168 enum Code taskReceive; |
176 | 169 enum Code shutdown; |
230 | 170 enum Code next; |
244 | 171 struct Queue* tasks; |
288 | 172 struct TaskManager* taskManager; |
184 | 173 } Worker; |
232 | 174 struct CPUWorker { |
233 | 175 pthread_t thread; |
242 | 176 pthread_mutex_t mutex; |
177 pthread_cond_t cond; | |
232 | 178 struct Context* context; |
179 int id; | |
180 } CPUWorker; | |
302 | 181 #ifdef USE_CUDAWorker |
182 struct CUDAWorker { | |
316
54d203daf06b
CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
309
diff
changeset
|
183 CUdevice device; |
54d203daf06b
CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
309
diff
changeset
|
184 CUcontext cuCtx; |
233 | 185 pthread_t thread; |
232 | 186 struct Context* context; |
187 int id; | |
188 struct Queue* tasks; | |
189 int runFlag; | |
190 enum Code next; | |
305 | 191 int num_stream; |
192 CUstream *stream; | |
193 } CUDAWorker; | |
187 | 194 #else |
302 | 195 struct CUDAWorker { |
305 | 196 } CUDAWorker; |
101 | 197 #endif |
177 | 198 struct Main { |
199 enum Code code; | |
200 enum Code next; | |
201 struct Queue* args; | |
185 | 202 } Main; |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
203 // Queue Interface |
90 | 204 struct Queue { |
136 | 205 union Data* queue; |
167 | 206 union Data* data; |
207 enum Code whenEmpty; | |
208 enum Code clear; | |
209 enum Code put; | |
210 enum Code take; | |
211 enum Code isEmpty; | |
130 | 212 enum Code next; |
184 | 213 } Queue; |
167 | 214 struct SingleLinkedQueue { |
215 struct Element* top; | |
216 struct Element* last; | |
184 | 217 } SingleLinkedQueue; |
282
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
218 struct SynchronizedQueue { |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
219 struct Element* top; |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
220 struct Element* last; |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
221 } SynchronizedQueue; |
132 | 222 // Stack Interface |
130 | 223 struct Stack { |
132 | 224 union Data* stack; |
130 | 225 union Data* data; |
133 | 226 union Data* data1; |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
227 enum Code whenEmpty; |
145
cc071cf1ba85
add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
228 enum Code clear; |
130 | 229 enum Code push; |
230 enum Code pop; | |
133 | 231 enum Code pop2; |
130 | 232 enum Code isEmpty; |
134
2eccf4564efe
fix stack call in rb_tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
233 enum Code get; |
133 | 234 enum Code get2; |
130 | 235 enum Code next; |
194 | 236 } Stack; |
132 | 237 // Stack implementations |
238 struct SingleLinkedStack { | |
239 struct Element* top; | |
194 | 240 } SingleLinkedStack; |
132 | 241 struct ArrayStack { |
242 int size; | |
243 int limit; | |
244 struct Element* array; | |
194 | 245 } ArrayStack; |
132 | 246 // Stack implementation end |
90 | 247 struct Element { |
113
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
248 union Data* data; |
90 | 249 struct Element* next; |
194 | 250 } Element; |
86 | 251 struct Array { |
381
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
252 int size; |
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
253 int prefix; |
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
254 int* array; |
194 | 255 } Array; |
86 | 256 struct Tree { |
166 | 257 union Data* tree; |
258 struct Node* node; | |
152 | 259 enum Code put; |
260 enum Code get; | |
261 enum Code remove; | |
171 | 262 enum Code clear; |
152 | 263 enum Code next; |
166 | 264 } Tree; |
172 | 265 struct RedBlackTree { |
152 | 266 struct Node* root; |
122 | 267 struct Node* current; // reading node of original tree |
138 | 268 struct Node* previous; // parent of reading node of original tree |
124 | 269 struct Node* newNode; // writing node of new tree |
143
34a7a21edc36
recude stack get using traverse field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
138
diff
changeset
|
270 struct Node* parent; |
34a7a21edc36
recude stack get using traverse field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
138
diff
changeset
|
271 struct Node* grandparent; |
132 | 272 struct Stack* nodeStack; |
86 | 273 int result; |
172 | 274 } RedBlackTree; |
147 | 275 struct RotateTree { |
276 enum Code next; | |
172 | 277 struct RedBlackTree* traverse; |
147 | 278 struct Tree* tree; |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
279 } RotateTree; |
86 | 280 struct Node { |
281 int key; // comparable data segment | |
90 | 282 union Data* value; |
86 | 283 struct Node* left; |
284 struct Node* right; | |
285 // need to balancing | |
286 enum Color { | |
287 Red, | |
288 Black, | |
289 } color; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
290 } Node; |
286 | 291 struct Semaphore { |
292 union Data* semaphore; | |
293 enum Code p; | |
294 enum Code v; | |
295 enum Code next; | |
296 } Semaphore; | |
297 struct SemaphoreImpl { | |
298 int value; | |
299 pthread_mutex_t mutex; | |
300 pthread_cond_t cond; | |
301 } SemaphoreImpl; | |
86 | 302 struct Allocate { |
303 enum Code next; | |
304 long size; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
305 } Allocate; |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
306 struct Integer { |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
307 int value; |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
308 } Integer; |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
309 struct SortArray { |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
310 struct Integer *array; //Array arrayじゃできない? |
379
2744cb933ebc
Fix compile error for bitonicSort but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
375
diff
changeset
|
311 int loopCounter; |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
312 int block; |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
313 int first; |
383
300c18700ca5
Add split to bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
381
diff
changeset
|
314 int prefix; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
315 } SortArray; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
316 struct Iterator { |
375
ad44fdb11433
Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
374
diff
changeset
|
317 union Data* iterator; |
ad44fdb11433
Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
374
diff
changeset
|
318 struct Context* task; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
319 enum Code exec; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
320 enum Code barrier; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
321 enum Code whenWait; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
322 enum Code next; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
323 } Iterator; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
324 struct MultiDimIterator { |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
325 int x; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
326 int y; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
327 int z; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
328 int count; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
329 int counterX; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
330 int counterY; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
331 int counterZ; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
332 } MultiDimIterator; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
333 struct MultiDim { |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
334 int x; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
335 int y; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
336 int z; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
337 } MultiDim; |
254 | 338 }; // union Data end this is necessary for context generator |
113
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
339 |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
254
diff
changeset
|
340 typedef union Data Data; |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
254
diff
changeset
|
341 |
186 | 342 #include "c/typedefData.h" |
278 | 343 |
344 #include "c/extern.h" | |
345 | |
346 extern __code start_code(struct Context* context); | |
347 extern __code exit_code(struct Context* context); | |
348 extern __code meta(struct Context* context, enum Code next); | |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
349 extern __code par_meta(struct Context* context, enum Code spawns, enum Code next); |
278 | 350 extern void initContext(struct Context* context); |
351 | |
132 | 352 #endif |