From 8c0e068cb06022b63f36fc6d58c1368153532d43 Mon Sep 17 00:00:00 2001 From: "jan.reininghaus" Date: Wed, 30 Apr 2014 08:56:30 +0000 Subject: changed chunk size for single threaded chunk_reduction.h git-svn-id: https://phat.googlecode.com/svn/trunk@163 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d --- include/phat/algorithms/chunk_reduction.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/phat/algorithms/chunk_reduction.h b/include/phat/algorithms/chunk_reduction.h index 0e096b5..32a0fe0 100644 --- a/include/phat/algorithms/chunk_reduction.h +++ b/include/phat/algorithms/chunk_reduction.h @@ -32,15 +32,18 @@ namespace phat { template< typename Representation > void operator() ( boundary_matrix< Representation >& boundary_matrix ) { + const index nr_columns = boundary_matrix.get_num_cols(); + if( omp_get_max_threads( ) > nr_columns ) + omp_set_num_threads( 1 ); + const dimension max_dim = boundary_matrix.get_max_dim(); std::vector< index > lowest_one_lookup( nr_columns, -1 ); std::vector < column_type > column_type( nr_columns, GLOBAL ); std::vector< char > is_active( nr_columns, false ); - //const index chunk_size = (index) sqrt( (double)nr_columns ); - const index chunk_size = nr_columns / omp_get_max_threads( ); + const index chunk_size = omp_get_max_threads() == 1 ? (index)sqrt( (double)nr_columns ) : nr_columns / omp_get_max_threads(); std::vector< index > chunk_boundaries; for( index cur_boundary = 0; cur_boundary < nr_columns; cur_boundary += chunk_size ) -- cgit v1.2.3