annotate src/gearsTools/lib/Gears/Context/Template/XV6.pm @ 175:de3934dd522a

merge
author anatofuz
date Fri, 17 Jan 2020 14:37:26 +0900
parents 7c200a8328fa b948cf7a881d
children 429f0c3cc097
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
173
7c200a8328fa fix user malloc and spinlock redefinition
kono
parents: 150
diff changeset
38 extern void* malloc(unsigned int sz);
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #define calloc(a,b) malloc((a)*(b))
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #define free(a) free(a)
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #define ALLOCATE_SIZE 20000000
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 #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
45 #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
46
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 #define ALLOC_DATA(cbc_context, dseg) ({\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 meta->type = D_##dseg;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 meta->size = sizeof(dseg);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 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
54
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 #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
56 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 meta->type = D_##t;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 meta->size = sizeof(t);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 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
62
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 #define ALLOCATE(cbc_context, t) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 cbc_context->heap += sizeof(t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 meta->type = D_##t; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 meta->size = sizeof(t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 meta->len = 1;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 #define ALLOCATE_ARRAY(cbc_context, t, length) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 cbc_context->heap += sizeof(t)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 meta->type = D_##t; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 meta->size = sizeof(t)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 meta->len = length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 #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
84 Meta* meta = (Meta*)cbc_context->heap;\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 cbc_context->heap += sizeof(Meta);\
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 union Data* data = cbc_context->heap; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 cbc_context->heap += sizeof(dseg *)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 meta->type = D_##dseg; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 meta->size = sizeof(dseg *)*length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 meta->len = length; \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 #define ALLOCATE_DATA_GEAR(cbc_context, t) ({ \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 union Data* data = ALLOCATE(cbc_context, t); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 Meta* meta = GET_META(data); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 meta->wait = createSynchronizedQueue(cbc_context); \
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 data; })
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 #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
100
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 #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
102 #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
103 #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
104 #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
105 #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
106
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 #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
108
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 // (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
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 #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
112
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 #include "c/enumCode.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
115 #include "types.h"
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 enum Relational {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 EQ,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 GT,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 LT,
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 };
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 #include "c/enumData.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 #define NDIRECT 12 //fs.h
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
126
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 struct Context {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 enum Code next;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 struct Worker* worker;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 struct TaskManager* taskManager;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 int codeNum;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 __code (**code) (struct Context*);
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 union Data **data;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 void* heapStart;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 void* heap;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 long heapLimit;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 int dataNum;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 // task parameter
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 int idgCount; //number of waiting dataGear
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 int idg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 int maxIdg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 int odg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 int maxOdg;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 int gpu; // GPU task
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 struct Context* task;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 struct Element* taskList;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 #ifdef USE_CUDAWorker
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 int num_exec;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 CUmodule module;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 CUfunction function;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 /* multi dimension parameter */
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 int iterate;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 struct Iterator* iterator;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 enum Code before;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 };
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
173
7c200a8328fa fix user malloc and spinlock redefinition
kono
parents: 150
diff changeset
159 #include "spinlock.h"
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 typedef int Int;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 #ifndef USE_CUDAWorker
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 typedef unsigned long long CUdeviceptr;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 #endif
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 EOFEOF
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 print $out $str;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 }
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 sub emit_data_gears {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 my ($class, $out, $dgs) = @_;
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 print $out "union Data {\n";
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 print $out $dgs;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 print $out <<'EOF';
173
7c200a8328fa fix user malloc and spinlock redefinition
kono
parents: 150
diff changeset
174
7c200a8328fa fix user malloc and spinlock redefinition
kono
parents: 150
diff changeset
175 #ifndef CbC_XV6_CONTEXT
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 struct Context Context;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 }; // 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
178 typedef union Data Data;
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
179 #endif
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 EOF
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 }
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 sub emit_last_header {
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 my($class, $out) = @_;
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 print $out <<'EOF';
149
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
187
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
188
654f2dadd744 add inode.h
menikon
parents: 110
diff changeset
189
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 #include "c/typedefData.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 #include "c/extern.h"
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
173
7c200a8328fa fix user malloc and spinlock redefinition
kono
parents: 150
diff changeset
194 #define CbC_XV6_CONTEXT 1
110
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;