annotate src/parallel_execution/context.h @ 166:06cfc1289361

fix
author mir3636
date Fri, 18 Nov 2016 19:34:44 +0900
parents 1115367f03a4
children 34562e63981f
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
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <pthread.h>
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
5 #ifdef USE_CUDA
98
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
6 #include <cuda.h>
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
7 #endif
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
9 #define ALLOCATE_SIZE 20000000
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
10 #define NEW(type) (type*)(calloc(1, sizeof(type)))
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
11 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
12
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
13 #define ALLOC_DATA(context, dseg) ({\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
14 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
15 meta->type = D_##dseg;\
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
16 context->heap += sizeof(struct Meta);\
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
17 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; })
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
18
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
19 #define ALLOC_DATA_TYPE(context, dseg, t) ({\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
20 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
21 meta->type = D_##t;\
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
22 context->heap += sizeof(struct Meta);\
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
23 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; })
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
25 #define ALLOCATE(context, t) ({ \
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
26 struct Meta* meta = (struct Meta*)context->heap;\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
27 context->heap += sizeof(struct Meta);\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
28 union Data* data = context->heap; \
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
29 context->heap += sizeof(struct t); \
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
30 meta->type = D_##t; \
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
31 data; })
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
32
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
33 #define GET_TYPE(dseg) ({ \
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
34 struct Meta* meta = (struct Meta*)(((void*)dseg) - sizeof(struct Meta));\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
35 meta->type; })
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
36
149
63ab65b28466 Add Gearef macro
one
parents: 148
diff changeset
37 #define Gearef(context, t) (&(context)->data[D_##t]->t)
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 enum Code {
144
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
39 C_code1,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
40 C_code2,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
41 C_code3,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
42 C_code4,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
43 C_code5,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
44 C_find,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 Not_find,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 Code6,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 Allocator,
144
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
48 C_put,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
49 C_replaceNode,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
50 C_replaceNode1,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
51 C_insertNode,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 Compare,
144
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
53 C_rotateLeft,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
54 C_rotateLeft1,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
55 C_rotateRight,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
56 C_rotateRight1,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 SetTree,
144
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
58 C_insertCase1,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
59 C_insertCase2,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
60 C_insertCase3,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
61 C_insertCase4,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
62 C_insertCase5,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
63 C_insertCase51,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
64 C_stackClear,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
65 C_get,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
66 C_search,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 Delete,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 Delete1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 Delete2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 Delete3,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 Replace_d1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 Replace_d2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 FindMax1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 FindMax2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 DeleteCase1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 DeleteCase2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 DeleteCase3,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 DeleteCase4,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 DeleteCase5,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 DeleteCase6,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 CreateWorker,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 TaskManager,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
83 CreateData1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
84 CreateData2,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
85 CreateTask1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
86 CreateTask2,
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
87 CreateTask3,
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
88 CreateTask4,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
89 PutQueue1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
90 PutQueue2,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
91 PutQueue3,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
92 PutQueue4,
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
93 GetQueue,
145
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
94 C_clearSingleLinkedStack,
144
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
95 C_pushSingleLinkedStack,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
96 C_popSingleLinkedStack,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
97 C_pop2SingleLinkedStack,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
98 C_getSingleLinkedStack,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
99 C_get2SingleLinkedStack,
d529c024e5a5 name fixes
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 143
diff changeset
100 C_isEmptySingleLinkedStack,
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
101 SpawnTask,
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
102 Twice,
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
103 StartTime,
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
104 EndTime,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 Exit,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 enum Relational {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 EQ,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 GT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 LT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
114 enum DataType {
148
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
115 D_Worker,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
116 D_Allocate,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
117 D_SingleLinkedStack,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
118 D_Stack,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
119 D_Tree,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
120 D_Traverse,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
121 D_RotateTree,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
122 D_Node,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
123 D_LoopCounter,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
124 D_Time,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
125 D_Element,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
126 D_ActiveQueue,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
127 D_WaitQueue,
473b7d990a1f fix data gears type enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 147
diff changeset
128 D_Queue
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 struct Context {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 enum Code next;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 int codeNum;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 __code (**code) (struct Context*);
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 void* heapStart;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 void* heap;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 long heapLimit;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 pthread_t thread;
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
139 int thread_num;
87
9e139a340bd1 rename directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
140 int dataNum;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 union Data **data;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 union Data {
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
145 struct Meta {
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
146 enum DataType type;
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
147 } meta;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
148 struct Time {
102
64c98838a291 remove stack StartTime&EndTime
ikkun
parents: 101
diff changeset
149 enum Code next;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
150 double time;
149
63ab65b28466 Add Gearef macro
one
parents: 148
diff changeset
151 } Time;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 struct LoopCounter {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 int i;
166
mir3636
parents: 153
diff changeset
154 struct Tree* tree;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 } loopCounter;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 struct Worker {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 int num;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 struct Context* contexts;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 } worker;
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
160 #ifdef USE_CUDA
98
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
161 struct CudaTask {
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
162 CUdevice device;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
163 CUcontext cuCtx;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
164 CUfunction code;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
165 CUdeviceptr* deviceptr;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
166 CUstream stream;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
167 } cudatask;
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
168 #endif
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
169 struct Task {
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
170 enum Code code;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
171 int key;
109
059b26a250cc Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
172 struct Queue* waitMe;
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
173 struct Queue* waitI;
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
174 int idsCount;
166
mir3636
parents: 153
diff changeset
175 } Task;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
176 struct Queue {
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
177 struct Element* first;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
178 struct Element* last;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
179 int count;
136
a747dc9d4da6 stack refactering no compile error
mir3636
parents: 135
diff changeset
180 union Data* queue;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
181 enum Code next;
166
mir3636
parents: 153
diff changeset
182 } Queue;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
183 // Stack Interface
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
184 struct Stack {
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
185 union Data* stack;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
186 union Data* data;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
187 union Data* data1;
145
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
188 enum Code whenEmpty;
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
189
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
190 enum Code clear;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
191 enum Code push;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
192 enum Code pop;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
193 enum Code pop2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
194 enum Code isEmpty;
134
2eccf4564efe fix stack call in rb_tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 133
diff changeset
195 enum Code get;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
196 enum Code get2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
197 enum Code next;
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
198 } stack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
199 // Stack implementations
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
200 struct SingleLinkedStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
201 struct Element* top;
135
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
202 } singleLinkedStack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
203 struct ArrayStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
204 int size;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
205 int limit;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
206 struct Element* array;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
207 } arrayStack;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
208 // Stack implementation end
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
209 struct Element {
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
210 union Data* data;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
211 struct Element* next;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
212 } element;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 struct Array {
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
214 int index;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
215 int prefix;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 int* array;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 } array;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 struct Tree {
166
mir3636
parents: 153
diff changeset
219 union Data* tree;
mir3636
parents: 153
diff changeset
220 struct Node* node;
150
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
221 enum Code put;
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
222 enum Code get;
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
223 enum Code remove;
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
224 enum Code next;
166
mir3636
parents: 153
diff changeset
225 } Tree;
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
226 struct Traverse {
150
7164f59660d4 create .cbc
mir3636
parents: 149
diff changeset
227 struct Node* root;
122
73a679a85c04 node stack rewrite
ikkun
parents: 119
diff changeset
228 struct Node* current; // reading node of original tree
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
229 struct Node* previous; // parent of reading node of original tree
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
230 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
231 struct Node* parent;
34a7a21edc36 recude stack get using traverse field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 138
diff changeset
232 struct Node* grandparent;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
233 struct Stack* nodeStack;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 int result;
149
63ab65b28466 Add Gearef macro
one
parents: 148
diff changeset
235 } Traverse;
147
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
236 struct RotateTree {
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
237 enum Code next;
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
238 struct Traverse* traverse;
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
239 struct Tree* tree;
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
240 } rotateTree;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 struct Node {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 int key; // comparable data segment
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
243 union Data* value;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 struct Node* left;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 struct Node* right;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 // need to balancing
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 enum Color {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 Red,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 Black,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 } color;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 } node;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 struct Allocate {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 enum Code next;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 long size;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 } allocate;
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
256 struct OutPutDataSegments {
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
257 union Data **data;
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
258 } ods;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 };
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
260
147
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
261 // typedef struct RotateTree D_RotateTree;
149
63ab65b28466 Add Gearef macro
one
parents: 148
diff changeset
262 typedef struct Time Time;
151
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
263 typedef struct LoopCounter LoopCounter;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
264 typedef struct Worker Worker;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
265 typedef struct CudaTask CudaTask;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
266 typedef struct Task Task;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
267 typedef struct Queue Queue;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
268 typedef struct Stack Stack;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
269 typedef struct SingleLinkedStack SingleLinkedStack;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
270 typedef struct ArrayStack ArrayStack;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
271 typedef struct Element Element;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
272 typedef struct Array Array;
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
273 typedef struct Tree Tree;
152
5c4922962497 Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 151
diff changeset
274 typedef struct Traverse Traverse;
5c4922962497 Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 151
diff changeset
275 typedef struct RotateTree RotateTree;
5c4922962497 Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 151
diff changeset
276 typedef struct Node Node;
5c4922962497 Fix error
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 151
diff changeset
277 typedef struct Allocate Allocate;
151
8c687b8fabf2 Add typedef to define Code Gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
278 typedef struct OutputDataSegments OutputDataSegments;
147
f2275f5777f4 add treeRotate data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 145
diff changeset
279
114
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
280 union MetaData {
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
281 struct Queue waitMeTasks;
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
282 struct Queue waitI;
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
283 };
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
284 #endif