annotate src/gearsTools/lib/Gears/Context/Template/XV6.pm @ 163:620a6abe2259 default tip

temporary_fix_use_pipe.h_at_pipe.cbc
author anatofuz
date Mon, 23 Dec 2019 08:35:53 +0900
parents db7d79dea533
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package Gears::Context::Template::XV6;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 use strict;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 use warnings;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 sub emit_top_header {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 my ($class, $out) = @_;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 my $str = << 'EOFEOF';
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 /* Context definition for llrb example */
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 // #ifdef CBC_CONTEXT_H does not work well
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #define CBC_CONTEXT_H
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // #include <stdlib.h>
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 // #include <pthread.h>
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #ifdef USE_CUDAWorker
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include <cuda.h>
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include <driver_types.h>
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include <cuda_runtime.h>
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #include "helper_cuda.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #ifndef NULL
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 # if defined __GNUG__ && \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 # define NULL (__null)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 # else
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 # if !defined(__cplusplus)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 # define NULL ((void*)0)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 # else
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 # define NULL (0)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 # endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 # endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #ifdef XV6KERNEL
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 extern void* kmalloc (int order);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #define calloc(a,b) kmalloc((a)*(b))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #define free(a) kfree(a)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #else
160
db7d79dea533 include usr.h and types.h in XV6.pm
tobaru
parents: 150
diff changeset
38 #include "types.h"
db7d79dea533 include usr.h and types.h in XV6.pm
tobaru
parents: 150
diff changeset
39 #include "user.h"
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #define calloc(a,b) malloc((a)*(b))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #define free(a) free(a)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 #define ALLOCATE_SIZE 20000000
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #define NEW(type) (type*)(calloc(1, sizeof(type)))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 #define ALLOC_DATA(cbc_context, dseg) ({\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 meta->type = D_##dseg;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 meta->size = sizeof(dseg);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(dseg); (dseg *)cbc_context->data[D_##dseg]; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #define ALLOC_DATA_TYPE(cbc_context, dseg, t) ({\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 meta->type = D_##t;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 meta->size = sizeof(t);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(t); (t *)cbc_context->data[D_##dseg]; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 #define ALLOCATE(cbc_context, t) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 cbc_context->heap += sizeof(t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 meta->type = D_##t; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 meta->size = sizeof(t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 #define ALLOCATE_ARRAY(cbc_context, t, length) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 cbc_context->heap += sizeof(t)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 meta->type = D_##t; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 meta->size = sizeof(t)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 meta->len = length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 #define ALLOCATE_PTR_ARRAY(cbc_context, dseg, length) ({\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 cbc_context->heap += sizeof(dseg *)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 meta->type = D_##dseg; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 meta->size = sizeof(dseg *)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 meta->len = length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 #define ALLOCATE_DATA_GEAR(cbc_context, t) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 union Data* data = ALLOCATE(cbc_context, t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 Meta* meta = GET_META(data); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 meta->wait = createSynchronizedQueue(cbc_context); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 #define ALLOC(cbc_context, t) (&ALLOCATE(cbc_context, t)->t)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 #define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 #define GET_TYPE(dseg) (GET_META(dseg)->type)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 #define GET_SIZE(dseg) (GET_META(dseg)->size)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 #define GET_LEN(dseg) (GET_META(dseg)->len)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 #define Gearef(cbc_context, t) (&(cbc_context)->data[D_##t]->t)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 // (SingleLinkedStack *)cbc_context->data[D_Stack]->Stack.stack->Stack.stack
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 #define GearImpl(cbc_context, intf, name) (Gearef(cbc_context, intf)->name->intf.name)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
114 #ifndef CBC_XV6_CONTEXT
150
124c59d99fc9 un_using_context.h_at_src_dir
anatofuz
parents: 149
diff changeset
115 #define CBC_XV6_CONTEXT TRUE
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
116
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 #include "c/enumCode.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
119 #include "types.h"
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
120
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 enum Relational {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 EQ,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 GT,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 LT,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 };
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 #include "c/enumData.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 #define NDIRECT 12 //fs.h
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
130
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 struct Context {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 enum Code next;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 struct Worker* worker;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 struct TaskManager* taskManager;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 int codeNum;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 __code (**code) (struct Context*);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 union Data **data;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 void* heapStart;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 void* heap;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 long heapLimit;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 int dataNum;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 // task parameter
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 int idgCount; //number of waiting dataGear
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 int idg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 int maxIdg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 int odg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 int maxOdg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 int gpu; // GPU task
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 struct Context* task;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 struct Element* taskList;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 #ifdef USE_CUDAWorker
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 int num_exec;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 CUmodule module;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 CUfunction function;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 /* multi dimension parameter */
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 int iterate;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 struct Iterator* iterator;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 enum Code before;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 };
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 typedef int Int;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 #ifndef USE_CUDAWorker
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 typedef unsigned long long CUdeviceptr;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 EOFEOF
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 print $out $str;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 }
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 sub emit_data_gears {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 my ($class, $out, $dgs) = @_;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 print $out "union Data {\n";
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 print $out $dgs;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 print $out <<'EOF';
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 struct Context Context;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 }; // union Data end this is necessary for context generator
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 typedef union Data Data;
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
180 #endif
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 EOF
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 }
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 sub emit_last_header {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 my($class, $out) = @_;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 print $out <<'EOF';
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
188
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
189
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
190
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 #include "c/typedefData.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 #include "c/extern.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 extern __code start_code(struct Context* cbc_context);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 extern __code exit_code(struct Context* cbc_context);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 extern __code meta(struct Context* cbc_context, enum Code next);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 //extern __code par_meta(struct Context* cbc_context, enum Code spawns, enum Code next);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 extern __code parGotoMeta(struct Context* cbc_context, enum Code next);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 extern void initContext(struct Context* cbc_context);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 // #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 EOF
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 }
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 1;