Commit d750493a authored by Martin Perdacher's avatar Martin Perdacher

v.0.99

parent 919ea2f5
......@@ -838,7 +838,7 @@ void test_ego_loop3_macro(size_t n, size_t d, double epsilon, double *array, siz
// printf("%ld ",savedload[NUM_THREADS*s+par]);
}
int test_ego_loop3_noself(const size_t nA, const size_t nB, const int d, const double epsilon, double *arrayA, double *arrayB, size_t *countresult, const int activedims, double *sortTime, double *indextime, double *loadpercent){
void test_ego_loop3_noself(const size_t nA, const size_t nB, const int d, const double epsilon, double *arrayA, double *arrayB, size_t *countresult, const int activedims, double *sortTime, double *indextime, double *loadpercent){
CUtilTimer index_timer,total_timer,sortTimer;
long long result = 0;
long long refinements = 0;
......@@ -904,8 +904,7 @@ int test_ego_loop3_noself(const size_t nA, const size_t nB, const int d, const d
// for(int par=0 ; par<NUM_THREADS ; par++, printf("\n"))
// for(int s=0 ; s<5 ; s++)
// printf("%ld ",savedload[NUM_THREADS*s+par]);
// printf("%ld ",savedload[NUM_THREADS*s+par]);
}
......
......@@ -61,7 +61,7 @@ void outputStatistics(int n, int d, double epsilon, double *array, int *reorder_
void sampleHistograms(int n, int d, double epsilon, double *array, int *reorder_dim);
void prepareStripesNoSelf(int nA, int nB, int d, int activeDimensions, double epsilon, double *A, double *B, int ** lower, int **upper, double *selfA, double *selfB);
int test_ego_loop3_noself(const size_t nA, const size_t nB, const int d, const double epsilon, double *arrayA, double *arrayB, size_t *countresult, const int activedims, double *sortTime, double *indextime, double *loadpercent);
void test_ego_loop3_noself(const size_t nA, const size_t nB, const int d, const double epsilon, double *arrayA, double *arrayB, size_t *countresult, const int activedims, double *sortTime, double *indextime, double *loadpercent);
#define hilbert_swap(i,j) {memcpy(b, (i), size); memcpy((i), (j), size); memcpy((j), b, size);}
#define hilbert_max(a,b) ((a)>(b) ? (a) : (b))
......
......@@ -70,12 +70,12 @@ int main(int argc, char** argv) {
read_file(array, n, d, filename, isBinary);
// printf("readfile ok\n"); fflush(stdout);
// for ( int i=0 ; i < 10 ; i++ ){
// for ( int j=0 ; j < d ; j++ ){
// printf("%f, ", array[i*d+j]);
// }
// printf("\n");
// }
for ( int i=0 ; i < 10 ; i++ ){
for ( int j=0 ; j < d ; j++ ){
printf("%f, ", array[i*d+j]);
}
printf("\n");
}
pmeter.reset(); pmeter.start();
timer.start();
......
......@@ -58,18 +58,37 @@ int main(int argc, char** argv) {
double *x1 = (double*) ddr_alloc(n * sizeof (double) * d + 16384);
double *x2 = (double*) ddr_alloc(m * sizeof (double) * d + 16384);
if ( strcmp(filename,"" ) == 0) {
random_init_unif(x1,n,d,1);
}else{
read_file(x1, n, d, filename, isBinary);
}
// if ( strcmp(filename,"" ) == 0) {
// // random_init_unif(x1,n,d,1);
// random_init_8_selective(x1,n,d,1);
// }else{
// read_file(x1, n, d, filename, isBinary);
// }
// char filenameA[256];
// sprintf(filenameA, "selective8_dims_A_%d_%d_normalized.bin", n,d);
// save_binary_file(x1, n, d, filenameA);
// printf("savedA\n");fflush(stdout);
if ( strcmp(filename2,"" ) == 0) {
random_init_unif(x2,m,d,2);
// random_init_unif(x2,m,d,2);
random_init_8_selective(x2,m,d,2);
}else{
read_file(x2, m, d, filename, isBinary);
}
// char filenameB[256];
// sprintf(filenameB, "selective8_dims_B_%d_%d_normalized.bin", m,d);
// save_binary_file(x2, m, d, filenameB);
// printf("savedB\n");fflush(stdout);
//
// for ( int i=m-3 ; i < m ; i++ ){
// for ( int j=0 ; j < d ; j++ ){
// printf("%f, ", x2[i*d+j] );
// }
// printf("\n");
// }
// pmeter.reset(); pmeter.start();
timer.start();
......@@ -87,6 +106,7 @@ int main(int argc, char** argv) {
algtimer.start();
#ifdef COUNT_ONLY
test_ego_loop3_noself(n, m, d, epsilon, x1, x2, &result, actdim, &sortTime, &indexTime, &loadpercent);
// test_ego_loop3_macro(n,d,epsilon,array,&result,stripes,&sortTime,&indexTime,&loadpercent);
// test_ego_loop3_macro(n,d,threads,epsilon,array,&result,stripes,&sortTime);
#else
......@@ -113,7 +133,7 @@ int main(int argc, char** argv) {
double jp_per_point = (result == 0 ) ? 0 : (double)result / n ;
// HEADER:
// N;D;JPPP;THREADS;EPSILON;STRIPES;KBLOCK;TIME;ALGTIME;SORTTIME;INDEXTIME;REORDERTIME;COUNTS;LOADPERCENT;WH
printf("%zu;%zu;%f;%zu;%2.14f;%d;%d;%f;%f;%f;%f;%f;%ld;%f;%f\n", n,d,jp_per_point, NUM_THREADS,epsilon,stripes,KBLOCK,algtime+reorderTime,algtime - sortTime,sortTime,indexTime,reorderTime,result,loadpercent,watthours);
printf("%zu;%zu;%zu;%f;%zu;%2.14f;%d;%d;%f;%f;%f;%f;%f;%ld;%f;%f\n", n,m,d,jp_per_point, NUM_THREADS,epsilon,stripes,KBLOCK,algtime+reorderTime,algtime - sortTime,sortTime,indexTime,reorderTime,result,loadpercent,watthours);
ddr_free(x1);
ddr_free(x2);
......
......@@ -97,7 +97,7 @@ void parsing_args_join(int argc, char* argv[], size_t *n, size_t *m, double *eps
exit(1);
}
while ( (c = getopt(argc, argv, "n:m:e:d:t:f:k:a:b") ) != -1) {
while ( (c = getopt(argc, argv, "n:m:e:d:t:f:g:k:a:b") ) != -1) {
if ( optarg ){
switch(c){
......@@ -120,7 +120,7 @@ void parsing_args_join(int argc, char* argv[], size_t *n, size_t *m, double *eps
strcpy(filename, optarg);
break;
case 'g':
strcpy(filename, optarg);
strcpy(filename2, optarg);
break;
case '?':
if (optopt == 'c')
......
......@@ -2,8 +2,7 @@
#include "dataIo.h"
void random_init_unif(double *array, const int N, const int D, const int INIT_SEED){
#pragma omp parallel
{
const int ME = omp_get_thread_num();
const int ALL_THREADS = omp_get_num_threads();
VSLStreamStatePtr stream;
......@@ -18,18 +17,66 @@ void random_init_unif(double *array, const int N, const int D, const int INIT_SE
exit(1);
}
const int imin = (N / ALL_THREADS) * ME;
const int imax = (ME == ALL_THREADS - 1 ) ? N : (N / ALL_THREADS) * (ME+1);
const int MY_N = imax - imin;
// const int imin = (N / ALL_THREADS) * ME;
// const int imax = (ME == ALL_THREADS - 1 ) ? N : (N / ALL_THREADS) * (ME+1);
// const int MY_N = imax - imin;
errcode = vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream, MY_N * D, &array[imin*D], LOWER_BOUND, UPPER_BOUND);
errcode = vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream, N * D, &array[0], LOWER_BOUND, UPPER_BOUND);
if ( errcode != VSL_ERROR_OK && errcode != VSL_STATUS_OK ){
printf("vslNewStream error. dataIo.cpp line 24.\n");
exit(1);
}
}
void random_init_8_selective(double *array, const int N, const int D, const int INIT_SEED){
const int ME = omp_get_thread_num();
const int ALL_THREADS = omp_get_num_threads();
VSLStreamStatePtr stream;
const int SEED=(ME + 15) * INIT_SEED;
const double LOWER_BOUND=0.0;
const double UPPER_BOUND=1.0;
int errcode = vslNewStream( &stream, VSL_BRNG_MCG31, SEED);
if ( errcode != VSL_ERROR_OK && errcode != VSL_STATUS_OK ){
printf("vslNewStream error. dataIo.cpp line 9.\n");
exit(1);
}
// const int imin = (N / ALL_THREADS) * ME;
// const int imax = (ME == ALL_THREADS - 1 ) ? N : (N / ALL_THREADS) * (ME+1);
// const int MY_N = imax - imin;
errcode = vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream, 1 * D, &array[0], LOWER_BOUND, UPPER_BOUND); // first value always 0
errcode = vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream, N * D, &array[0], LOWER_BOUND, UPPER_BOUND);
if ( errcode != VSL_ERROR_OK && errcode != VSL_STATUS_OK ){
printf("vslNewStream error. dataIo.cpp line 24.\n");
exit(1);
}
// // test output (sanity check)
// for ( int i = 0 ; i < 3 ; i++ ){
// for ( int j=0 ; j < D ; j++ ){
// printf("%f ", array[i*D + j]);
// }
// printf("\n");
// }
// write the value of array[i*D+8] in all remaining dimensions (d>8)
#pragma omp parallel for
for ( int i=0 ; i < N ; i++ ){
double value=array[i*D+8];
for ( int j=8; j < D ; j++ ){
array[i*D+j]=value;
}
}
}
void random_init(double *array, const int N, const int D){
......@@ -68,6 +115,7 @@ void read_file(double *array, const int N, const int D, char filename[], const b
if ( IS_BINARY ){
// printf("processing binary file!");fflush(stdout);
// read binary file, everything at once
// printf("binary");
counts = fread(array, N * D, sizeof(double), fp);
// printf("%dx%d: %d readed\n", N, D, counts);
if ( counts == 0 ) {
......@@ -75,6 +123,7 @@ void read_file(double *array, const int N, const int D, char filename[], const b
exit(1);
}
}else{
printf("not binary");
// processing a text file
// format: there are D double values each line. Each value is separated by a space character.
// notice MAX_LINE_LENGTH = 2049
......@@ -104,7 +153,7 @@ void save_binary_file(double *array, const int N, const int D, char filename[]){
FILE *fp=NULL;
size_t counts = 0;
fp = fopen(filename, "w");
fp = fopen(filename, "wb");
if ( fp == NULL ){
fprintf(stderr, "Could not open file '%s'!", filename);
......
......@@ -13,6 +13,7 @@
#define MAX_LINE_LENGTH 2049
void random_init(double *array, const int N, const int D);
void random_init_8_selective(double *array, const int N, const int D, const int INIT_SEED);
void random_init_unif(double *array, const int N, const int D, const int INIT_SEED);
void read_file(double *array, const int N, const int D, char filename[], const bool IS_BINARY);
void save_binary_file(double *array, const int N, const int D, char filename[]);
......
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