diff example/many_task/sort.cc @ 230:2b114977852d

fix Random
author gongo@localhost.localdomain
date Fri, 13 Feb 2009 10:53:58 +0900
parents d54cbfafcb82
children 00fe05184a02
line wrap: on
line diff
--- a/example/many_task/sort.cc	Thu Feb 12 19:05:02 2009 +0900
+++ b/example/many_task/sort.cc	Fri Feb 13 10:53:58 2009 +0900
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include "TaskManager.h"
 #include "sort.h"
 #include "Func.h"
@@ -16,28 +15,6 @@
 static void sort_restart(void *);
 static void sort_start(void);
 
-
-/**
- * set random seed
- */
-static void
-set_seed(void)
-{
-    FILE *fp;
-    unsigned int seed;
-
-    if ((fp = fopen("/dev/random", "r")) == NULL) {
-	seed = 12345;
-	goto FINISH;
-    }
-
-    fread(&seed, sizeof(unsigned int), 1, fp);
-    fclose(fp);
-
-FINISH:
-    srandom(seed);
-}
-
 /**
  * 一つの block にある data の数が MAX_BLOCK_SIZE 超えないような
  * len の分割数を返す
@@ -91,7 +68,6 @@
 	fsort[i]->add_inData(&data[i*block_num], sizeof(Data)*block_num);
 	fsort[i]->add_outData(&data[i*block_num], sizeof(Data)*block_num);
 	fsort[i]->add_param(block_num);
-	fsort[i]->add_param(i*block_num);
 	fsort[i]->set_cpu(SPE_ANY);
     }
 
@@ -103,7 +79,6 @@
 	fsort[i]->add_inData(&data[i*block_num], sizeof(Data)*last_block_num);
 	fsort[i]->add_outData(&data[i*block_num], sizeof(Data)*last_block_num);
 	fsort[i]->add_param(last_block_num);
-	fsort[i]->add_param(i*block_num);
 	fsort[i]->set_cpu(SPE_ANY);
    }
 
@@ -117,7 +92,6 @@
 	    bsort[i]->add_outData(&data[i*block_num+half_block_num],
 				  sizeof(Data)*block_num);
 	    bsort[i]->add_param(block_num);
-	    bsort[i]->add_param(i*block_num + half_block_num);
 	    bsort[i]->set_cpu(SPE_ANY);
 	}
 
@@ -130,7 +104,6 @@
 	    bsort[i]->add_outData(&data[i*block_num+half_block_num],
 				  sizeof(Data)*last_half_block_num);
 	    bsort[i]->add_param(last_half_block_num);
-	    bsort[i]->add_param(i*block_num + half_block_num);
 	    bsort[i]->set_cpu(SPE_ANY);	
 	}
 	
@@ -153,10 +126,8 @@
     data = (DataPtr)manager->allocate(sizeof(Data)*length);
     data_length = length;
 
-    set_seed();
-
     for (int i = 0; i < length; i++) { 
-        data[i].index = random()%10000;
+        data[i].index = manager->get_random()%10000;
         data[i].ptr   = 0;
     }