changeset 1894:b37dfbf3380d draft

fix GpuTaskManagerFactory
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Sun, 12 Jan 2014 10:28:52 +0900
parents b72db78232bc
children 6695eba251e1
files TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuTaskManagerFactory.cc TaskManager/Gpu/GpuThreads.h TaskManager/kernel/ppe/CpuThreads.h example/multiply/main.cc example/word_count/gpu/Exec_Data_Parallel.cl example/word_count/main.cc example/word_count/ppe/Exec_Data_Parallel.cc
diffstat 8 files changed, 31 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc	Sat Jan 04 19:30:26 2014 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Sun Jan 12 10:28:52 2014 +0900
@@ -235,9 +235,9 @@
                 
                 ret = clSetKernelArg(kernel[cur], 0, sizeof(memaddr),(void *)&memin[cur].buf[0]);
                 if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; }
-
+                
                 param++;
-
+                
                 cl_mem_flags mem_flag = flag[cur].flip ? CL_MEM_READ_WRITE : CL_MEM_READ_ONLY;
                 
                 for(int i=0;i<nextTask->inData_count;i++) {
--- a/TaskManager/Gpu/GpuTaskManagerFactory.cc	Sat Jan 04 19:30:26 2014 +0900
+++ b/TaskManager/Gpu/GpuTaskManagerFactory.cc	Sun Jan 12 10:28:52 2014 +0900
@@ -1,6 +1,7 @@
 #define DEBUG
-#include "GpuTaskManagerImpl.h"
+#include "CellTaskManagerImpl.h"
 #include "GpuThreads.h"
+#include "CpuThreads.h"
 
 TaskManagerImpl *create_impl(int num, int num_gpu, int useRefDma)
 {
@@ -8,5 +9,5 @@
     init_task_list(gpu_task_list);
     Threads *cpus = new CpuThreads(num, io_num, useRefDma,num_gpu);
     num += num_gpu; // for GPU
-    return new GpuTaskManagerImpl(num, num_gpu, cpus);
+    return new CellTaskManagerImpl(num, num_gpu, cpus);
 }
--- a/TaskManager/Gpu/GpuThreads.h	Sat Jan 04 19:30:26 2014 +0900
+++ b/TaskManager/Gpu/GpuThreads.h	Sun Jan 12 10:28:52 2014 +0900
@@ -20,7 +20,7 @@
     GpuScheduler *scheduler;
     TaskManagerImpl *manager;
     SemPtr wait;
-	int useRefDma;
+    int useRefDma;
 } gpu_thread_arg_t;
 
 class GpuThreads : public Threads {
--- a/TaskManager/kernel/ppe/CpuThreads.h	Sat Jan 04 19:30:26 2014 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.h	Sun Jan 12 10:28:52 2014 +0900
@@ -17,7 +17,7 @@
     MainScheduler *scheduler;
     TaskManagerImpl *manager;
     SemPtr wait;
-	int useRefDma;
+    int useRefDma;
     
 } cpu_thread_arg_t;
 
--- a/example/multiply/main.cc	Sat Jan 04 19:30:26 2014 +0900
+++ b/example/multiply/main.cc	Sun Jan 12 10:28:52 2014 +0900
@@ -108,15 +108,15 @@
     multiply->set_param(0,(long)1);
     multiply->iterate(length); 
     
-    hoge = manager->create_task(MULTIPLY_TASK);
-    hoge->set_cpu(spe_cpu);
-    hoge->set_inData(0,(memaddr)A,sizeof(float)*length);
-    hoge->set_inData(1,(memaddr)B,sizeof(float)*length);
-    hoge->set_inData(2,(memaddr)C,sizeof(float)*length);
-    hoge->set_outData(0,(memaddr)C,sizeof(float)*length);
-    hoge->set_param(0,(long)0);
-    hoge->wait_for(multiply);
-    hoge->iterate(length);
+    // hoge = manager->create_task(MULTIPLY_TASK);
+    // hoge->set_cpu(spe_cpu);
+    // hoge->set_inData(0,(memaddr)A,sizeof(float)*length);
+    // hoge->set_inData(1,(memaddr)B,sizeof(float)*length);
+    // hoge->set_inData(2,(memaddr)C,sizeof(float)*length);
+    // hoge->set_outData(0,(memaddr)C,sizeof(float)*length);
+    // hoge->set_param(0,(long)0);
+    // hoge->wait_for(multiply);
+    // hoge->iterate(length);
     //        multiply->spawn();
     //    }
 }
--- a/example/word_count/gpu/Exec_Data_Parallel.cl	Sat Jan 04 19:30:26 2014 +0900
+++ b/example/word_count/gpu/Exec_Data_Parallel.cl	Sun Jan 12 10:28:52 2014 +0900
@@ -7,7 +7,7 @@
     long division_size = param[1];
     long length = param[2];
     long out_size = param[3];
-    
+    printf("%ld\n",task_spwaned);
     long allocation = task_spwaned + (long)get_global_id(0);
     __global char *i_data = rbuf + allocation*division_size;
     __global unsigned long *o_data = wbuf + allocation*out_size;
--- a/example/word_count/main.cc	Sat Jan 04 19:30:26 2014 +0900
+++ b/example/word_count/main.cc	Sun Jan 12 10:28:52 2014 +0900
@@ -134,11 +134,11 @@
                 w->size -= size*array_task_num;
                 if(w->size < 0) array_task_num -= 1;
                 h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL);
-                h_exec->flip();
+                //                h_exec->flip();
                 h_exec->set_inData(0,w->file_mmap,w->file_size);
-                h_exec->set_inData(1,w->o_data,w->out_size_);
-                h_exec->set_outData(0,w->file_mmap,w->file_size);
-                h_exec->set_outData(1,w->o_data,w->out_size_);
+                //                h_exec->set_inData(1,w->o_data,w->out_size_);
+                //                h_exec->set_outData(0,w->file_mmap,w->file_size);
+                h_exec->set_outData(0,w->o_data,w->out_size_);
                 h_exec->set_param(0,(long)i);
                 h_exec->set_param(1,(long)w->division_size);
                 h_exec->set_param(2,(long)size);
@@ -153,11 +153,11 @@
                 
                 if(w->size < 0) {
                     h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL);
-                    h_exec->flip();
+                    //                    h_exec->flip();
                     h_exec->set_inData(0,w->file_mmap,w->file_size);
-                    h_exec->set_inData(1,w->o_data,w->out_size_);
-                    h_exec->set_outData(0,w->file_mmap,w->file_size);
-                    h_exec->set_outData(1,w->o_data,w->out_size_);
+                    //                    h_exec->set_inData(1,w->o_data,w->out_size_);
+                    //                    h_exec->set_outData(0,w->file_mmap,w->file_size);
+                    h_exec->set_outData(0,w->o_data,w->out_size_);
                     h_exec->set_param(0,(long)w->task_spwaned);
                     h_exec->set_param(1,(long)w->division_size);
                     h_exec->set_param(2,(long)(size+w->size));
@@ -334,8 +334,10 @@
         } else if (strcmp(argv[i], "-anum") == 0) {
             array_task_num = atoi(argv[i+1]);
             i++;
-        } else if (strcmp(argv[i], "-g") == 0 ) {
+        } else if (strcmp(argv[i], "-g") == 0) {
             spe_cpu = GPU_ANY;
+        } else if (strcmp(argv[i], "-any") == 0) {
+            spe_cpu = ANY_ANY;
         } else if (strcmp(argv[i], "-i") == 0) {
             use_iterate = 1;
             use_task_array = 0;
--- a/example/word_count/ppe/Exec_Data_Parallel.cc	Sat Jan 04 19:30:26 2014 +0900
+++ b/example/word_count/ppe/Exec_Data_Parallel.cc	Sun Jan 12 10:28:52 2014 +0900
@@ -13,10 +13,10 @@
     long division_size = (long)s->get_param(1);
     long length = (long)s->get_param(2);
     long out_size = (long)s->get_param(3);
-    
+    printf("%ld\n",task_spwaned);
     long allocation = task_spwaned + (long)s->x;
-    char *i_data = (char *)rbuf + allocation*division_size;
-    unsigned long long *o_data = (unsigned long long*)wbuf + allocation*out_size;
+    char* i_data = (char*)s->get_input(rbuf,0) + allocation*division_size;
+    unsigned long long* o_data = (unsigned long long*)s->get_output(wbuf,0) + allocation*out_size;
     unsigned long long *head_tail_flag = o_data +2;
     int word_flag = 0;
     int word_num = 0;