changeset 124:acf0453b1c7a

Fix meta data pointer calculate
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 27 Sep 2016 16:19:31 +0900
parents 4ff6f093b695
children 77e60b6cdace
files src/parallel_execution/context.c src/parallel_execution/context.h src/parallel_execution/dependency.c src/parallel_execution/main.c
diffstat 4 files changed, 41 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/context.c	Tue Sep 13 11:54:25 2016 +0900
+++ b/src/parallel_execution/context.c	Tue Sep 27 16:19:31 2016 +0900
@@ -52,6 +52,7 @@
 extern __code createTask3_stub(struct Context*);
 extern __code createTask4_stub(struct Context*);
 extern __code createTask5_stub(struct Context*);
+extern __code createTask6_stub(struct Context*);
 extern __code poll1_stub(struct Context*);
 extern __code poll2_stub(struct Context*);
 /* extern __code createTask3_stub(struct Context*); */
@@ -81,7 +82,7 @@
     context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
     context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
     context->data = NEWN(ALLOCATE_SIZE, union Data*);
-    context->mData = NEWN(ALLOCATE_SIZE, union Data*);
+    context->mData = NEWN(ALLOCATE_SIZE, union MetaData*);
     context->heapStart = NEWN(context->heapLimit, char);
     context->heap = context->heapStart;
 
@@ -133,6 +134,7 @@
     context->code[CreateTask3]   = createTask3_stub;
     context->code[CreateTask4]   = createTask4_stub;
     context->code[CreateTask5]   = createTask5_stub;
+    context->code[CreateTask6]   = createTask6_stub;
     context->code[Poll1]         = poll1_stub;
     context->code[Poll2]         = poll2_stub;
     context->code[PutQueue1]     = putQueue1_stub;
--- a/src/parallel_execution/context.h	Tue Sep 13 11:54:25 2016 +0900
+++ b/src/parallel_execution/context.h	Tue Sep 27 16:19:31 2016 +0900
@@ -63,6 +63,7 @@
     CreateTask3,
     CreateTask4,
     CreateTask5,
+    CreateTask6,
     Poll1,
     Poll2,
     PutQueue1,
--- a/src/parallel_execution/dependency.c	Tue Sep 13 11:54:25 2016 +0900
+++ b/src/parallel_execution/dependency.c	Tue Sep 27 16:19:31 2016 +0900
@@ -9,16 +9,16 @@
 
 __code waitFor(struct Context* context, struct Task* slave, struct Element* element, union Data* data) {
     struct Integer* integer   = (struct Integer *)data;
-    struct Queue* waitMeTasks = (struct Queue *)(integer + integer-> mDataOffset);
+    struct Queue* waitMeTasks = (struct Queue *)(integer + integer-> mDataOffset / sizeof(struct Integer));
     element->data = (union Data *)slave;
     goto meta_waitFor(context, waitMeTasks, PutQueue1);
 }
 
 __code waitFor_stub(struct Context* context) {
     goto waitFor(context,
-            &context->data[context->dataNum-1]->task,
+            &context->data[context->dataNum-2]->task,
             &context->data[Element]->element,
-            &context->data[Node]->node.value);
+            context->data[Node]->node.value);
 }
 
 __code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) {
@@ -26,7 +26,7 @@
     goto (context->code[next])(context);
 }
 
-__code spawnTask(struct Context* context, struct Task* task, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) {
+__code spawnTask(struct Context* context, struct Task* task, struct Queue* activeQueue, struct Queue* waitQueue) {
     if (task->idsCount == 0) {
         //printf("put ActiveQueue\n");
         // enqueue activeQueue
@@ -41,7 +41,6 @@
 __code spawnTask_stub(struct Context* context) {
     goto spawnTask(context,
             (struct Task *)(context->data[Element]->element.data),
-            &context->data[Element]->element,
             &context->data[ActiveQueue]->queue,
             &context->data[WaitQueue]->queue);
 }
@@ -53,7 +52,7 @@
 
 __code checkTaskFinish1(struct Context* context, union Data* data) {
     struct Integer* integer = (struct Integer *)data;
-    struct Queue* waitMeTasks = (struct Queue *)(integer + integer->mDataOffset);
+    struct Queue* waitMeTasks = (struct Queue *)(integer + integer->mDataOffset / sizeof(struct Integer));
     context->next = CheckTaskFinish2;
     goto meta_checkTaskFinish1(context, waitMeTasks, GetQueue1);
 }
@@ -77,7 +76,7 @@
 }
 
 __code checkTaskFinish2_stub(struct Context* context) {
-    goto checkTaskFinish1(context,
+    goto checkTaskFinish2(context,
                           (struct Task*)(context->data[Element]->element.data));
 }
 
--- a/src/parallel_execution/main.c	Tue Sep 13 11:54:25 2016 +0900
+++ b/src/parallel_execution/main.c	Tue Sep 27 16:19:31 2016 +0900
@@ -52,15 +52,15 @@
 __code code2(struct Context* context, struct Array* array, struct LoopCounter* loopCounter) {
     int i = loopCounter->i;
 
-    if (i < length) {
-           //printf("%d\n", array->array[i]);
-        if (array->array[i] == (i*2)) {
-            loopCounter->i++;
-            goto meta(context, Code2);
-        } else
-            puts("wrong result");
+    //if (i < length) {
+    //       //printf("%d\n", array->array[i]);
+    //    if (array->array[i] == (i*2)) {
+    //        loopCounter->i++;
+    //        goto meta(context, Code2);
+    //    } else
+    //        puts("wrong result");
 
-    }
+    //}
 
     goto meta(context, Exit);
 }
@@ -215,16 +215,18 @@
 }
 
 
-__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element) {
+__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Node* node) {
     int i = loopCounter->i;
 
     task->code = Add;
     task->oKeys[0] = i;
     task->iKeys[0] = i-1;
     task->iKeys[1] = i-2;
+    task->idsCount = 0;
     loopCounter->i -= 2;
-    element->data = (union Data *)task;
     context->next = CreateTask5;
+
+    node->key = task->oKeys[0];
     goto meta(context, Get);
 }
 
@@ -232,22 +234,33 @@
     goto createTask4(context,
             &context->data[LoopCounter]->loopCounter,
             &context->data[context->dataNum]->task,
-            &context->data[Element]->element
+            &context->data[Node]->node
             );
 }
 
-__code createTask5(struct Context* context, struct Task* task, struct Node* node) {
-    node->key = task->oKeys[0];
-    loopCounter->i = 0;
-    context->next = Code1;
+__code createTask5(struct Context* context, struct Task* task) {
+    context->next = CreateTask6;
     goto meta(context, WaitFor);
 }
 
 __code createTask5_stub(struct Context* context) {
-    goto createTask4(context,
+    goto createTask5(context,
+            &context->data[context->dataNum]->task
+            );
+}
+
+__code createTask6(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element) {
+    element->data = (union Data *)task;
+    loopCounter->i = 0;
+    context->next = Code1;
+    goto meta(context, SpawnTask);
+}
+
+__code createTask6_stub(struct Context* context) {
+    goto createTask6(context,
             &context->data[LoopCounter]->loopCounter,
-            &context->data[context->dataNum]->task,
-            &context->data[Node]->node
+            &context->data[context->dataNum-1]->task,
+            &context->data[Element]->element
             );
 }