changeset 240:864bb372f37f

Add spawnTask1
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 24 Jan 2017 16:31:10 +0900
parents e450bd33b33b
children 9135e22799dd
files src/parallel_execution/taskManager.c src/parallel_execution/worker.c
diffstat 2 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/taskManager.c	Tue Jan 24 09:21:47 2017 +0900
+++ b/src/parallel_execution/taskManager.c	Tue Jan 24 16:31:10 2017 +0900
@@ -31,18 +31,18 @@
     int i = 0;
     TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context,TaskManager,taskManager);
     taskManagerImpl->workers = (Worker*)ALLOC_ARRAY(context,Worker,taskManager->maxCPU);
-    for (;i>taskManager->gpu;i++) {
+    for (;i<taskManager->gpu;i++) {
         Queue* queue = &createSynchronizedQueue(context)->Queue;
         taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue);
     }
-    for (;i>taskManager->cpu;i++) {
+    for (;i<taskManager->cpu;i++) {
 #ifdef USE_CUDA
 #else
         Queue* queue = &createSynchronizedQueue(context)->Queue;
         taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue);
 #endif        
     }
-    for (;i>taskManager->maxCPU;i++) {
+    for (;i<taskManager->maxCPU;i++) {
         Queue* queue = &createSynchronizedQueue(context)->Queue;
         taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue);
     }
@@ -67,8 +67,7 @@
         queue->queue = (union Data*)taskManager->taskQueue;
     }
     queue->data = (union Data*)task;
-    queue->next = next;
-    pthread_mutex_unlock(taskManagerImpl->mutex);
+    queue->next = C_spawnTaskManager1;
     goto meta(context, queue->queue->Queue.put);
 }
 
@@ -78,15 +77,27 @@
                           (struct TaskManager*)GearImpl(context, TaskManager, taskManager),
                           Gearef(context, Queue),
                           Gearef(context, TaskManager)->context,
-                          Gearef(context, TaskManager)->next
-            );
+                          Gearef(context, TaskManager)->next);
+}
+
+
+__code spawnTaskManager1(struct Context* context, struct TaskManagerImpl* taskManager, enum Code next) {
+    pthread_mutex_unlock(taskManagerImpl->mutex);
+    goto meta(context, next);
+}
+
+__code spawnTaskManager1_stub(struct Context* context) {
+    goto spawnTaskManager(context,
+                          (struct TaskManager*)GearImpl(context, TaskManager, taskManager),
+                          Gearef(context, TaskManager)->next);
 }
 
 __code taskSend(struct Context* context) {
     if(loopCounter->i < taskManager->numWorker) {
-        taskManager->workers[i]->taskSend;
+        queue->queue = taskManager->workers[i]->tasks;
+        queue->next  =  C_taskSend;
         loopCounter->i++;
-        goto meta(context, C_taskSend);
+        goto meta(context, queue->queue->Queue.put);
     }
     goto meta(context, TaskManager->next);
 }
@@ -111,7 +122,7 @@
 }
 
 __code createWorker1_stub(struct Context* context) {
-    goto createWorker1(context, &context->data[D_LoopCounter]->LoopCounter,     &context->data[D_Worker]->Worker);
+    goto createWorker1(context, &context->data[D_LoopCounter]->LoopCounter, &context->data[D_Worker]->Worker);
 }
 
 __code shutdownTaskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker, struct TaskManager* taskManager) {
--- a/src/parallel_execution/worker.c	Tue Jan 24 09:21:47 2017 +0900
+++ b/src/parallel_execution/worker.c	Tue Jan 24 16:31:10 2017 +0900
@@ -36,7 +36,7 @@
 }
 
 __code getTask1(struct Context* context, Worker* worker, struct Context* task) {
-    if (! task)
+    if (!task)
         return; // end thread
     task->worker = worker;
     goto meta(task, task->next);