From 39c70b21be671050f2a224f8cd41d8adf3615d5a Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Sat, 21 Jan 2012 00:57:11 +0100 Subject: [PATCH] set new number of cores --- openmp/merge/sort.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openmp/merge/sort.c b/openmp/merge/sort.c index 8d27047..bee8bc6 100644 --- a/openmp/merge/sort.c +++ b/openmp/merge/sort.c @@ -5,6 +5,13 @@ #include #include "numlist.h" +#ifndef min + #define min( a, b ) ( ((a) < (b)) ? (a) : (b) ) +#endif +#ifndef max + #define max( a, b ) ( ((a) > (b)) ? (a) : (b) ) +#endif + typedef int numtype; void printlist(char * message, numtype * ptr, int len); @@ -14,7 +21,7 @@ void merge(int ti, numtype * a, int n, numtype * b, int m, numtype * c); int main ( int argc, char ** argv) { int n = LISTSIZE, m = LISTSIZE; - int p = 1; + int p = min(omp_get_num_procs(), n); int opt, i; int a_len, b_len, b_len_end, b_len_begin; numtype * c; @@ -31,7 +38,7 @@ int main ( int argc, char ** argv) { } } - //printf ("Maximal number of threads: %i\n", omp_get_max_threads()); + printf ("Number of processes that will be started: %i\n", p); //printf ("----------------------------------\n"); c = (numtype *) malloc((LISTSIZE * 2 + 1) * (sizeof (numtype))); -- 2.43.0