annotate src/context.h @ 146:fd166dda4361

tweak return value at file_read.cbc
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Dec 2019 14:15:27 +0900
parents 4f9d95dc4efd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
1 /* Context definition for llrb example */
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
2 // #ifdef CBC_CONTEXT_H does not work well
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
3 #define CBC_CONTEXT_H
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
4 // #include <stdlib.h>
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
5 // #include <pthread.h>
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
6 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
7 #include <cuda.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
8 #include <driver_types.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
9 #include <cuda_runtime.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
10 #include "helper_cuda.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
11 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
12
94
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
13 #ifndef NULL
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
14 # if defined __GNUG__ && \
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
15 (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
16 # define NULL (__null)
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
17 # else
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
18 # if !defined(__cplusplus)
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
19 # define NULL ((void*)0)
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
20 # else
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
21 # define NULL (0)
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
22 # endif
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
23 # endif
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
24 #endif
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
25
62
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
26 #ifdef XV6KERNEL
95
0ddcd561d975 fix make error
tobaru
parents: 94
diff changeset
27 extern void* kmalloc (int order);
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
28 #define calloc(a,b) kmalloc((a)*(b))
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
29 #define free(a) kfree(a)
62
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
30 #else
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
31 #define calloc(a,b) malloc((a)*(b))
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
32 #define free(a) free(a)
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
33 #endif
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
34
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
35 #define ALLOCATE_SIZE 20000000
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
36 #define NEW(type) (type*)(calloc(1, sizeof(type)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
37 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
38
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
39 #define ALLOC_DATA(cbc_context, dseg) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
40 Meta* meta = (Meta*)cbc_context->heap;\
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
41 meta->type = D_##dseg;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
42 meta->size = sizeof(dseg);\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
43 meta->len = 1;\
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
44 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
45 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(dseg); (dseg *)cbc_context->data[D_##dseg]; })
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
46
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
47 #define ALLOC_DATA_TYPE(cbc_context, dseg, t) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
48 Meta* meta = (Meta*)cbc_context->heap;\
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
49 meta->type = D_##t;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
50 meta->size = sizeof(t);\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
51 meta->len = 1;\
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
52 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
53 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(t); (t *)cbc_context->data[D_##dseg]; })
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
54
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
55 #define ALLOCATE(cbc_context, t) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
56 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
57 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
58 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
59 cbc_context->heap += sizeof(t); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
60 meta->type = D_##t; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
61 meta->size = sizeof(t); \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
62 meta->len = 1;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
63 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
64
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
65 #define ALLOCATE_ARRAY(cbc_context, t, length) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
66 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
67 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
68 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
69 cbc_context->heap += sizeof(t)*length; \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
70 meta->type = D_##t; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
71 meta->size = sizeof(t)*length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
72 meta->len = length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
73 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
74
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
75 #define ALLOCATE_PTR_ARRAY(cbc_context, dseg, length) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
76 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
77 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
78 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
79 cbc_context->heap += sizeof(dseg *)*length; \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
80 meta->type = D_##dseg; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
81 meta->size = sizeof(dseg *)*length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
82 meta->len = length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
83 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
84
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
85 #define ALLOCATE_DATA_GEAR(cbc_context, t) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
86 union Data* data = ALLOCATE(cbc_context, t); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
87 Meta* meta = GET_META(data); \
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
88 meta->wait = createSynchronizedQueue(cbc_context); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
89 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
90
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
91 #define ALLOC(cbc_context, t) (&ALLOCATE(cbc_context, t)->t)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
92
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
93 #define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
94 #define GET_TYPE(dseg) (GET_META(dseg)->type)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
95 #define GET_SIZE(dseg) (GET_META(dseg)->size)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
96 #define GET_LEN(dseg) (GET_META(dseg)->len)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
97 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
98
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
99 #define Gearef(cbc_context, t) (&(cbc_context)->data[D_##t]->t)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
100
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
101 // (SingleLinkedStack *)cbc_context->data[D_Stack]->Stack.stack->Stack.stack
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
102
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
103 #define GearImpl(cbc_context, intf, name) (Gearef(cbc_context, intf)->name->intf.name)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
104
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
105 #include "c/enumCode.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
106
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
107 enum Relational {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
108 EQ,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
109 GT,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
110 LT,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
111 };
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
112
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
113 #include "c/enumData.h"
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
114 #define NDIRECT 12 //fs.h
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
115
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
116 struct Context {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
117 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
118 struct Worker* worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
119 struct TaskManager* taskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
120 int codeNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
121 __code (**code) (struct Context*);
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
122 union Data **data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
123 void* heapStart;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
124 void* heap;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
125 long heapLimit;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
126 int dataNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
127
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
128 // task parameter
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
129 int idgCount; //number of waiting dataGear
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
130 int idg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
131 int maxIdg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
132 int odg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
133 int maxOdg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
134 int gpu; // GPU task
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
135 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
136 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
137 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
138 int num_exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
139 CUmodule module;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
140 CUfunction function;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
141 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
142 /* multi dimension parameter */
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
143 int iterate;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
144 struct Iterator* iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
145 enum Code before;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
146 };
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
147
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
148 typedef int Int;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
149 #ifndef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
150 typedef unsigned long long CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
151 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
152 union Data {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
153 struct Meta {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
154 enum DataType type;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
155 long size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
156 long len;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
157 struct Queue* wait; // tasks waiting this dataGear
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
158 } Meta;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
159 struct Context Context;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
160 struct Timer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
161 union Data* timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
162 enum Code start;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
163 enum Code end;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
164 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
165 } Timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
166 struct TimerImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
167 double time;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
168 } TimerImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
169 struct LoopCounter {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
170 int i;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
171 } LoopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
172 struct TaskManager {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
173 union Data* taskManager;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
174 enum Code spawn; // start NEW cbc_context on the worker
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
175 enum Code spawnTasks; // start NEW tasks on the worker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
176 enum Code shutdown;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
177 enum Code incrementTaskCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
178 enum Code decrementTaskCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
179 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
180 enum Code next1;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
181 enum Code setWaitTask;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
182 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
183 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
184 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
185 } TaskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
186 struct TaskManagerImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
187 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
188 int numWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
189 int sendCPUWorkerIndex;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
190 int sendGPUWorkerIndex;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
191 int taskCount;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
192 // pthread_mutex_t mutex;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
193 struct Queue* activeQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
194 struct Worker** workers;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
195 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
196 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
197 int cpu;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
198 int gpu;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
199 int io;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
200 int maxCPU;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
201 } TaskManagerImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
202 struct Worker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
203 union Data* worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
204 enum Code taskReceive;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
205 enum Code shutdown;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
206 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
207 struct Queue* tasks;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
208 // pthread_t thread;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
209 struct TaskManager* taskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
210 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
211 } Worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
212 struct CPUWorker {
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
213 // pthread_mutex_t mutex;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
214 // pthread_cond_t cond;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
215 struct Context* cbc_context;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
216 int id;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
217 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
218 } CPUWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
219 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
220 struct CUDAWorker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
221 CUdevice device;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
222 CUcbc_context cuCtx;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
223 struct Context* cbc_context;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
224 int id;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
225 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
226 int deviceNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
227 struct Queue* tasks;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
228 int runFlag;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
229 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
230 int numStream;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
231 struct Executor* executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
232 CUstream *stream;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
233 } CUDAWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
234 #else
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
235 struct CUDAWorker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
236 } CUDAWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
237 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
238 struct Main {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
239 enum Code code;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
240 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
241 struct Queue* args;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
242 } Main;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
243 // Queue Interface
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
244 struct Queue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
245 union Data* queue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
246 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
247 enum Code whenEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
248 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
249 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
250 enum Code take;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
251 enum Code isEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
252 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
253 } Queue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
254 struct SingleLinkedQueue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
255 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
256 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
257 } SingleLinkedQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
258 struct SynchronizedQueue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
259 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
260 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
261 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
262 } SynchronizedQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
263 // Stack Interface
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
264 struct Stack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
265 union Data* stack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
266 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
267 union Data* data1;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
268 enum Code whenEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
269 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
270 enum Code push;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
271 enum Code pop;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
272 enum Code pop2;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
273 enum Code isEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
274 enum Code get;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
275 enum Code get2;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
276 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
277 } Stack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
278 // Stack implementations
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
279 struct SingleLinkedStack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
280 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
281 } SingleLinkedStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
282 struct ArrayStack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
283 int size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
284 int limit;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
285 struct Element* array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
286 } ArrayStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
287 // Stack implementation end
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
288 struct Element {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
289 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
290 struct Element* next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
291 } Element;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
292 struct Array {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
293 int prefix;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
294 Int* array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
295 } Array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
296 struct Tree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
297 union Data* tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
298 struct Node* node;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
299 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
300 enum Code get;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
301 enum Code remove;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
302 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
303 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
304 } Tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
305 struct RedBlackTree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
306 struct Node* root;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
307 struct Node* current; // reading node of original tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
308 struct Node* previous; // parent of reading node of original tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
309 struct Node* newNode; // writing node of new tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
310 struct Node* parent;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
311 struct Node* grandparent;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
312 struct Stack* nodeStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
313 enum Code findNodeNext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
314 int result;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
315 } RedBlackTree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
316 struct RotateTree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
317 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
318 struct RedBlackTree* traverse;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
319 struct Tree* tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
320 } RotateTree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
321 struct Node {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
322 int key; // comparable data segment
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
323 union Data* value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
324 struct Node* left;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
325 struct Node* right;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
326 // need to balancing
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
327 enum Color {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
328 Red,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
329 Black,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
330 // Red eq 0,Black eq 1. enum name convert intager.
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
331 } color;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
332 } Node;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
333 struct Atomic {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
334 union Data* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
335 union Data** ptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
336 union Data* oldData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
337 union Data* newData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
338 enum Code checkAndSet;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
339 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
340 enum Code fail;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
341 } Atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
342 struct AtomicReference {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
343 } AtomicReference;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
344 struct Semaphore {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
345 union Data* semaphore;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
346 enum Code p;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
347 enum Code v;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
348 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
349 } Semaphore;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
350 struct SemaphoreImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
351 int value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
352 struct Lock* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
353 struct Queue* waitThreadQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
354 } SemaphoreImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
355 struct Allocate {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
356 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
357 long size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
358 } Allocate;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
359 struct Integer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
360 int value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
361 } Integer;
92
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
362 struct UInteger {
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
363 unsigned int value;
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
364 } UInteger;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
365 struct SortArray {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
366 struct Integer *array; //Array arrayじゃできない?
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
367 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
368 int block;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
369 int first;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
370 int prefix;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
371 } SortArray;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
372 struct Iterator {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
373 union Data* iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
374 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
375 int numGPU;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
376 enum Code exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
377 enum Code barrier;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
378 enum Code whenWait;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
379 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
380 } Iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
381 struct MultiDimIterator {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
382 int x;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
383 int y;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
384 int z;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
385 int count;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
386 int counterX;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
387 int counterY;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
388 int counterZ;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
389 } MultiDimIterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
390 struct MultiDim {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
391 int x;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
392 int y;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
393 int z;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
394 } MultiDim;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
395 struct Executor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
396 union Data* executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
397 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
398 enum Code read;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
399 enum Code exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
400 enum Code write;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
401 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
402 } Executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
403 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
404 struct CUDAExecutor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
405 CUdeviceptr** kernelParams;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
406 struct CUDABuffer* buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
407 int maxThreadPerBlock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
408 int maxThreadPerBlockX;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
409 int maxThreadPerBlockY;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
410 int maxThreadPerBlockZ;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
411 struct Timer* timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
412 } CUDAExecutor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
413 struct CUDABuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
414 int inputLen;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
415 int outputLen;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
416 union Data** inputData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
417 union Data** outputData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
418 } CUDABuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
419 CUdeviceptr CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
420 #else
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
421 struct CUDAExecutor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
422 } CUDAExecutor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
423 struct CUDABuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
424 } CUDABuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
425 CUdeviceptr CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
426 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
427 Int Int;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
428 struct Memory {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
429 union Data* adr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
430 int length;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
431 union Data* body;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
432 int hash;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
433 } Memory;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
434 struct Buffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
435 union Data* buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
436 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
437 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
438 enum Code take;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
439 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
440 } Buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
441 struct BoundedBuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
442 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
443 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
444 struct Semaphore* fullCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
445 struct Semaphore* emptyCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
446 struct Semaphore* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
447 } BoundedBuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
448 struct Lock {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
449 union Data* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
450 enum Code doLock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
451 enum Code doUnlock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
452 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
453 } Lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
454 struct LockImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
455 Int* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
456 struct Queue* waitThreadQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
457 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
458 struct Context* lockContext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
459 } LockImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
460 struct SpinLock {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
461 volatile Int* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
462 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
463 struct Context* lockContext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
464 } SpinLock;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
465 /* CbCxv6 cbc_context*/
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
466 struct Uinteger {
94
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
467 unsigned int value;
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
468 } Uinteger;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
469 struct Short {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
470 short value;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
471 } Short;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
472 struct String {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
473 char* string;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
474 } String;
96
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
475 struct CbCPipe {
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
476 struct pipe *p;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
477 } CbCPipe;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
478 struct PipeRead {
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
479 struct CbCPipe *pipe;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
480 struct String *addr;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
481 struct Integer* i;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
482 } PipeRead;
106
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
483 struct SysRead {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
484 union Data* sys_read;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
485 struct UInteger* num;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
486 int n;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
487 struct String *p;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
488 enum Code read;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
489 enum Code next;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
490 } SysRead;
109
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
491 struct FileRead {
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
492 struct file *f;
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
493 } FileRead;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
494 }; // union Data end this is necessary for cbc_context generator
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
495
96
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
496 /*
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
497 struct cbc_console_arg {
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
498 int n;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
499 int target;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
500 char* dst;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
501 struct inode *ip;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
502 struct file *f;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
503 int num;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
504 struct pipe *p;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
505 char *addr;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
506 int i;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
507 __code (*next)(int ret);
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
508 } cbc_console_arg;
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
509 */
d5c4016c65b8 implement read interfacce
anatofuz
parents: 95
diff changeset
510
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
511 typedef union Data Data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
512
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
513 #include "c/typedefData.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
514
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
515 #include "c/extern.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
516
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
517 extern __code start_code(struct Context* cbc_context);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
518 extern __code exit_code(struct Context* cbc_context);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
519 extern __code meta(struct Context* cbc_context, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
520 //extern __code par_meta(struct Context* cbc_context, enum Code spawns, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
521 extern __code parGotoMeta(struct Context* cbc_context, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
522 extern void initContext(struct Context* cbc_context);
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
523
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
524 // #endif