Mercurial > hg > Gears > GearsAgda
changeset 149:63ab65b28466
Add Gearef macro
author | one |
---|---|
date | Thu, 10 Nov 2016 20:37:52 +0900 |
parents | 473b7d990a1f |
children | 7164f59660d4 8c687b8fabf2 |
files | src/parallel_execution/context.h src/parallel_execution/main.c src/parallel_execution/rb_tree.c src/parallel_execution/time.c src/parallel_execution/worker.c |
diffstat | 5 files changed, 29 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.h Thu Nov 10 12:07:53 2016 +0900 +++ b/src/parallel_execution/context.h Thu Nov 10 20:37:52 2016 +0900 @@ -34,6 +34,7 @@ struct Meta* meta = (struct Meta*)(((void*)dseg) - sizeof(struct Meta));\ meta->type; }) +#define Gearef(context, t) (&(context)->data[D_##t]->t) enum Code { C_code1, C_code2, @@ -147,7 +148,7 @@ struct Time { enum Code next; double time; - } time; + } Time; struct LoopCounter { int i; } loopCounter; @@ -225,7 +226,7 @@ struct Node* grandparent; struct Stack* nodeStack; int result; - } traverse; + } Traverse; struct RotateTree { enum Code next; struct Traverse* traverse; @@ -252,6 +253,7 @@ }; // typedef struct RotateTree D_RotateTree; +typedef struct Time Time; union MetaData { struct Queue waitMeTasks;
--- a/src/parallel_execution/main.c Thu Nov 10 12:07:53 2016 +0900 +++ b/src/parallel_execution/main.c Thu Nov 10 20:37:52 2016 +0900 @@ -40,7 +40,7 @@ context->next = CreateWorker; - struct Time *t = &context->data[D_Time]->time; + struct Time *t = &context->data[D_Time]->Time; t->next = CreateWorker; goto meta(context, StartTime); } @@ -320,7 +320,7 @@ loopCounter->i = 0; - struct Time *t = &context->data[D_Time]->time; + Time *t = &context->data[D_Time]->Time; t->next = C_code2; goto meta(context, EndTime); }
--- a/src/parallel_execution/rb_tree.c Thu Nov 10 12:07:53 2016 +0900 +++ b/src/parallel_execution/rb_tree.c Thu Nov 10 20:37:52 2016 +0900 @@ -43,7 +43,7 @@ &context->data[D_Stack]->stack, &context->data[D_Tree]->tree, &context->data[D_Node]->node, - &context->data[D_Traverse]->traverse, + &context->data[D_Traverse]->Traverse, context->data[D_Tree]->tree.root, newNode ); @@ -60,9 +60,10 @@ __code replaceNode_stub(struct Context* context) { goto replaceNode(context, - &context->data[D_Traverse]->traverse, - context->data[D_Traverse]->traverse.current, - context->data[D_Traverse]->traverse.newNode, + &context->data[D_Traverse]->Traverse, + context->data[D_Traverse]->Traverse.current, + //context->data[D_Traverse]->Traverse.newNode, + Gearef(context, Traverse)->newNode, &context->data[D_Stack]->stack); } @@ -90,12 +91,12 @@ __code replaceNode1_stub(struct Context* context) { struct Node* newnewNode = &ALLOCATE(context, Node)->node; goto replaceNode1(context, - &context->data[D_Traverse]->traverse, + &context->data[D_Traverse]->Traverse, &context->data[D_Node]->node, - context->data[D_Traverse]->traverse.current, - context->data[D_Traverse]->traverse.previous, + context->data[D_Traverse]->Traverse.current, + context->data[D_Traverse]->Traverse.previous, newnewNode, - context->data[D_Traverse]->traverse.result); + context->data[D_Traverse]->Traverse.result); } __code insertNode(struct Context* context, struct Traverse* traverse, struct Stack *nodeStack, struct Node* node, struct Node* newNode) { @@ -109,10 +110,10 @@ __code insertNode_stub(struct Context* context) { goto insertNode(context, - &context->data[D_Traverse]->traverse, + &context->data[D_Traverse]->Traverse, &context->data[D_Stack]->stack, &context->data[D_Node]->node, - context->data[D_Traverse]->traverse.newNode); + context->data[D_Traverse]->Traverse.newNode); } __code insertCase1(struct Context* context,struct Traverse* traverse, struct Tree* tree,struct Node *parent, struct Node *grandparent) { @@ -127,7 +128,7 @@ __code insertCase1_stub(struct Context* context) { goto insertCase1(context, - &context->data[D_Traverse]->traverse, + &context->data[D_Traverse]->Traverse, &context->data[D_Tree]->tree, &context->data[D_Stack]->stack.data->node, &context->data[D_Stack]->stack.data1->node); @@ -141,7 +142,7 @@ } __code insertCase2_stub(struct Context* context) { - goto insertCase2(context, &context->data[D_Traverse]->traverse); + goto insertCase2(context, &context->data[D_Traverse]->Traverse); } __code insertCase3(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack) { @@ -166,7 +167,7 @@ } __code insertCase3_stub(struct Context* context) { - goto insertCase3(context, &context->data[D_Traverse]->traverse, + goto insertCase3(context, &context->data[D_Traverse]->Traverse, &context->data[D_Stack]->stack ); } @@ -200,7 +201,7 @@ } __code insertCase4_stub(struct Context* context) { - goto insertCase4(context, &context->data[D_Traverse]->traverse, &context->data[D_RotateTree]->rotateTree); + goto insertCase4(context, &context->data[D_Traverse]->Traverse, &context->data[D_RotateTree]->rotateTree); } __code insertCase5(struct Context* context, struct Traverse* traverse,struct Stack *nodeStack) { @@ -210,7 +211,7 @@ } __code insertCase5_stub(struct Context* context) { - goto insertCase5(context, &context->data[D_Traverse]->traverse, &context->data[D_Stack]->stack); + goto insertCase5(context, &context->data[D_Traverse]->Traverse, &context->data[D_Stack]->stack); } __code insertCase51(struct Context* context, struct Traverse* traverse, struct RotateTree *rotateTree, struct Node* current, struct Node* parent, struct Node* grandparent) { @@ -234,7 +235,7 @@ __code insertCase51_stub(struct Context* context) { struct Node* parent = &context->data[D_Stack]->stack.data->node; struct Node* grandparent = &context->data[D_Stack]->stack.data1->node; - goto insertCase51(context, &context->data[D_Traverse]->traverse,&context->data[D_RotateTree]->rotateTree, context->data[D_Traverse]->traverse.current, parent, grandparent); + goto insertCase51(context, &context->data[D_Traverse]->Traverse,&context->data[D_RotateTree]->rotateTree, context->data[D_Traverse]->Traverse.current, parent, grandparent); } __code rotateLeft(struct Context* context, struct Traverse* traverse,struct Stack* nodeStack) { @@ -327,7 +328,7 @@ } __code stackClear_stub(struct Context* context) { - goto stackClear(context, &context->data[D_Traverse]->traverse,&context->data[D_Stack]->stack); + goto stackClear(context, &context->data[D_Traverse]->Traverse,&context->data[D_Stack]->stack); } @@ -342,7 +343,7 @@ } __code get_stub(struct Context* context) { - goto get(context, &context->data[D_Tree]->tree, &context->data[D_Traverse]->traverse); + goto get(context, &context->data[D_Tree]->tree, &context->data[D_Traverse]->Traverse); } __code search(struct Context* context, struct Traverse* traverse, struct Node* node) { @@ -365,7 +366,7 @@ } __code search_stub(struct Context* context) { - goto search(context, &context->data[D_Traverse]->traverse, &context->data[D_Node]->node); + goto search(context, &context->data[D_Traverse]->Traverse, &context->data[D_Node]->node); } /* /\* __code delete(struct Context* context, struct Tree* tree) { *\/ */
--- a/src/parallel_execution/time.c Thu Nov 10 12:07:53 2016 +0900 +++ b/src/parallel_execution/time.c Thu Nov 10 20:37:52 2016 +0900 @@ -14,7 +14,7 @@ } __code start_time_stub(struct Context* context) { - goto start_time(context, &context->data[D_Time]->time); + goto start_time(context, &context->data[D_Time]->Time); } __code end_time(struct Context* context, struct Time* time) { @@ -27,5 +27,5 @@ } __code end_time_stub(struct Context* context) { - goto end_time(context, &context->data[D_Time]->time); + goto end_time(context, Gearef(context, Time)); }
--- a/src/parallel_execution/worker.c Thu Nov 10 12:07:53 2016 +0900 +++ b/src/parallel_execution/worker.c Thu Nov 10 20:37:52 2016 +0900 @@ -14,7 +14,7 @@ context->next = GetQueue; node->key = ((struct Task *)(first->data))->key; - struct Traverse *t = &context->data[D_Traverse]->traverse; + struct Traverse *t = &context->data[D_Traverse]->Traverse; t->next = ((struct Task *)(first->data))->code; goto meta(context, C_get); } else {