comparison src/parallel_execution/context.h @ 430:35b37fe8d3a7

Add size member in struct Meta
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 09 Oct 2017 17:46:42 +0900
parents 54352ed97f34
children b3359544adbb
comparison
equal deleted inserted replaced
429:54352ed97f34 430:35b37fe8d3a7
12 #define NEWN(n, type) (type*)(calloc(n, sizeof(type))) 12 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
13 13
14 #define ALLOC_DATA(context, dseg) ({\ 14 #define ALLOC_DATA(context, dseg) ({\
15 struct Meta* meta = (struct Meta*)context->heap;\ 15 struct Meta* meta = (struct Meta*)context->heap;\
16 meta->type = D_##dseg;\ 16 meta->type = D_##dseg;\
17 meta->size = 1;\ 17 meta->size = sizeof(struct dseg);\
18 meta->len = 1;\
18 context->heap += sizeof(struct Meta);\ 19 context->heap += sizeof(struct Meta);\
19 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; }) 20 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; })
20 21
21 #define ALLOC_DATA_TYPE(context, dseg, t) ({\ 22 #define ALLOC_DATA_TYPE(context, dseg, t) ({\
22 struct Meta* meta = (struct Meta*)context->heap;\ 23 struct Meta* meta = (struct Meta*)context->heap;\
23 meta->type = D_##t;\ 24 meta->type = D_##t;\
24 meta->size = 1;\ 25 meta->size = sizeof(struct t);\
26 meta->len = 1;\
25 context->heap += sizeof(struct Meta);\ 27 context->heap += sizeof(struct Meta);\
26 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; }) 28 context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; })
27 29
28 #define ALLOCATE(context, t) ({ \ 30 #define ALLOCATE(context, t) ({ \
29 struct Meta* meta = (struct Meta*)context->heap;\ 31 struct Meta* meta = (struct Meta*)context->heap;\
30 context->heap += sizeof(struct Meta);\ 32 context->heap += sizeof(struct Meta);\
31 union Data* data = context->heap; \ 33 union Data* data = context->heap; \
32 context->heap += sizeof(struct t); \ 34 context->heap += sizeof(struct t); \
33 meta->type = D_##t; \ 35 meta->type = D_##t; \
34 meta->size = 1; \ 36 meta->size = sizeof(struct t); \
37 meta->len = 1;\
35 data; }) 38 data; })
36 39
37 #define ALLOCATE_ARRAY(context, t, len) ({ \ 40 #define ALLOCATE_ARRAY(context, t, length) ({ \
38 struct Meta* meta = (struct Meta*)context->heap;\ 41 struct Meta* meta = (struct Meta*)context->heap;\
39 context->heap += sizeof(struct Meta);\ 42 context->heap += sizeof(struct Meta);\
40 union Data* data = context->heap; \ 43 union Data* data = context->heap; \
41 context->heap += sizeof(struct t)*len; \ 44 context->heap += sizeof(struct t)*length; \
42 meta->type = D_##t; \ 45 meta->type = D_##t; \
43 meta->size = len; \ 46 meta->size = sizeof(struct t)*length; \
47 meta->len = length; \
44 data; }) 48 data; })
45 49
46 #define ALLOC(context, t) (&ALLOCATE(context, t)->t) 50 #define ALLOCATE_PTR_ARRAY(context, dseg, length) ({\
47
48 #define ALLOCATE_PTR_ARRAY(context, dseg, len) ({\
49 struct Meta* meta = (struct Meta*)context->heap;\ 51 struct Meta* meta = (struct Meta*)context->heap;\
50 context->heap += sizeof(struct Meta);\ 52 context->heap += sizeof(struct Meta);\
51 union Data* data = context->heap; \ 53 union Data* data = context->heap; \
52 context->heap += sizeof(struct dseg *)*len; \ 54 context->heap += sizeof(struct dseg *)*length; \
53 meta->type = D_##dseg; \ 55 meta->type = D_##dseg; \
54 meta->size = len; \ 56 meta->size = sizeof(struct dseg *)*length; \
57 meta->len = length; \
55 data; }) 58 data; })
56 59
57 #define ALLOCATE_DATA_GEAR(context, t) ({ \ 60 #define ALLOCATE_DATA_GEAR(context, t) ({ \
58 union Data* data = ALLOCATE(context, t); \ 61 union Data* data = ALLOCATE(context, t); \
59 struct Meta* meta = GET_META(data); \ 62 struct Meta* meta = GET_META(data); \
60 meta->wait = createSingleLinkedQueue(context); \ 63 meta->wait = createSingleLinkedQueue(context); \
61 data; }) 64 data; })
62 65
66 #define ALLOC(context, t) (&ALLOCATE(context, t)->t)
67
63 #define GET_META(dseg) ((struct Meta*)(((void*)dseg) - sizeof(struct Meta))) 68 #define GET_META(dseg) ((struct Meta*)(((void*)dseg) - sizeof(struct Meta)))
64 #define GET_TYPE(dseg) (GET_META(dseg)->type) 69 #define GET_TYPE(dseg) (GET_META(dseg)->type)
65 #define GET_SIZE(dseg) (GET_META(dseg)->size) 70 #define GET_SIZE(dseg) (GET_META(dseg)->size)
71 #define GET_LEN(dseg) (GET_META(dseg)->len)
66 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait) 72 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
67 73
68 #define Gearef(context, t) (&(context)->data[D_##t]->t) 74 #define Gearef(context, t) (&(context)->data[D_##t]->t)
69 75
70 // (struct SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack 76 // (struct SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
114 120
115 union Data { 121 union Data {
116 struct Meta { 122 struct Meta {
117 enum DataType type; 123 enum DataType type;
118 long size; 124 long size;
125 long len;
119 struct Queue* wait; // tasks waiting this dataGear 126 struct Queue* wait; // tasks waiting this dataGear
120 } meta; 127 } meta;
121 struct Context Context; 128 struct Context Context;
122 struct Time { 129 struct Time {
123 union Data* time; 130 union Data* time;