Mercurial > hg > GearsTemplate
changeset 170:ee7134f3bef1
Fix
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Nov 2016 10:36:45 +0900 |
parents | ea7b11f3e717 |
children | 747067fe46bd |
files | src/parallel_execution/context.c src/parallel_execution/context.h src/parallel_execution/main.c src/parallel_execution/queue.h src/parallel_execution/worker.c |
diffstat | 5 files changed, 23 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.c Tue Nov 22 09:48:37 2016 +0900 +++ b/src/parallel_execution/context.c Tue Nov 22 10:36:45 2016 +0900 @@ -188,8 +188,8 @@ ALLOC_DATA(context, Time); - context->data[D_ActiveQueue] = createSynchronizedQueue(context) - context->data[D_WaitQueue] = createSynchronizedQueue(context) + context->data[D_ActiveQueue] = createSynchronizedQueue(context); + context->data[D_WaitQueue] = createSynchronizedQueue(context); context->dataNum = D_Queue; }
--- a/src/parallel_execution/context.h Tue Nov 22 09:48:37 2016 +0900 +++ b/src/parallel_execution/context.h Tue Nov 22 10:36:45 2016 +0900 @@ -90,8 +90,8 @@ PutQueue2, PutQueue3, PutQueue4, - C_GetTask1, - C_GetTask2, + C_getTask1, + C_getTask2, C_clearSingleLinkedStack, C_pushSingleLinkedStack, C_popSingleLinkedStack, @@ -107,6 +107,10 @@ C_putSynchronizedQueue, C_isEmptySynchronizedQueue, C_clearSynchronizedQueue, + C_putRedBlackTree, + C_getRedBlackTree, + C_removeRedBlackTree, + C_clearRedBlackTree, SpawnTask, Twice, StartTime, @@ -126,6 +130,7 @@ D_SingleLinkedStack, D_Stack, D_Tree, + D_Task, D_Traverse, D_RotateTree, D_Node,
--- a/src/parallel_execution/main.c Tue Nov 22 09:48:37 2016 +0900 +++ b/src/parallel_execution/main.c Tue Nov 22 10:36:45 2016 +0900 @@ -114,14 +114,6 @@ __code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element) { int i = loopCounter->i; - waitMe->first = 0; - waitMe->last = 0; - waitMe->count = 0; - - waitI->first = 0; - waitI->last = 0; - waitI->count = 0; - task->code = Twice; task->key = i; task->waitMe = waitMe; @@ -194,71 +186,12 @@ // &context->data[Element]->element); //} -__code putQueue1(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Element); - allocator(context); - - goto meta(context, PutQueue2); -} - -__code putQueue1_stub(struct Context* context) { - goto putQueue1(context, &context->data[D_Allocate]->allocate); -} - -__code putQueue2(struct Context* context, struct Element* new_element, struct Element* element, struct Queue* queue) { - new_element->data = element->data; - - if (queue->first) - goto meta(context, PutQueue3); - else - goto meta(context, PutQueue4); -} - -__code putQueue2_stub(struct Context* context) { - goto putQueue2(context, - &context->data[context->dataNum]->element, - &context->data[D_Element]->element, - &context->data[D_Queue]->Queue); -} - -__code putQueue3(struct Context* context, struct Queue* queue, struct Element* new_element) { - struct Element* last = queue->last; - - if (__sync_bool_compare_and_swap(&queue->last, last, new_element)) { - last->next = new_element; - queue->count++; - - goto meta(context, context->next); - } else { - goto meta(context, PutQueue3); - } -} - -__code putQueue3_stub(struct Context* context) { - goto putQueue3(context, &context->data[D_Queue]->Queue, &context->data[context->dataNum]->element); -} - -__code putQueue4(struct Context* context, struct Queue* queue, struct Element* new_element) { - if (__sync_bool_compare_and_swap(&queue->first, 0, new_element)) { - queue->last = new_element; - queue->count++; - - goto meta(context, context->next); - } else { - goto meta(context, PutQueue3); - } -} - -__code putQueue4_stub(struct Context* context) { - goto putQueue4(context, &context->data[D_Queue]->Queue, &context->data[context->dataNum]->element); -} - __code createWorker(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { int i = loopCounter->i; if (i < worker->num) { struct Context* worker_context = &worker->contexts[i]; - worker_context->next = GetQueue; + worker_context->next = C_getTask1; worker_context->data[D_Tree] = context->data[D_Tree]; worker_context->data[D_ActiveQueue] = context->data[D_ActiveQueue]; pthread_create(&worker_context->thread, NULL, (void*)&start_code, worker_context);
--- a/src/parallel_execution/queue.h Tue Nov 22 09:48:37 2016 +0900 +++ b/src/parallel_execution/queue.h Tue Nov 22 10:36:45 2016 +0900 @@ -1,6 +1,13 @@ extern union Data* createSingleLinkedQueue(struct Context* context); -extern __code putSingleLinkedQueue_stub(struct Context* context) ; -extern __code takeSingleLinkedQueue_stub(struct Context* context) ; -extern __code isEmptySingleLinkedQueue_stub(struct Context* context) ; -extern __code clearSingleLinkedQueue_stub(struct Context* context) ; +extern __code putSingleLinkedQueue_stub(struct Context* context); +extern __code takeSingleLinkedQueue_stub(struct Context* context); +extern __code isEmptySingleLinkedQueue_stub(struct Context* context); +extern __code clearSingleLinkedQueue_stub(struct Context* context); + +extern union Data* createSynchronizedQueue(struct Context* context); + +extern __code putSynchronizedQueue_stub(struct Context* context); +extern __code takeSynchronizedQueue_stub(struct Context* context); +extern __code isEmptySynchronizedQueue_stub(struct Context* context); +extern __code clearSynchronizedQueue_stub(struct Context* context);
--- a/src/parallel_execution/worker.c Tue Nov 22 09:48:37 2016 +0900 +++ b/src/parallel_execution/worker.c Tue Nov 22 10:36:45 2016 +0900 @@ -4,7 +4,7 @@ #include "origin_cs.h" __code getTask1(struct Context* context, struct Queue* queue) { - queue->next = GetTask2; + queue->next = C_getTask2 goto meta(context, queue->take); } @@ -17,6 +17,7 @@ struct Traverse *t = &context->data[D_Traverse]->Traverse; t->next = task->code; + context->next = C_getTask1 goto meta(context, C_get); }