changeset 349:01e0fa598ce3

Fix compile error but not work
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 07 Jun 2017 13:46:00 +0900
parents c03159481cb6
children a9863b41f026
files src/parallel_execution/TaskManagerImpl.cbc src/parallel_execution/examples/Add.cbc src/parallel_execution/examples/Mult.cbc src/parallel_execution/examples/calc.cbc
diffstat 4 files changed, 35 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/TaskManagerImpl.cbc	Tue Jun 06 17:08:55 2017 +0900
+++ b/src/parallel_execution/TaskManagerImpl.cbc	Wed Jun 07 13:46:00 2017 +0900
@@ -75,20 +75,20 @@
 
 __code setWaitTask(struct TaskManager* taskManager, struct Queue* queue, struct Context* task, struct LoopCounter* loopCounter, __code next(...)) {
     int i = loopCounter->i;
-    if(task->idg + i < task->maxidg) {
+    if(task->idg + i < task->maxIdg) {
         loopCounter->i++;
         queue->queue = (Data *)GET_WAIT_LIST(task->data[task->idg + i]);
         queue->next = C_setWaitTask;
         queue->data = (Data *)task;
         goto meta(context, queue->queue->Queue.put);
     }
-    goto meta(context, taskManager->taskManager->spawn);
+    goto meta(context, taskManager->taskManager->TaskManager.spawn);
 }
 
 __code setWaitTask_stub(struct Context* context) {
     TaskManager* taskManager = Gearef(context, TaskManager);
     struct Context* task = Gearef(context, TaskManager)->context;
-    goto setWaitTask(context, taskManager, Gearef(context, Queue), task, Gearef(task, LoopCounter), taskGearef(context, TaskManager)->next);
+    goto setWaitTask(context, taskManager, Gearef(context, Queue), task, Gearef(task, LoopCounter), Gearef(context, TaskManager)->next);
 }
 
 __code spawnTaskManager(struct TaskManagerImpl* taskManager, struct Queue* queue, struct Context* task, __code next(...)) {
--- a/src/parallel_execution/examples/Add.cbc	Tue Jun 06 17:08:55 2017 +0900
+++ b/src/parallel_execution/examples/Add.cbc	Wed Jun 07 13:46:00 2017 +0900
@@ -1,54 +1,18 @@
 #include "../../context.h"
-CodeGear* createAddCodeGear(struct Context* context) {
-    struct CodeGear* codeGear = new CodeGear();
-    struct context* addContext = NEW(struct Context);
-    codeGear->codeGear = (union Data*)addContext;
-    initContext(addContext);
-    codeGear->code = C_add;
-    codeGear->setInfo = C_setAddCodeGearInfo;
-    return codeGear;
-}
-
-__code setAddCodeGearInfo(struct Context* codeGear, union Data** dataGears, __code next(...)) {
-    codeGear->next = C_add;
-    codeGear->idgCount = 2;
-    codeGear->idg = codeGear->datanum;
-    codeGear->data[codeGear->idg] = dataGears[0];
-    codeGear->data[codeGear->idg+1] = dataGears[1];
-    codeGear->maxIdg = codeGear->idg + 2;
-    codeGear->odg = codeGear->maxIdg;
-    codeGear->data[codeGear->odg] = dataGears[2];
-    task->maxOdg = task->odg + 1;
-    goto meta(context, C_setWaitTask)
+#include <stdio.h>
+__code add(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
+    struct Integer* output = NULL;
+    output->value = input1->value + input2->value;
+    printf("%d + %d = %d\n", input1->value, input2->value, output->value);
+    *O_output = output;
+    goto meta(context, next);
 }
 
-__code setAddCodeGearInfo_stub(struct Context* context) {
-	Context* codeGear = (Context *)GearIpl(context, CodeGear, codeGear);
-	Data* dataGears = Gearef(context, CodeGear)->dataGears;
-	enum Code next = Gearef(context, CodeGear)->next;
-	goto setAddCodeGearInfo(context, codeGear, dataGears, next);
+__code add_stub(struct Context* context) {
+    Integer** O_output = (struct Integer **)&context->data[context->odg];
+    goto add(context,
+            &context->data[context->idg]->Integer,
+            &context->data[context->idg + 1]->Integer,
+            context->next,
+            O_output);
 }
-
-__code setWaitTask(struct Context* codeGear, struct Queue* Queue, struct LoopCounter* loopCounter, union Data** dataGears, __code next(...)) {
-    if(loopCounter->i < codeGear->idgCount) {
-        queue->queue = (Data *)GET_WAIT_LIST(data);
-        queue->data = codeGears[loopCoutner->i];
-        queue->next = C_setWaitTask;
-        loopCounter->i++;
-        goto meta(context, queue->queue->Queue.put);
-    }
-    taskManager->context = codeGear;
-    taskManager->next = next;
-    goto meta(context, taskManager->spawn);
-}
-
-__code setWaitTask_stub(struct Context* context) {
-    Context* codeGear = GearImpl(context, CodeGear, codeGear)
-    goto setWaitTask(context, codeGear, Gearef(context, Queue), Gearef(codeGear, LoopCounter), Gearef(context, CodeGear)->dataGears, Gearef(context, CodeGear)->next);
-}
-
-__code add(struct Integer* input1, struct Integer* input2, __code next(union Integer* output, ...)) {
-    output->value = input1->value + input2->value;
-    printf("%d + %d = %d\n", input1->value, input2->value, output->value);
-    goto next(output, ...)
-}
--- a/src/parallel_execution/examples/Mult.cbc	Tue Jun 06 17:08:55 2017 +0900
+++ b/src/parallel_execution/examples/Mult.cbc	Wed Jun 07 13:46:00 2017 +0900
@@ -1,36 +1,18 @@
 #include "../../context.h"
-CodeGear* createMultCodeGear(struct Context* context) {
-    struct CodeGear* codeGear = new CodeGear();
-    struct context* multContext = NEW(struct Context);
-    codeGear->codeGear = (union Data*)multContext;
-    initContext(multContext);
-    codeGear->code = C_mult;
-    codeGear->setInfo = C_setMultCodeGearInfo;
-    return codeGear;
+#include <stdio.h>
+__code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
+    struct Integer* output = NULL;
+    output->value = input1->value * input2->value;
+    printf("%d + %d = %d\n", input1->value, input2->value, output->value);
+    *O_output = output;
+    goto meta(context, next);
 }
 
-__code setMultCodeGearInfo(struct Context* codeGear, union Data** dataGears, __code next(...)) {
-    codeGear->next = C_mult;
-    codeGear->idgCount = 2;
-    codeGear->idg = codeGear->datanum;
-    codeGear->data[codeGear->idg] = dataGears[0];
-    codeGear->data[codeGear->idg+1] = dataGears[1];
-    codeGear->maxIdg = codeGear->idg + 2;
-    codeGear->odg = codeGear->maxIdg;
-    codeGear->data[codeGear->odg] = dataGears[2];
-    task->maxOdg = task->odg + 1;
-    goto meta(context, C_setWaitTask)
+__code mult_stub(struct Context* context) {
+    Integer** O_output = (struct Integer **)&context->data[context->odg];
+    goto mult(context,
+            &context->data[context->idg]->Integer,
+            &context->data[context->idg + 1]->Integer,
+            context->next,
+            O_output);
 }
-
-__code setMultCodeGearInfo_stub(struct Context* context) {
-	Context* codeGear = (Context *)GearIpl(context, CodeGear, codeGear);
-	Data* dataGears = Gearef(context, CodeGear)->dataGears;
-	enum Code next = Gearef(context, CodeGear)->next;
-	goto setMultCodeGearInfo(context, codeGear, dataGears, next);
-}
-
-__code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
-    output->value = input1->value * input2->value;
-    printf("%d + %d = %d\n", input1->value, input2->value, output->value);
-    goto next(output, ...)
-}
--- a/src/parallel_execution/examples/calc.cbc	Tue Jun 06 17:08:55 2017 +0900
+++ b/src/parallel_execution/examples/calc.cbc	Wed Jun 07 13:46:00 2017 +0900
@@ -109,9 +109,10 @@
     integer2->value = i+1;
     struct Context* task = NEW(struct Context);
     initContext(task);
+    task->taskManager = &taskManager->taskManager->TaskManager;
     task->next = C_mult;
     task->idgCount = 2;
-    task->idg = task->datanum;
+    task->idg = task->dataNum;
     task->data[task->idg] = (union Data*)integer1;
     task->data[task->idg+1] = (union Data*)integer2;
     task->maxIdg = task->idg + 2;
@@ -141,9 +142,10 @@
     integer2->value = i+1;
     struct Context* task = NEW(struct Context);
     initContext(task);
+    task->taskManager = &taskManager->taskManager->TaskManager;
     task->next = C_add;
     task->idgCount = 2;
-    task->idg = task->datanum;
+    task->idg = task->dataNum;
     task->data[task->idg] = (union Data*)integer1;
     task->data[task->idg+1] = (union Data*)integer2;
     task->maxIdg = task->idg + 2;
@@ -180,7 +182,6 @@
     }
 }
 
-
 int main(int argc, char** argv) {
     init(argc, argv);
     struct Context* main_context = NEW(struct Context);
@@ -189,18 +190,3 @@
 
     goto start_code(main_context);
 }
-
-__code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
-    output->value = input1->value * input2->value;
-    printf("%d * %d = %d\n", input1->value, input2->value, output->value);
-    assert(output->value == 2 * (input2->value * input2->value) + input2->value);
-    goto meta(context, context->next);
-}
-
-__code mult_stub(struct Context* context) {
-    goto mult(context,
-            &context->data[context->idg]->Integer,
-            &context->data[context->idg + 1]->Integer,
-            &context->data[context->odg]->Integer);
-
-}