Commit 3b3ea787 authored by Martin Perdacher's avatar Martin Perdacher

corrected randomgenerator

parent d4fa2b90
...@@ -60,7 +60,7 @@ void parsing_args(int argc, char* argv[], size_t *n, double *epsilon, size_t *d, ...@@ -60,7 +60,7 @@ void parsing_args(int argc, char* argv[], size_t *n, double *epsilon, size_t *d,
}else{ }else{
switch(c){ switch(c){
case 'b': case 'b':
*isBinary = true; *isBinary = true;
break; break;
case '?': case '?':
fprintf (stderr, "Unknown option `-%c'.\n", optopt); fprintf (stderr, "Unknown option `-%c'.\n", optopt);
...@@ -72,7 +72,7 @@ void parsing_args(int argc, char* argv[], size_t *n, double *epsilon, size_t *d, ...@@ -72,7 +72,7 @@ void parsing_args(int argc, char* argv[], size_t *n, double *epsilon, size_t *d,
} }
} }
if ( *blocksize > *n /* * 1000 */ || *blocksize <= 1 ){ if ( *blocksize > *n * 1000 || *blocksize <= 1 ){
fprintf (stderr, "Blocksize has to be greater than 1 and smaller or equal to N\n"); fprintf (stderr, "Blocksize has to be greater than 1 and smaller or equal to N\n");
printf("n:%d, blocksize: %d\n", *n * 1000, *blocksize); printf("n:%d, blocksize: %d\n", *n * 1000, *blocksize);
exit(1); exit(1);
......
...@@ -5,11 +5,17 @@ void random_init(double *array, const int N, const int D){ ...@@ -5,11 +5,17 @@ void random_init(double *array, const int N, const int D){
short unsigned seed[3]; short unsigned seed[3];
int i; int i;
seed[0]=1; seed[1]=1; seed[2]=2; #pragma omp parallel
{
#pragma omp parallel for firstprivate(seed) int tId = omp_get_thread_num();
for ( i=0 ; i < N * D ; i++ ){ seed[0]=(((tId*tId + 15) * 3)/7);
array[i] = erand48(seed) * 100.0; seed[1]=(((tId*tId + 13) * 2)/3);
seed[2]=tId;
#pragma omp for
for ( i=0 ; i < N * D ; i++ ){
array[i] = erand48(seed) * 100.0;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment