From abe121ae704208c0c32689f59afcdaa043447421 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Mon, 27 Sep 2021 13:31:04 +0300 Subject: Seems to work now --- makefile | 2 +- test/executables/.place_holder | 0 test/inputs/.place_holder | 0 test/outputs/.place_holder | 0 test/times/.place_holder | 0 test/times/heavy/.place_holder | 0 test/times/normal/.place_holder | 0 threadet.c | 102 ---------------------------------------- 8 files changed, 1 insertion(+), 103 deletions(-) create mode 100644 test/executables/.place_holder create mode 100644 test/inputs/.place_holder create mode 100644 test/outputs/.place_holder create mode 100644 test/times/.place_holder create mode 100644 test/times/heavy/.place_holder create mode 100644 test/times/normal/.place_holder diff --git a/makefile b/makefile index 4bf8a61..01822ff 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ install: - gcc -pthread main.c -o main.exe -L. -lgmp -lnuma + gcc -pthread main.c -o main.exe -L. -lgmp gcc make_heavy.c -o make_heavy.exe clear: diff --git a/test/executables/.place_holder b/test/executables/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/test/inputs/.place_holder b/test/inputs/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/test/outputs/.place_holder b/test/outputs/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/test/times/.place_holder b/test/times/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/test/times/heavy/.place_holder b/test/times/heavy/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/test/times/normal/.place_holder b/test/times/normal/.place_holder new file mode 100644 index 0000000..e69de29 diff --git a/threadet.c b/threadet.c index f1cdfd2..d413ff1 100644 --- a/threadet.c +++ b/threadet.c @@ -15,108 +15,6 @@ mpq_t* threadet(mpq_t **matrix,size_t size,size_t number_of_threads,char verbose); void* dethread(void* thr); void calc_row(mpq_t **matrix,size_t size,size_t target,size_t source); -void split_matrix(mpq_t **matrix,mpq_t ***a,mpq_t ***b,size_t size); - - -void split_matrix(mpq_t **matrix,mpq_t ***a,mpq_t ***b,size_t size,size_t number_of_threads,char verbose) -{ - size_t i; - size_t j; - size_t k; - /* shared thread parameters */ - struct Pair_Dispenser thr; - /* swap */ - mpq_t *hold; - /* array of the threads we are executing. We are going to join these every column of the matrix cleaned because it is a very convinient sync.*/ - pthread_t* threds; - /* result is accumulated here */ - mpq_t *res; - /* placeholder for thread return values. They all return NULL but join() requires a pointer to store return */ - void **temp; - /* we can't clean a column with a zero so we swap a impotent column with a column with a non zero value ( if there is such) */ - char sign; - /* timers REALTIME CLOCK could be fooled by an administrator changing the system time, but is the only guaranteed clock in the posix standart*/ - struct timespec pass_start,pass_finish; - struct timespec start,finish; - - if(verbose==1) - { - clock_gettime(CLOCK_REALTIME,&start); - } - - - - threds=malloc(sizeof(pthread_t*) * number_of_threads); - res=malloc(sizeof(mpq_t)); - temp = malloc(sizeof(void*)); - - Pair_Dispenser_Init(&thr,size,matrix,verbose); - mpq_init(*res); - thr.current.target_row=1; - sign=1; - - for(i=0;isize) - { - mpq_set_d(*res,0); - - free(threds); - free(temp); - if(verbose == 1) - { - clock_gettime(CLOCK_REALTIME,&finish); - finish.tv_sec-=start.tv_sec; - finish.tv_nsec-=start.tv_nsec; - printf("TIME: %f\n",(double)(finish.tv_sec + 0.000000001*finish.tv_nsec)); - } - return res; - }else - { - hold = matrix[j]; - matrix[j] = matrix[i]; - matrix[i] = hold; - /* change the sign approprietly */ - sign = (sign + (j-i)%2)%2; - } - } - if(verbose==1) - { - clock_gettime(CLOCK_REALTIME,&pass_start); - } - /* clean the i-th row this is one pass*/ - - k=((number_of_threads