changeset 1568:767d99d95fbc draft

refactoring
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Sat, 16 Mar 2013 17:47:44 +0900
parents 4ef32873b5be
children ad622d24ac5a
files TaskManager/kernel/ppe/TaskManager.cc TaskManager/kernel/ppe/TaskManager.h example/multiply/main.cc
diffstat 3 files changed, 19 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/TaskManager.cc	Fri Mar 15 07:00:34 2013 +0900
+++ b/TaskManager/kernel/ppe/TaskManager.cc	Sat Mar 16 17:47:44 2013 +0900
@@ -42,7 +42,6 @@
 void
 TaskManager::finish()
 {
-    delete ndr;
     delete m_impl;
 }
 
--- a/TaskManager/kernel/ppe/TaskManager.h	Fri Mar 15 07:00:34 2013 +0900
+++ b/TaskManager/kernel/ppe/TaskManager.h	Sat Mar 16 17:47:44 2013 +0900
@@ -9,6 +9,11 @@
 class MemList;
 
 typedef struct nd_range {
+    nd_range() {
+        dimension = 1;
+        gws[0]=1; gws[0]=1; gws[0]=1;
+        lws[0]=1; lws[0]=1; lws[0]=1;
+    }
     cl_uint dimension;
     size_t gws[3];
     size_t lws[3];
@@ -23,7 +28,6 @@
     /* variables */
     TaskManagerImpl *m_impl;
     void (*tm_end)(TaskManager *manager);
-    ND_RANGE_T_PTR ndr;
 
     /* user function */
     HTaskPtr create_task(int cmd);
--- a/example/multiply/main.cc	Fri Mar 15 07:00:34 2013 +0900
+++ b/example/multiply/main.cc	Sat Mar 16 17:47:44 2013 +0900
@@ -4,13 +4,6 @@
 #include <sys/time.h>
 #include "TaskManager.h"
 #include "Func.h"
-/*
-typedef struct nd_range {
-    int dimension;
-    size_t gws[3];
-    size_t lws[3];
-} ND_RANGE_T, *ND_RANGE_T_PTR;
-*/
 
 extern void task_init(void);
 static int task = 1;
@@ -19,9 +12,10 @@
 void TMend(TaskManager *);
 
 float *A,*B,*C;
+ND_RANGE_T_PTR ndr;
 
-static double st_time;
-static double ed_time;
+static double st_time = 0 ;
+static double ed_time = 0;
 
 static double
 getTime() {
@@ -74,15 +68,12 @@
         B[i]=(float)i/10.f;
     }
     st_time = getTime();
-    /**
-     * Create Task
-     *   create_task(Task ID);
-     */
 
-    ND_RANGE_T_PTR ndr = new ND_RANGE_T;
-    ndr->dimension = 1;
-    ndr->gws[0] = length; ndr->gws[1] = 1; ndr->gws[2] = 1;
-    ndr->lws[0] = 1;   ndr->lws[1] = 1; ndr->lws[2] = 1;
+    // set ND_RANGE parameter
+    // 初期値は全部1になっている
+    ndr = new ND_RANGE_T;
+    
+    ndr->gws[0] = length;
     manager->set_NDRange(ndr);
 
     multiply = manager->create_task(MULTIPLY_TASK);
@@ -116,7 +107,6 @@
 int
 TMmain(TaskManager *manager,int argc, char *argv[])
 {
-    st_time = getTime();
     init(argc, argv);
     // Task Register
     //   ppe/task_init.cc
@@ -124,9 +114,8 @@
     for (int i = 0; i < task; ++i) {
         multi_init(manager);
     }
-
+    st_time = getTime();
     manager->set_TMend(TMend);
-
     return 0;
 }
 
@@ -137,4 +126,9 @@
     print_result();
     check_data();
     printf("Time: %0.6f\n",ed_time-st_time);
+
+    delete A;
+    delete B;
+    delete C;
+    delete ndr;
 }