From ddba210c28597169425baf0b1efb82242fd0cde6 Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Thu, 3 Nov 2011 15:19:58 +0100 Subject: [PATCH] add timing information --- openmp/merge/sort.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openmp/merge/sort.c b/openmp/merge/sort.c index 4e32478..6cb9e2b 100644 --- a/openmp/merge/sort.c +++ b/openmp/merge/sort.c @@ -78,6 +78,7 @@ int main ( int argc, char ** argv) { int opt, i; int a_len, b_len, b_len_end, b_len_begin; int * c; + double startTime, endTime; while ((opt = getopt(argc, argv, "t:")) != -1) { switch (opt) { @@ -99,6 +100,8 @@ int main ( int argc, char ** argv) { //printlist("0 Sorted List A:", a); //printlist("0 Sorted List B:", b); + startTime = omp_get_wtime(); + a_len = n/p; #pragma omp parallel for shared(a,b,c,n,p,a_len) private(i,b_len_begin,b_len_end,b_len) for (i = 0; i < p; i++) { @@ -122,6 +125,9 @@ int main ( int argc, char ** argv) { &c[i*a_len+b_len_begin]); } + endTime = omp_get_wtime(); + printf(" took %f seconds.\n", endTime-startTime); + //printlist("Sorted List:", c); free(c); return 0; -- 2.43.0