#include "bsp_3_lib_bench_par.h" #include #include using namespace std; int main() { benchmark_B(8000,8000,400); benchmark_B_par(8000,8000,400); benchmark_C(4000,4000,4000,1); benchmark_C_par(4000,4000,4000,1); benchmark_D(1e4,1e5,15); benchmark_D_par(1e4,1e5,15); // comparing the time for sum and inner product with and without parallelization cout << "\nComparing the runtime (in sec) for inner product and sum with and without parallelization\n\n"; for(int k=3; k<=8; ++k) { int N = pow(10,k); cout << "k = " << k << " N = " << N << endl; vector v1(N,1.0/N); vector v2(N,N); auto tstart = omp_get_wtime(); double s = scalar(v1, v2); auto t_diff_scalar = omp_get_wtime() - tstart; tstart = omp_get_wtime(); double sp = scalar_par(v1, v2); auto t_diff_scalar_par = omp_get_wtime() - tstart; tstart = omp_get_wtime(); double su = sum(v1); auto t_diff_sum = omp_get_wtime() - tstart; tstart = omp_get_wtime(); double sup = sum_par(v1); auto t_diff_sum_par = omp_get_wtime() - tstart; cout << "sum " << t_diff_sum << " inner_prod " << t_diff_scalar << endl; cout << "sum_par " << t_diff_sum_par << " inner_prod_par " << t_diff_scalar_par << endl << endl;; } return 0; }