diff src/parallel_execution/main.c @ 218:d8a59b727f65

Fix spawnTaskManager
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Mon, 09 Jan 2017 05:23:20 +0900
parents c34e6aa10967
children 6c0692c9bfed
line wrap: on
line diff
--- a/src/parallel_execution/main.c	Mon Jan 09 01:18:13 2017 +0900
+++ b/src/parallel_execution/main.c	Mon Jan 09 05:23:20 2017 +0900
@@ -6,6 +6,8 @@
 #include "origin_cs.h"
 
 extern __code initContext(struct Context* context);
+extern union Data* createRedBlackTree(struct Context* context);
+extern union Data* createTaskManager(struct Context* context);
 extern void allocator(struct Context* context);
 
 int cpu_num = 1;
@@ -73,9 +75,6 @@
     int i = loopCounter->i;
 
     if ((length/split*i) < length) {
-        allocate->size = sizeof(struct Array);
-        allocator(context);
-
         goto meta(context, C_createData2);
     }
 
@@ -84,7 +83,11 @@
 }
 
 __code createData1_stub(struct Context* context) {
-    goto createData1(context, &context->data[D_Allocate]->Allocate, &context->data[D_LoopCounter]->LoopCounter);
+    LoopCounter* loopCounter = Gearef(context, LoopCounter);
+    loopCounter->i = 0;
+    loopCounter->tree = &createRedBlackTree(context)->Tree;
+    context->data[D_Tree]->Tree.tree = (union Data*)loopCounter->tree;
+    goto createData1(context, Gearef(context, Allocate), Gearef(context, LoopCounter));
 }
 
 __code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node, Tree* tree) {
@@ -104,79 +107,35 @@
 }
 
 __code createData2_stub(struct Context* context) {
+    Array* array = &ALLOCATE(context, Array)->Array;
     goto createData2(context,
-            &context->data[D_LoopCounter]->LoopCounter,
-            &context->data[context->dataNum]->Array,
-            &context->data[D_Node]->Node,
+            Gearef(context, LoopCounter),
+            array,
+            Gearef(context, Node),
             Gearef(context, Tree));
 }
 
-__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element) {
+__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct Task* task) {
     task->code = C_twice;
     task->idsCount = 0;
 
-    element->data = (union Data *)task;
-
-    context->next = C_createData1;
+    taskManager->task = task;
+    taskManager->next = C_createData1;
     loopCounter->i++;
 
-    goto meta(context, C_createTask1);
+    goto meta(context, taskManager->taskManager->TaskManager.spawn);
 }
 
 __code createTask1_stub(struct Context* context) {
     Task* task = &ALLOCATE(context, Task)->Task;
+    TaskManager* taskManager = &createTaskManager(context)->TaskManager;
+    context->data[D_TaskManager]->TaskManager.taskManager = (union Data*)taskManager;
     goto createTask1(context,
-            &context->data[D_LoopCounter]->LoopCounter,
-            task,
-            &context->data[D_Element]->Element);
+            Gearef(context, LoopCounter),
+            Gearef(context, TaskManager),
+            task);
 }
 
-//__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) {
-//    int i = loopCounter->i;
-//
-//    task->code = TaskC;
-//    task->key = i;
-//    task->waitMe = waitMe;
-//    task->waitI = waitI;
-//    task->idsCount = 1;
-//
-//    element->data = (union Data *)task;
-//
-//    context->next = CreateData1;
-//    loopCounter->i++;
-//
-//    goto meta_createTask2(context, activeQueue, PutQueue1);
-//}
-//
-//__code createTask4_stub(struct Context* context) {
-//    goto createTask2(context,
-//            &context->data[LoopCounter]->loopCounter,
-//            &context->data[context->dataNum]->task,
-//            &context->data[context->dataNum-1]->queue,
-//            &context->data[context->dataNum-2]->odsQueue,
-//            &context->data[Element]->element,
-//            &context->data[ActiveQueue]->queue);
-//}
-//
-//__code createTask5(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) {
-//    int i = loopCounter->i;
-//
-//    task->code = TaskB;
-//    task->key = i;
-//    element->data = (union Data *)task;
-//
-//    context->next = CreateData1;
-//    loopCounter->i++;
-//
-//    goto meta(context, WaitFor1);
-//}
-//
-//__code createTask5_stub(struct Context* context) {
-//    goto createTask2(context,
-//            &context->data[context->dataNum]->task,
-//            &context->data[Element]->element);
-//}
-
 __code createWorker1(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) {
     int i = loopCounter->i;