diff src/parallel_execution/main.cbc @ 312:7dd5a7d52a67

USE_CUDAWorker flag only for CUDAtwice
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 15 Feb 2017 11:04:30 +0900
parents 8c2123bb577b
children 4addbc7469ee
line wrap: on
line diff
--- a/src/parallel_execution/main.cbc	Tue Feb 14 22:20:17 2017 +0900
+++ b/src/parallel_execution/main.cbc	Wed Feb 15 11:04:30 2017 +0900
@@ -8,6 +8,9 @@
 int length = 102400;
 int split = 8;
 int* array_ptr;
+int gpu_num = 0;
+int CPU_ANY = -1;
+int CPU_CUDA = -1;
 
 void print_queue(struct Element* element) {
     while (element) {
@@ -27,7 +30,7 @@
 __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
     // loopCounter->tree = createRedBlackTree(context);
     loopCounter->i = 0;
-    taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, 0, 0);
+    taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
     goto meta(context, C_createTask1);
 }
 
@@ -37,6 +40,7 @@
 
 __code code1(struct Time* time) {
     printf("cpus:\t\t%d\n", cpu_num);
+    printf("gpus:\t\t%d\n", gpu_num);
     printf("length:\t\t%d\n", length);
     printf("length/task:\t%d\n", length/split);
     /* puts("queue"); */
@@ -89,9 +93,15 @@
     array->index = i;
     array->prefix = length/split;
     array->array = array_ptr;
+    array->size = length;
     loopCounter2->i = 0;
     task->idgCount = 0;
-    task->next = C_twice;
+    if (gpu_num) {
+        task->next = C_CUDAtwice;
+        task->workerId = CPU_CUDA;
+    } else {
+        task->next = C_twice;
+    }
     task->data[task->dataNum] = (union Data*)loopCounter2;
     task->data[task->dataNum+1] = (union Data*)array;
     task->odg = task->dataNum + 2;
@@ -120,7 +130,11 @@
             length = (int)atoi(argv[i+1]);
         else if (strcmp(argv[i], "-s") == 0)
             split = (int)atoi(argv[i+1]);
+        else if (strcmp(argv[i], "-cuda") == 0) {
+            gpu_num = 1;
+        }
     }
+    CPU_CUDA = cpu_num;
 }