annotate src/parallel_execution/context.h @ 133:568730b1239e

call stack interface in rb_tree
author mir3636
date Mon, 07 Nov 2016 21:12:19 +0900
parents 7c309e1aea73
children 2eccf4564efe
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;\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
15 meta->type = dseg;\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
16 context->heap += sizeof(struct Meta);\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
17 context->data[dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[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;\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
21 meta->type = t;\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
22 context->heap += sizeof(struct Meta);\
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
23 context->data[dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[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); \
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
30 meta->type = t; \
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
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 enum Code {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 Code1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 Code2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 Code3,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 Code4,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 Code5,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 Find,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 Not_find,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 Code6,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 Allocator,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
47 PutTree,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 Replace,
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
49 Replace1,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 Insert,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 Compare,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 RotateL,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 RotateR,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 SetTree,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 InsertCase1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 InsertCase2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 InsertCase3,
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
58 InsertCase31,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 InsertCase4,
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
60 InsertCase4_01,
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
61 InsertCase4_02,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 InsertCase4_1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 InsertCase4_2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 InsertCase5,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 StackClear,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 Get,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 Search,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 Delete,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 Delete1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 Delete2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 Delete3,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 Replace_d1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 Replace_d2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 FindMax1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 FindMax2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 DeleteCase1,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 DeleteCase2,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 DeleteCase3,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 DeleteCase4,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 DeleteCase5,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 DeleteCase6,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 CreateWorker,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 TaskManager,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
84 CreateData1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
85 CreateData2,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
86 CreateTask1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
87 CreateTask2,
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
88 CreateTask3,
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
89 CreateTask4,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
90 PutQueue1,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
91 PutQueue2,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
92 PutQueue3,
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
93 PutQueue4,
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
94 GetQueue,
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
95 PushSingleLinkedStack,
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
96 PopSingleLinkedStack,
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
97 SpawnTask,
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
98 Twice,
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
99 StartTime,
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
100 EndTime,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 Exit,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 enum Relational {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 EQ,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 GT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 LT,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
110 enum DataType {
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 Worker,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 Allocate,
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
113 SingleLinkedStack,
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
114 Stack,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 Tree,
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
116 Traverse,
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 Node,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 LoopCounter,
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
119 Time,
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
120 Element,
87
9e139a340bd1 rename directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
121 ActiveQueue,
109
059b26a250cc Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
122 WaitQueue,
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
123 Queue
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 struct Context {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 enum Code next;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 int codeNum;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 __code (**code) (struct Context*);
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 void* heapStart;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 void* heap;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 long heapLimit;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 pthread_t thread;
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
134 int thread_num;
87
9e139a340bd1 rename directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
135 int dataNum;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 union Data **data;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 };
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
139 struct QueueInterface {
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
140 enum Code put;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
141 enum Code get;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
142 enum Code isEmpty;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
143 };
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
144
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
145 struct StackInterface {
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
146 enum Code push;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
147 enum Code pop;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
148 enum Code isEmpty;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
149 };
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
150
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 union Data {
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
152 struct Meta {
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
153 enum DataType type;
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
154 } meta;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
155 struct Time {
102
64c98838a291 remove stack StartTime&EndTime
ikkun
parents: 101
diff changeset
156 enum Code next;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
157 double time;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
158 } time;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 struct LoopCounter {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 int i;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 } loopCounter;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 struct Worker {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 int num;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 struct Context* contexts;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 } worker;
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
166 #ifdef USE_CUDA
98
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
167 struct CudaTask {
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
168 CUdevice device;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
169 CUcontext cuCtx;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
170 CUfunction code;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
171 CUdeviceptr* deviceptr;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
172 CUstream stream;
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
173 } cudatask;
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
174 #endif
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
175 struct Task {
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
176 enum Code code;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
177 int key;
109
059b26a250cc Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
178 struct Queue* waitMe;
113
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
179 struct Queue* waitI;
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
180 int idsCount;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
181 } task;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
182 struct Queue {
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
183 struct Element* first;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
184 struct Element* last;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
185 int count;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
186 struct QueueInterface* i;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
187 enum Code next;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
188 } queue;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
189 // Stack Interface
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
190 struct Stack {
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
191 union Data* stack;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
192 union Data* data;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
193 union Data* data1;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
194 enum Code push;
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
195 enum Code pop;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
196 enum Code pop2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
197 enum Code isEmpty;
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
198 enum Code whenEmpty;
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
199 enum Code get2;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 124
diff changeset
200 enum Code next;
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
201 } stack;
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
202 // Stack implementations
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
203 struct SingleLinkedStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
204 struct Element* top;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
205 } singleLinekedStack;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
206 struct ArrayStack {
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
207 int size;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
208 int limit;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
209 struct Element* array;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
210 } arrayStack;
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
211 // Stack implementation end
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
212 struct Element {
113
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
213 union Data* data;
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
214 struct Element* next;
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
215 } element;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 struct Array {
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
217 int index;
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
218 int prefix;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 int* array;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 } array;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 struct Tree {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 struct Node* root;
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
223 } tree;
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
224 struct Traverse {
103
6402a33250a6 remove stack from getQueue
ikkun
parents: 102
diff changeset
225 enum Code next;
119
b224aa7b80a0 remove code stack, stack clear is directly called
ikkun
parents: 113
diff changeset
226 enum Code rotateNext;
122
73a679a85c04 node stack rewrite
ikkun
parents: 119
diff changeset
227 struct Node* current; // reading node of original tree
124
36ac17d37be4 Fix compile error but not work
one
parents: 122
diff changeset
228 struct Node* newNode; // writing node of new tree
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
229 struct Stack* nodeStack;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 int result;
91
1e074c3878c7 modify tree
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 90
diff changeset
231 } traverse;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 struct Node {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 int key; // comparable data segment
90
4b5bf5b40970 put queue
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
234 union Data* value;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 struct Node* left;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 struct Node* right;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 // need to balancing
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 enum Color {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 Red,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 Black,
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 } color;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 } node;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 struct Allocate {
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 enum Code next;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 long size;
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 } allocate;
112
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
247 struct OutPutDataSegments {
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
248 union Data **data;
e3cba827d489 Add spawnTask CS
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
249 } ods;
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 };
113
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
251
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
252 union MetaData {
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
253 struct Queue waitMeTasks;
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
254 struct Queue waitI;
d05b9937aa95 Change element data from Task to Data
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 112
diff changeset
255 };
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
256 #endif