annotate src/parallel_execution/context.h @ 459:57c715bd6283

Change taskManager parameter from context to task
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sat, 16 Dec 2017 06:04:32 +0900
parents 77de0283ac92
children 6b71cf5b1c22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Context definition for llrb example */
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
2 #ifndef CONTEXT_H
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
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
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
7 #include <cuda.h>
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
8 #endif
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
11 #define NEW(type) (type*)(calloc(1, sizeof(type)))
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
12 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
13
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
14 #define ALLOC_DATA(context, dseg) ({\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
15 Meta* meta = (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;\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
17 meta->size = sizeof(dseg);\
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
18 meta->len = 1;\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
19 context->heap += sizeof(Meta);\
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
20 context->data[D_##dseg] = context->heap; context->heap += sizeof(dseg); (dseg *)context->data[D_##dseg]; })
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
21
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
22 #define ALLOC_DATA_TYPE(context, dseg, t) ({\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
23 Meta* meta = (Meta*)context->heap;\
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
24 meta->type = D_##t;\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
25 meta->size = sizeof(t);\
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
26 meta->len = 1;\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
27 context->heap += sizeof(Meta);\
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
28 context->data[D_##dseg] = context->heap; context->heap += sizeof(t); (t *)context->data[D_##dseg]; })
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
30 #define ALLOCATE(context, t) ({ \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
31 Meta* meta = (Meta*)context->heap;\
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
32 context->heap += sizeof(Meta);\
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
33 union Data* data = context->heap; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
34 context->heap += sizeof(t); \
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
35 meta->type = D_##t; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
36 meta->size = sizeof(t); \
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
37 meta->len = 1;\
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
38 data; })
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
39
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
40 #define ALLOCATE_ARRAY(context, t, length) ({ \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
41 Meta* meta = (Meta*)context->heap;\
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
42 context->heap += sizeof(Meta);\
404
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
43 union Data* data = context->heap; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
44 context->heap += sizeof(t)*length; \
404
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
45 meta->type = D_##t; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
46 meta->size = sizeof(t)*length; \
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
47 meta->len = length; \
404
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
48 data; })
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
49
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
50 #define ALLOCATE_PTR_ARRAY(context, dseg, length) ({\
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
51 Meta* meta = (Meta*)context->heap;\
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
52 context->heap += sizeof(Meta);\
236
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
53 union Data* data = context->heap; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
54 context->heap += sizeof(dseg *)*length; \
236
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
55 meta->type = D_##dseg; \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
56 meta->size = sizeof(dseg *)*length; \
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
57 meta->len = length; \
236
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
58 data; })
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
59
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
60 #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
61 union Data* data = ALLOCATE(context, t); \
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
62 Meta* meta = GET_META(data); \
449
0181b7fa5f53 Using SynchornizedQueue in data gear wait list
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 447
diff changeset
63 meta->wait = createSynchronizedQueue(context); \
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
64 data; })
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
65
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
66 #define ALLOC(context, t) (&ALLOCATE(context, t)->t)
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
67
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
68 #define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
288
f1b0cc555b6e Add odgCommit
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 287
diff changeset
69 #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
70 #define GET_SIZE(dseg) (GET_META(dseg)->size)
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
71 #define GET_LEN(dseg) (GET_META(dseg)->len)
288
f1b0cc555b6e Add odgCommit
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 287
diff changeset
72 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
73
149
63ab65b28466 Add Gearef macro
one
parents: 148
diff changeset
74 #define Gearef(context, t) (&(context)->data[D_##t]->t)
186
dbc064c26b98 generate context script
mir3636
parents: 185
diff changeset
75
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
76 // (SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
77
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
78 #define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name)
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
79
186
dbc064c26b98 generate context script
mir3636
parents: 185
diff changeset
80 #include "c/enumCode.h"
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 enum Relational {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 EQ,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 GT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 LT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
186
dbc064c26b98 generate context script
mir3636
parents: 185
diff changeset
88 #include "c/enumData.h"
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 struct Context {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 enum Code next;
230
a1fb3f2d1a36 fix worker
ikkun
parents: 222
diff changeset
92 struct Worker* worker;
a1fb3f2d1a36 fix worker
ikkun
parents: 222
diff changeset
93 struct TaskManager* taskManager;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 int codeNum;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 __code (**code) (struct Context*);
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 void* heapStart;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 void* heap;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 long heapLimit;
87
9e139a340bd1 rename directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
99 int dataNum;
236
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
100 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
101 int idg;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 320
diff changeset
102 int maxIdg;
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
103 int odg;
288
f1b0cc555b6e Add odgCommit
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 287
diff changeset
104 int maxOdg;
242
9f3f8ed6ed9f Add sendTask
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 239
diff changeset
105 int workerId;
410
85b0ddbf458e Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 406
diff changeset
106 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
107 struct Context* task;
398
fc4fcd441700 Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 397
diff changeset
108 struct Queue* tasks;
308
aeddca686007 CUDAtwice
ikkun
parents: 305
diff changeset
109 #ifdef USE_CUDAWorker
aeddca686007 CUDAtwice
ikkun
parents: 305
diff changeset
110 int num_exec;
aeddca686007 CUDAtwice
ikkun
parents: 305
diff changeset
111 CUmodule module;
aeddca686007 CUDAtwice
ikkun
parents: 305
diff changeset
112 CUfunction function;
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
113 #endif
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 union Data **data;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 369
diff changeset
115
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 369
diff changeset
116 /* multi dimension parameter */
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
117 int iterate;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
118 struct Iterator* iterator;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
121 typedef int Int;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
122 #ifndef USE_CUDAWorker
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
123 typedef unsigned long long CUdeviceptr;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
124 #endif
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 union Data {
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
126 struct Meta {
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
127 enum DataType type;
236
865179a0a56d fix taskManager
ikkun
parents: 234
diff changeset
128 long size;
430
35b37fe8d3a7 Add size member in struct Meta
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 429
diff changeset
129 long len;
176
f0427e27dd7b create interface of Task, TaskManager, Worker
mir3636
parents: 172
diff changeset
130 struct Queue* wait; // tasks waiting this dataGear
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
131 } Meta;
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 254
diff changeset
132 struct Context Context;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
133 struct Time {
364
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
134 union Data* time;
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
135 enum Code start;
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
136 enum Code end;
102
64c98838a291 remove stack StartTime&EndTime
ikkun
parents: 101
diff changeset
137 enum Code next;
364
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
138 } Time;
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
139 struct TimeImpl {
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
140 double time;
364
a0a3301bac4d Add Time interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 362
diff changeset
141 } TimeImpl;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 struct LoopCounter {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 int i;
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
144 } LoopCounter;
176
f0427e27dd7b create interface of Task, TaskManager, Worker
mir3636
parents: 172
diff changeset
145 struct TaskManager {
320
f730761bb044 non CUDA case clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 316
diff changeset
146 union Data* taskManager;
234
47588c28f189 TaskManager
mir3636
parents: 233
diff changeset
147 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
148 enum Code spawnTasks; // start NEW tasks on the worker
176
f0427e27dd7b create interface of Task, TaskManager, Worker
mir3636
parents: 172
diff changeset
149 enum Code shutdown;
405
8915fce522b3 Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 404
diff changeset
150 enum Code incrementTaskCount;
8915fce522b3 Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 404
diff changeset
151 enum Code decrementTaskCount;
184
mir3636
parents: 183
diff changeset
152 enum Code next;
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
153 enum Code next1;
459
57c715bd6283 Change taskManager parameter from context to task
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 454
diff changeset
154 enum Code setWaitTask;
57c715bd6283 Change taskManager parameter from context to task
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 454
diff changeset
155 struct Context* task;
398
fc4fcd441700 Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 397
diff changeset
156 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
157 union Data* data;
233
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
158 int worker;
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
159 int cpu;
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
160 int gpu;
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
161 int io;
237
mir3636
parents: 236
diff changeset
162 int maxCPU;
184
mir3636
parents: 183
diff changeset
163 } TaskManager;
182
57a11c15ff4c Add queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 178
diff changeset
164 struct TaskManagerImpl {
388
8940d1451a0d handle local continuation
masataka
parents: 383
diff changeset
165 enum Code next;
233
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
166 int numWorker;
410
85b0ddbf458e Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 406
diff changeset
167 int sendCPUWorkerIndex;
85b0ddbf458e Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 406
diff changeset
168 int sendGPUWorkerIndex;
405
8915fce522b3 Fix shutdown TaskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 404
diff changeset
169 int taskCount;
239
mir3636
parents: 237
diff changeset
170 pthread_mutex_t mutex;
184
mir3636
parents: 183
diff changeset
171 struct Queue* activeQueue;
mir3636
parents: 183
diff changeset
172 struct Queue* taskQueue;
244
d1567718f12c Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 242
diff changeset
173 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
174 struct LoopCounter* loopCounter;
184
mir3636
parents: 183
diff changeset
175 } TaskManagerImpl;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 struct Worker {
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
177 union Data* worker;
222
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 218
diff changeset
178 enum Code taskReceive;
176
f0427e27dd7b create interface of Task, TaskManager, Worker
mir3636
parents: 172
diff changeset
179 enum Code shutdown;
230
a1fb3f2d1a36 fix worker
ikkun
parents: 222
diff changeset
180 enum Code next;
244
d1567718f12c Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 242
diff changeset
181 struct Queue* tasks;
411
0eba9a04633f Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 410
diff changeset
182 pthread_t thread;
288
f1b0cc555b6e Add odgCommit
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 287
diff changeset
183 struct TaskManager* taskManager;
184
mir3636
parents: 183
diff changeset
184 } Worker;
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
185 struct CPUWorker {
242
9f3f8ed6ed9f Add sendTask
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 239
diff changeset
186 pthread_mutex_t mutex;
9f3f8ed6ed9f Add sendTask
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 239
diff changeset
187 pthread_cond_t cond;
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
188 struct Context* context;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
189 int id;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
190 } CPUWorker;
302
8e7926f3e271 fix CUDAWorker
ikkun
parents: 288
diff changeset
191 #ifdef USE_CUDAWorker
8e7926f3e271 fix CUDAWorker
ikkun
parents: 288
diff changeset
192 struct CUDAWorker {
316
54d203daf06b CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 309
diff changeset
193 CUdevice device;
54d203daf06b CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 309
diff changeset
194 CUcontext cuCtx;
233
06133afb3b5b create worker start_code
mir3636
parents: 232
diff changeset
195 pthread_t thread;
232
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
196 struct Context* context;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
197 int id;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
198 struct Queue* tasks;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
199 int runFlag;
123b0d277b84 worker interface
mir3636
parents: 230
diff changeset
200 enum Code next;
451
dcc42f3e7e97 Auto choice blockDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 450
diff changeset
201 int numStream;
436
08a93fc2f0d3 Fix CudaExecutor but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 435
diff changeset
202 struct Executor* executor;
305
ec0a5b4fba05 CUDAWorker
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 304
diff changeset
203 CUstream *stream;
ec0a5b4fba05 CUDAWorker
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 304
diff changeset
204 } CUDAWorker;
187
bacc37265386 main.o fixed
mir3636
parents: 186
diff changeset
205 #else
302
8e7926f3e271 fix CUDAWorker
ikkun
parents: 288
diff changeset
206 struct CUDAWorker {
305
ec0a5b4fba05 CUDAWorker
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 304
diff changeset
207 } CUDAWorker;
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
208 #endif
177
bb52f7f77bf5 add main
ikkun
parents: 176
diff changeset
209 struct Main {
bb52f7f77bf5 add main
ikkun
parents: 176
diff changeset
210 enum Code code;
bb52f7f77bf5 add main
ikkun
parents: 176
diff changeset
211 enum Code next;
bb52f7f77bf5 add main
ikkun
parents: 176
diff changeset
212 struct Queue* args;
185
247a2c4a8908 fix compile errors
mir3636
parents: 184
diff changeset
213 } Main;
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
214 // Queue Interface
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
215 struct Queue {
136
a747dc9d4da6 stack refactering no compile error
mir3636
parents: 135
diff changeset
216 union Data* queue;
167
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
217 union Data* data;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
218 enum Code whenEmpty;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
219 enum Code clear;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
220 enum Code put;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
221 enum Code take;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
222 enum Code isEmpty;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
223 enum Code next;
184
mir3636
parents: 183
diff changeset
224 } Queue;
167
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
225 struct SingleLinkedQueue {
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
226 struct Element* top;
34562e63981f create queue.c
mir3636
parents: 166
diff changeset
227 struct Element* last;
184
mir3636
parents: 183
diff changeset
228 } SingleLinkedQueue;
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
229 struct SynchronizedQueue {
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
230 struct Element* top;
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
231 struct Element* last;
444
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
232 struct Atomic* atomic;
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 278
diff changeset
233 } SynchronizedQueue;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
234 // Stack Interface
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
235 struct Stack {
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
236 union Data* stack;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
237 union Data* data;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
238 union Data* data1;
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
239 enum Code whenEmpty;
145
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
240 enum Code clear;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
241 enum Code push;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
242 enum Code pop;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
243 enum Code pop2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
244 enum Code isEmpty;
134
2eccf4564efe fix stack call in rb_tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
245 enum Code get;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
246 enum Code get2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
247 enum Code next;
194
081607dcf893 create generate_stub.pl
mir3636
parents: 187
diff changeset
248 } Stack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
249 // Stack implementations
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
250 struct SingleLinkedStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
251 struct Element* top;
194
081607dcf893 create generate_stub.pl
mir3636
parents: 187
diff changeset
252 } SingleLinkedStack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
253 struct ArrayStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
254 int size;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
255 int limit;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
256 struct Element* array;
194
081607dcf893 create generate_stub.pl
mir3636
parents: 187
diff changeset
257 } ArrayStack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
258 // Stack implementation end
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
259 struct Element {
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
260 union Data* data;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
261 struct Element* next;
194
081607dcf893 create generate_stub.pl
mir3636
parents: 187
diff changeset
262 } Element;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 struct Array {
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
264 int prefix;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
265 Int* array;
194
081607dcf893 create generate_stub.pl
mir3636
parents: 187
diff changeset
266 } Array;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 struct Tree {
166
mir3636
parents: 153
diff changeset
268 union Data* tree;
mir3636
parents: 153
diff changeset
269 struct Node* node;
150
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
270 enum Code put;
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
271 enum Code get;
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
272 enum Code remove;
171
747067fe46bd Fix selected Queue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 170
diff changeset
273 enum Code clear;
150
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
274 enum Code next;
166
mir3636
parents: 153
diff changeset
275 } Tree;
172
661b0b0d0399 replace Tree to RedBlackTree
ikkun
parents: 171
diff changeset
276 struct RedBlackTree {
150
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
277 struct Node* root;
122
73a679a85c04 node stack rewrite
ikkun
parents: 119
diff changeset
278 struct Node* current; // reading node of original tree
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
279 struct Node* previous; // parent of reading node of original tree
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
280 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
281 struct Node* parent;
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
282 struct Node* grandparent;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
283 struct Stack* nodeStack;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 int result;
172
661b0b0d0399 replace Tree to RedBlackTree
ikkun
parents: 171
diff changeset
285 } RedBlackTree;
147
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
286 struct RotateTree {
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
287 enum Code next;
172
661b0b0d0399 replace Tree to RedBlackTree
ikkun
parents: 171
diff changeset
288 struct RedBlackTree* traverse;
147
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
289 struct Tree* tree;
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
290 } RotateTree;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 struct Node {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 int key; // comparable data segment
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
293 union Data* value;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 struct Node* left;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 struct Node* right;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 // need to balancing
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 enum Color {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 Red,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 Black,
454
77de0283ac92 Debug RedBlackTree.cbc.
ryokka
parents: 452
diff changeset
300 // Red eq 0,Black eq 1. enum name convert intager.
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 } color;
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
302 } Node;
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
303 struct Atomic {
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
304 union Data* atomic;
444
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
305 union Data** ptr;
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
306 union Data* oldData;
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
307 union Data* newData;
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
308 enum Code checkAndSet;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
309 enum Code next;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
310 enum Code fail;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
311 } Atomic;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
312 struct AtomicReference {
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 438
diff changeset
313 } AtomicReference;
286
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
314 struct Semaphore {
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
315 union Data* semaphore;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
316 enum Code p;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
317 enum Code v;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
318 enum Code next;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
319 } Semaphore;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
320 struct SemaphoreImpl {
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
321 int value;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
322 pthread_mutex_t mutex;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
323 pthread_cond_t cond;
fd470e090403 Add sempahore
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 282
diff changeset
324 } SemaphoreImpl;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 struct Allocate {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 enum Code next;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 long size;
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
328 } Allocate;
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 320
diff changeset
329 struct Integer {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 320
diff changeset
330 int value;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 320
diff changeset
331 } Integer;
404
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
332 struct SortArray {
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
333 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
334 int loopCounter;
404
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
335 int block;
c5cd9888bf2a Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 402
diff changeset
336 int first;
383
300c18700ca5 Add split to bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
337 int prefix;
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
338 } SortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
339 struct Iterator {
375
ad44fdb11433 Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 374
diff changeset
340 union Data* iterator;
ad44fdb11433 Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 374
diff changeset
341 struct Context* task;
410
85b0ddbf458e Fix CudaWorker
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 406
diff changeset
342 int numGPU;
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
343 enum Code exec;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
344 enum Code barrier;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
345 enum Code whenWait;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
346 enum Code next;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
347 } Iterator;
402
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
348 struct MultiDimIterator {
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
349 int x;
402
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
350 int y;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
351 int z;
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
352 int count;
402
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
353 int counterX;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
354 int counterY;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
355 int counterZ;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
356 } MultiDimIterator;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
357 struct MultiDim {
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
358 int x;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
359 int y;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
360 int z;
e958a409943c Change iterator implement from oneDim to multiDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 398
diff changeset
361 } MultiDim;
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
362 struct Executor {
436
08a93fc2f0d3 Fix CudaExecutor but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 435
diff changeset
363 union Data* executor;
434
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
364 struct Context* task;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
365 enum Code read;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
366 enum Code exec;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
367 enum Code write;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
368 enum Code next;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
369 } Executor;
b75badf42701 Define Executor to context
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
370 #ifdef USE_CUDAWorker
435
af0ec811b20e Add CUDAExecutor
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 434
diff changeset
371 struct CUDAExecutor {
436
08a93fc2f0d3 Fix CudaExecutor but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 435
diff changeset
372 CUdeviceptr** kernelParams;
08a93fc2f0d3 Fix CudaExecutor but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 435
diff changeset
373 struct CUDABuffer* buffer;
451
dcc42f3e7e97 Auto choice blockDim
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 450
diff changeset
374 int maxThreadPerBlock;
435
af0ec811b20e Add CUDAExecutor
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 434
diff changeset
375 } CUDAExecutor;
af0ec811b20e Add CUDAExecutor
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 434
diff changeset
376 struct CUDABuffer {
431
b3359544adbb Edit cudaExec but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 430
diff changeset
377 int inputLen;
b3359544adbb Edit cudaExec but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 430
diff changeset
378 int outputLen;
b3359544adbb Edit cudaExec but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 430
diff changeset
379 union Data** inputData;
b3359544adbb Edit cudaExec but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 430
diff changeset
380 union Data** outputData;
435
af0ec811b20e Add CUDAExecutor
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 434
diff changeset
381 } CUDABuffer;
438
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
382 CUdeviceptr CUdeviceptr;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
383 #else
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
384 struct CUDAExecutor {
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
385 } CUDAExecutor;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
386 struct CUDABuffer {
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
387 } CUDABuffer;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
388 CUdeviceptr CUdeviceptr;
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
389 #endif
7679093bdd72 Work CUDAtwice
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 436
diff changeset
390 Int Int;
447
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
391 struct Memory {
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
392 union Data* adr;
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
393 int length;
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
394 union Data* body;
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
395 int hash;
57132ef16009 Remove ALLOCATE_DATA_GEAR from par goto code gear arguments
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 444
diff changeset
396 } Memory;
254
edb3aff688d0 fix generator CLI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 244
diff changeset
397 }; // union Data end this is necessary for context generator
259
195518ab62fc fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 254
diff changeset
398 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
399
186
dbc064c26b98 generate context script
mir3636
parents: 185
diff changeset
400 #include "c/typedefData.h"
278
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
401
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
402 #include "c/extern.h"
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
403
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
404 extern __code start_code(struct Context* context);
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
405 extern __code exit_code(struct Context* context);
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
406 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
407 extern __code par_meta(struct Context* context, enum Code spawns, enum Code next);
278
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
408 extern void initContext(struct Context* context);
23767f714f4a fix generate_stub
mir3636
parents: 259
diff changeset
409
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
410 #endif