diff src/parallel_execution/examples/calc.cbc @ 327:534601ed8c50 examples_directory

Running dependency example for single thread and single task
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 18 Apr 2017 05:53:37 +0900
parents f23f6d0aa4e9
children 48c2b5bcab79
line wrap: on
line diff
--- a/src/parallel_execution/examples/calc.cbc	Tue Apr 18 01:47:42 2017 +0900
+++ b/src/parallel_execution/examples/calc.cbc	Tue Apr 18 05:53:37 2017 +0900
@@ -111,20 +111,21 @@
 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
     int i = loopCounter->i;
 
-    if ((length/split*i) < length) {
+    if (i < 1) {
+        loopCounter->i++;
         taskManager->next = C_createTask2;
         goto meta(context, taskManager->taskManager->TaskManager.createTask);
     }
 
     loopCounter->i = 0;
     taskManager->next = C_code1;
+    sleep(3);
     goto meta(context, taskManager->taskManager->TaskManager.shutdown);
 }
 
 __code createTask2(LoopCounter* loopCounter, TaskManager* taskManager, struct Context *task, Integer *integer1, Integer *integer2, Integer *integer3) {
     int i = loopCounter->i;
-    loopCounter->i++;
-    task->idgCount = 0;
+    task->idgCount = 1;
     task->next = C_mult;
     integer2->value = i+1;
     task->data[task->idg] = (union Data*)integer1;
@@ -139,9 +140,9 @@
 }
 
 __code createTask2_stub(struct Context* context) {
-    Integer* integer1 = &ALLOCATE(context, Integer)->Integer;
-    Integer* integer2 = &ALLOCATE(context, Integer)->Integer;
-    Integer* integer3 = &ALLOCATE(context, Integer)->Integer;
+    Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
+    Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
+    Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
     goto createTask2(context,
             Gearef(context, LoopCounter),
             Gearef(context, TaskManager),
@@ -151,16 +152,11 @@
             integer3);
 }
 
-__code createTask3(TaskManager* taskManager) {
+__code createTask3(struct TaskManager* taskManager) {
     taskManager->next = C_createTask4;
     goto meta(context, taskManager->taskManager->TaskManager.spawn);
 }
 
-__code createTask3_stub(struct Context* context) {
-    goto createTask3(context,
-            Gearef(context, TaskManager));
-}
-
 __code createTask4(struct TaskManager* taskManager) {
     taskManager->next = C_createTask5;
     goto meta(context, taskManager->taskManager->TaskManager.createTask);
@@ -171,21 +167,20 @@
     task->next = C_add;
     task->idgCount = 0;
     integer1->value = i;
-    integer1->value = i+1;
+    integer2->value = i+1;
     task->data[task->idg] = (union Data*)integer1;
     task->data[task->idg+1] = (union Data*)integer2;
     task->maxIdg = task->idg + 2;
     task->odg = task->maxIdg;
     task->data[task->odg] = (union Data*)integer3;
     task->maxOdg = task->odg + 1;
-    taskManager->next = C_createTask3;
-    taskManager->data = (union Data*)integer1;
+    taskManager->next = C_createTask1;
     goto meta(context, taskManager->taskManager->TaskManager.spawn);
 }
 
 __code createTask5_stub(struct Context* context) {
-    Integer* integer1 = &ALLOCATE(context, Integer)->Integer;
-    Integer* integer2 = &ALLOCATE(context, Integer)->Integer;
+    Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
+    Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
     goto createTask5(context,
             Gearef(context, LoopCounter),
             Gearef(context, TaskManager),
@@ -248,7 +243,7 @@
 }
 
 __code mult_stub(struct Context* context) { 
-    goto add(context, 
+    goto mult(context, 
             &context->data[context->idg]->Integer,
             &context->data[context->idg + 1]->Integer,
             &context->data[context->odg]->Integer);