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