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