diff --git a/A2/Makefile b/A2/Makefile index 5544ddd..52c6211 100755 --- a/A2/Makefile +++ b/A2/Makefile @@ -1,12 +1,12 @@ CC = gcc CFLAGS = -std=gnu99 -O3 -fopenmp -Wall BIN = assignment2 all: $(BIN) -$(BIN): assignment2.c utility.h algorithm_T_tile.c +$(BIN): assignment2.c utility.h algorithm_chunks.c $(CC) $(CFLAGS) $< -o $@ clean: rm -f $(BIN) *.o diff --git a/A2/cestino/algorithm_chunks.c b/A2/algorithm_chunks.c similarity index 96% rename from A2/cestino/algorithm_chunks.c rename to A2/algorithm_chunks.c index c4c6550..1473632 100644 --- a/A2/cestino/algorithm_chunks.c +++ b/A2/algorithm_chunks.c @@ -1,57 +1,57 @@ /* ============================================================================ Filename : algorithm.c Author : Your names go here SCIPER : Your SCIPER numbers ============================================================================ */ #include #define INPUT(I,J) input[(I)*length+(J)] #define OUTPUT(I,J) output[(I)*length+(J)] void simulate(double *input, double *output, int threads, int length, int iterations) { double *temp; omp_set_num_threads(threads); for(int n=0; n < iterations; n++) { //int th_index; int tid; const int B = 4; // size of block const int jump = threads * B; const int N2 = length * (length-1); - #pragma omp parallel shared(N2, B, jump) + #pragma omp parallel { tid = omp_get_thread_num(); for(int off=length + tid * B; off < N2; off += jump) { for(int k=off; k #include #include #include #include "utility.h" //#include "algorithm_Ancarola.c" //#include "algorithm_test.c" //#include "algorithm.c" //#include "algorithm_slow.c" -#include "algorithm_T_tile.c" +//#include "algorithm_T_tile.c" +//#include "algorithm_2_tile.c" //#include "algorithm_1fork.c" +#include "algorithm_chunks.c" //#include "algorithm_onethread.c" //#include "algorithm_trivial.c" //#include "algorithm_collapse.c" int main (int argc, const char *argv[]) { int threads, length, iterations; double time; if (argc != 5) { printf("Invalid input! \nUsage: ./assignment2 \n"); return 1; } else { threads = atoi(argv[1]); length = atoi(argv[2]); iterations = atoi(argv[3]); if(length%2!=0) { printf("Invalid input! Array length must be even\n"); return 1; } } //Allocate a two-dimensional array double *input = malloc(sizeof(double)*length*length); double *output = malloc(sizeof(double)*length*length); //Initialize the array init(input, length); init(output, length); //Start timer set_clock(); //Optimize the following function simulate(input, output, threads, length, iterations); //Stop timer time = elapsed_time(); //Report time required for n iterations printf("Running the algorithm with %d threads on %d by %d array for %d iterations took %.4g seconds \n", threads, length, length, iterations, time); if(iterations % 2 == 0){ double *temp = input; input = output; output = temp; } //Save array in filelength if the output is not /dev/null // idea: do not save if not needed if (strcmp(argv[4], "/dev/null") != 0) save(output, length, argv[4]); //Free allocated memory free(input); free(output); return 0; } diff --git a/A2/graph/tests_T_tile/slurm-5948045.out b/A2/graph/tests_T_tile/slurm-5948045.out new file mode 100644 index 0000000..c5b1cc0 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948045.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:08 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.106 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.08 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.555 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7924 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.7027 seconds +FINISHED at Mon Oct 26 23:22:20 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948046.out b/A2/graph/tests_T_tile/slurm-5948046.out new file mode 100644 index 0000000..e52e209 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948046.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.003 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.092 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.553 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7954 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6786 seconds +FINISHED at Mon Oct 26 23:22:22 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948047.out b/A2/graph/tests_T_tile/slurm-5948047.out new file mode 100644 index 0000000..00fdc0d --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948047.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.009 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.095 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.554 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7988 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6094 seconds +FINISHED at Mon Oct 26 23:22:23 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948048.out b/A2/graph/tests_T_tile/slurm-5948048.out new file mode 100644 index 0000000..8bb717b --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948048.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.01 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.095 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.554 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7902 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.5986 seconds +FINISHED at Mon Oct 26 23:22:23 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948049.out b/A2/graph/tests_T_tile/slurm-5948049.out new file mode 100644 index 0000000..21ae5e5 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948049.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.002 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.092 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.554 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7896 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6592 seconds +FINISHED at Mon Oct 26 23:22:23 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948050.out b/A2/graph/tests_T_tile/slurm-5948050.out new file mode 100644 index 0000000..edd0174 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948050.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.003 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.096 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.56 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.8068 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.742 seconds +FINISHED at Mon Oct 26 23:22:23 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948051.out b/A2/graph/tests_T_tile/slurm-5948051.out new file mode 100644 index 0000000..f4ddcbf --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948051.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:10 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 5.999 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.071 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.559 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7913 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6846 seconds +FINISHED at Mon Oct 26 23:22:23 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948052.out b/A2/graph/tests_T_tile/slurm-5948052.out new file mode 100644 index 0000000..9681e4f --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948052.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.016 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.072 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.558 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7944 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6547 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948053.out b/A2/graph/tests_T_tile/slurm-5948053.out new file mode 100644 index 0000000..09ca61a --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948053.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.087 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.079 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.562 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7972 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6172 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948054.out b/A2/graph/tests_T_tile/slurm-5948054.out new file mode 100644 index 0000000..b0c5de9 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948054.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.046 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.085 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.556 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.802 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.7206 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948055.out b/A2/graph/tests_T_tile/slurm-5948055.out new file mode 100644 index 0000000..356133b --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948055.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.01 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.093 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.553 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7955 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6888 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948056.out b/A2/graph/tests_T_tile/slurm-5948056.out new file mode 100644 index 0000000..cd20ef1 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948056.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.022 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.09 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.553 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7953 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.7215 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948057.out b/A2/graph/tests_T_tile/slurm-5948057.out new file mode 100644 index 0000000..f15a589 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948057.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.003 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.089 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.555 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7972 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.7139 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948058.out b/A2/graph/tests_T_tile/slurm-5948058.out new file mode 100644 index 0000000..03941e3 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948058.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:22:46 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.003 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.072 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.556 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7855 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6028 seconds +FINISHED at Mon Oct 26 23:22:58 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948059.out b/A2/graph/tests_T_tile/slurm-5948059.out new file mode 100644 index 0000000..b393684 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948059.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.124 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.077 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.557 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7875 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6081 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948060.out b/A2/graph/tests_T_tile/slurm-5948060.out new file mode 100644 index 0000000..8c7a265 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948060.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 5.998 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.084 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.565 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7915 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6952 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948061.out b/A2/graph/tests_T_tile/slurm-5948061.out new file mode 100644 index 0000000..bf0d2e3 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948061.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.008 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.08 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.561 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7951 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6171 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948062.out b/A2/graph/tests_T_tile/slurm-5948062.out new file mode 100644 index 0000000..93bb82b --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948062.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.029 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.081 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.557 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.789 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6377 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948063.out b/A2/graph/tests_T_tile/slurm-5948063.out new file mode 100644 index 0000000..e9de7b7 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948063.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 5.995 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.093 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.555 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.7905 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6159 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020 diff --git a/A2/graph/tests_T_tile/slurm-5948064.out b/A2/graph/tests_T_tile/slurm-5948064.out new file mode 100644 index 0000000..22b0a74 --- /dev/null +++ b/A2/graph/tests_T_tile/slurm-5948064.out @@ -0,0 +1,7 @@ +STARTING AT Mon Oct 26 23:23:20 CET 2020 +Running the algorithm with 1 threads on 5000 by 5000 array for 50 iterations took 6.026 seconds +Running the algorithm with 2 threads on 5000 by 5000 array for 50 iterations took 3.14 seconds +Running the algorithm with 4 threads on 5000 by 5000 array for 50 iterations took 1.559 seconds +Running the algorithm with 8 threads on 5000 by 5000 array for 50 iterations took 0.8035 seconds +Running the algorithm with 16 threads on 5000 by 5000 array for 50 iterations took 0.6282 seconds +FINISHED at Mon Oct 26 23:23:33 CET 2020