Mercurial > hg > GearsTemplate
annotate src/parallel_execution/context.h @ 410:85b0ddbf458e
Fix CudaWorker
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 14 Sep 2017 02:35:20 +0900 |
parents | 9b35e6581b5c |
children | 0eba9a04633f |
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; |
410
85b0ddbf458e
Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
100 int gpu; // GPU task |
406
9b35e6581b5c
Use task member of context by par goto meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
101 struct Context* task; |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
102 struct Queue* tasks; |
308 | 103 #ifdef USE_CUDAWorker |
104 int num_exec; | |
105 CUmodule module; | |
106 CUfunction function; | |
309 | 107 #endif |
86 | 108 union Data **data; |
372
d6ce4273e7d1
Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
369
diff
changeset
|
109 |
d6ce4273e7d1
Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
369
diff
changeset
|
110 /* multi dimension parameter */ |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
111 int iterate; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
112 struct Iterator* iterator; |
86 | 113 }; |
114 | |
115 union Data { | |
133 | 116 struct Meta { |
117 enum DataType type; | |
236 | 118 long size; |
176 | 119 struct Queue* wait; // tasks waiting this dataGear |
133 | 120 } meta; |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
254
diff
changeset
|
121 struct Context Context; |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
122 struct Time { |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
123 union Data* time; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
124 enum Code start; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
125 enum Code end; |
102 | 126 enum Code next; |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
127 } Time; |
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
128 struct TimeImpl { |
95
3e28ee215c0e
modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
92
diff
changeset
|
129 double time; |
364
a0a3301bac4d
Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
362
diff
changeset
|
130 } TimeImpl; |
86 | 131 struct LoopCounter { |
132 int i; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
133 } LoopCounter; |
176 | 134 struct TaskManager { |
320
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
135 #ifdef USE_CUDA_MAIN_THREAD |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
136 volatile |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
137 #endif |
f730761bb044
non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
316
diff
changeset
|
138 union Data* taskManager; |
234 | 139 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
|
140 enum Code spawnTasks; // start NEW tasks on the worker |
176 | 141 enum Code shutdown; |
405
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
142 enum Code incrementTaskCount; |
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
143 enum Code decrementTaskCount; |
184 | 144 enum Code next; |
353
b07078bd1f2c
Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
352
diff
changeset
|
145 enum Code next1; |
233 | 146 enum Code task; |
147 struct Context* context; | |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
148 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
|
149 union Data* data; |
233 | 150 int worker; |
151 int cpu; | |
152 int gpu; | |
153 int io; | |
237 | 154 int maxCPU; |
184 | 155 } TaskManager; |
182 | 156 struct TaskManagerImpl { |
388 | 157 enum Code next; |
233 | 158 int numWorker; |
410
85b0ddbf458e
Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
159 int sendCPUWorkerIndex; |
85b0ddbf458e
Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
160 int sendGPUWorkerIndex; |
405
8915fce522b3
Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
404
diff
changeset
|
161 int taskCount; |
239 | 162 pthread_mutex_t mutex; |
184 | 163 struct Queue* activeQueue; |
164 struct Queue* taskQueue; | |
244 | 165 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
|
166 struct LoopCounter* loopCounter; |
184 | 167 } TaskManagerImpl; |
86 | 168 struct Worker { |
232 | 169 union Data* worker; |
222
77faa28128b4
Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
218
diff
changeset
|
170 enum Code taskReceive; |
176 | 171 enum Code shutdown; |
230 | 172 enum Code next; |
244 | 173 struct Queue* tasks; |
288 | 174 struct TaskManager* taskManager; |
184 | 175 } Worker; |
232 | 176 struct CPUWorker { |
233 | 177 pthread_t thread; |
242 | 178 pthread_mutex_t mutex; |
179 pthread_cond_t cond; | |
232 | 180 struct Context* context; |
181 int id; | |
182 } CPUWorker; | |
302 | 183 #ifdef USE_CUDAWorker |
184 struct CUDAWorker { | |
316
54d203daf06b
CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
309
diff
changeset
|
185 CUdevice device; |
54d203daf06b
CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
309
diff
changeset
|
186 CUcontext cuCtx; |
233 | 187 pthread_t thread; |
232 | 188 struct Context* context; |
189 int id; | |
190 struct Queue* tasks; | |
191 int runFlag; | |
192 enum Code next; | |
305 | 193 int num_stream; |
194 CUstream *stream; | |
195 } CUDAWorker; | |
187 | 196 #else |
302 | 197 struct CUDAWorker { |
305 | 198 } CUDAWorker; |
101 | 199 #endif |
177 | 200 struct Main { |
201 enum Code code; | |
202 enum Code next; | |
203 struct Queue* args; | |
185 | 204 } Main; |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
205 // Queue Interface |
90 | 206 struct Queue { |
136 | 207 union Data* queue; |
167 | 208 union Data* data; |
209 enum Code whenEmpty; | |
210 enum Code clear; | |
211 enum Code put; | |
212 enum Code take; | |
213 enum Code isEmpty; | |
130 | 214 enum Code next; |
184 | 215 } Queue; |
167 | 216 struct SingleLinkedQueue { |
217 struct Element* top; | |
218 struct Element* last; | |
184 | 219 } SingleLinkedQueue; |
282
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
220 struct SynchronizedQueue { |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
221 struct Element* top; |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
222 struct Element* last; |
a3448b0f0a56
Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
223 } SynchronizedQueue; |
132 | 224 // Stack Interface |
130 | 225 struct Stack { |
132 | 226 union Data* stack; |
130 | 227 union Data* data; |
133 | 228 union Data* data1; |
169
ea7b11f3e717
Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
229 enum Code whenEmpty; |
145
cc071cf1ba85
add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
230 enum Code clear; |
130 | 231 enum Code push; |
232 enum Code pop; | |
133 | 233 enum Code pop2; |
130 | 234 enum Code isEmpty; |
134
2eccf4564efe
fix stack call in rb_tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
133
diff
changeset
|
235 enum Code get; |
133 | 236 enum Code get2; |
130 | 237 enum Code next; |
194 | 238 } Stack; |
132 | 239 // Stack implementations |
240 struct SingleLinkedStack { | |
241 struct Element* top; | |
194 | 242 } SingleLinkedStack; |
132 | 243 struct ArrayStack { |
244 int size; | |
245 int limit; | |
246 struct Element* array; | |
194 | 247 } ArrayStack; |
132 | 248 // Stack implementation end |
90 | 249 struct Element { |
113
d05b9937aa95
Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
250 union Data* data; |
90 | 251 struct Element* next; |
194 | 252 } Element; |
86 | 253 struct Array { |
381
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
254 int size; |
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
255 int prefix; |
b81492c74d2b
Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
256 int* array; |
194 | 257 } Array; |
86 | 258 struct Tree { |
166 | 259 union Data* tree; |
260 struct Node* node; | |
152 | 261 enum Code put; |
262 enum Code get; | |
263 enum Code remove; | |
171 | 264 enum Code clear; |
152 | 265 enum Code next; |
166 | 266 } Tree; |
172 | 267 struct RedBlackTree { |
152 | 268 struct Node* root; |
122 | 269 struct Node* current; // reading node of original tree |
138 | 270 struct Node* previous; // parent of reading node of original tree |
124 | 271 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
|
272 struct Node* parent; |
34a7a21edc36
recude stack get using traverse field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
138
diff
changeset
|
273 struct Node* grandparent; |
132 | 274 struct Stack* nodeStack; |
86 | 275 int result; |
172 | 276 } RedBlackTree; |
147 | 277 struct RotateTree { |
278 enum Code next; | |
172 | 279 struct RedBlackTree* traverse; |
147 | 280 struct Tree* tree; |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
281 } RotateTree; |
86 | 282 struct Node { |
283 int key; // comparable data segment | |
90 | 284 union Data* value; |
86 | 285 struct Node* left; |
286 struct Node* right; | |
287 // need to balancing | |
288 enum Color { | |
289 Red, | |
290 Black, | |
291 } color; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
292 } Node; |
286 | 293 struct Semaphore { |
294 union Data* semaphore; | |
295 enum Code p; | |
296 enum Code v; | |
297 enum Code next; | |
298 } Semaphore; | |
299 struct SemaphoreImpl { | |
300 int value; | |
301 pthread_mutex_t mutex; | |
302 pthread_cond_t cond; | |
303 } SemaphoreImpl; | |
86 | 304 struct Allocate { |
305 enum Code next; | |
306 long size; | |
217
c34e6aa10967
Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
207
diff
changeset
|
307 } Allocate; |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
308 struct Integer { |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
309 int value; |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
320
diff
changeset
|
310 } Integer; |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
311 struct SortArray { |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
312 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
|
313 int loopCounter; |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
314 int block; |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
315 int first; |
383
300c18700ca5
Add split to bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
381
diff
changeset
|
316 int prefix; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
317 } SortArray; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
318 struct Iterator { |
375
ad44fdb11433
Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
374
diff
changeset
|
319 union Data* iterator; |
ad44fdb11433
Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
374
diff
changeset
|
320 struct Context* task; |
410
85b0ddbf458e
Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
321 int numGPU; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
322 enum Code exec; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
323 enum Code barrier; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
324 enum Code whenWait; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
325 enum Code next; |
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
326 } Iterator; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
327 struct MultiDimIterator { |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
328 int x; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
329 int y; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
330 int z; |
374
fb50cf8aa615
Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
372
diff
changeset
|
331 int count; |
402
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
332 int counterX; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
333 int counterY; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
334 int counterZ; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
335 } MultiDimIterator; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
336 struct MultiDim { |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
337 int x; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
338 int y; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
339 int z; |
e958a409943c
Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
398
diff
changeset
|
340 } MultiDim; |
254 | 341 }; // 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
|
342 |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
254
diff
changeset
|
343 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
|
344 |
186 | 345 #include "c/typedefData.h" |
278 | 346 |
347 #include "c/extern.h" | |
348 | |
349 extern __code start_code(struct Context* context); | |
350 extern __code exit_code(struct Context* context); | |
351 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
|
352 extern __code par_meta(struct Context* context, enum Code spawns, enum Code next); |
278 | 353 extern void initContext(struct Context* context); |
354 | |
132 | 355 #endif |