From d4c7ef6903b5cea01fdfa0ebf10ce311537eb865 Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <pedro.gonnet@durham.ac.uk> Date: Mon, 27 May 2013 22:58:01 +0000 Subject: [PATCH] limit parallelism. Former-commit-id: 8b79fd206af30e488ab8d8a8e25548536bd1437a --- src/space.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/space.c b/src/space.c index 1fa18b8698..8943eaa5e8 100644 --- a/src/space.c +++ b/src/space.c @@ -589,16 +589,33 @@ void parts_sort_rec ( struct part *parts , int *ind , int N , int min , int max error( "Sorting failed (>pivot)." ); } */ - /* Recurse on the left? */ - if ( j > 0 && pivot > min ) { - #pragma omp task untied - parts_sort( parts , ind , j+1 , min , pivot ); + /* Bother going parallel? */ + if ( N < 100 ) { + + /* Recurse on the left? */ + if ( j > 0 && pivot > min ) + parts_sort( parts , ind , j+1 , min , pivot ); + + /* Recurse on the right? */ + if ( i < N && pivot+1 < max ) + parts_sort( &parts[i], &ind[i], N-i , pivot+1 , max ); + } + + else { + + /* Recurse on the left? */ + if ( j > 0 && pivot > min ) { + #pragma omp task untied + parts_sort( parts , ind , j+1 , min , pivot ); + } - /* Recurse on the right? */ - if ( i < N && pivot+1 < max ) { - #pragma omp task untied - parts_sort( &parts[i], &ind[i], N-i , pivot+1 , max ); + /* Recurse on the right? */ + if ( i < N && pivot+1 < max ) { + #pragma omp task untied + parts_sort( &parts[i], &ind[i], N-i , pivot+1 , max ); + } + } } -- GitLab