summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorjan.reininghaus <jan.reininghaus@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2014-04-30 08:56:30 +0000
committerjan.reininghaus <jan.reininghaus@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2014-04-30 08:56:30 +0000
commit8c0e068cb06022b63f36fc6d58c1368153532d43 (patch)
tree7387e055686eebc77d8d41f4298de8b2060b5a94 /include
parentfe4b78f9280469f9f99836a8c0c9c1ee140825c6 (diff)
changed chunk size for single threaded chunk_reduction.h
git-svn-id: https://phat.googlecode.com/svn/trunk@163 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d
Diffstat (limited to 'include')
-rw-r--r--include/phat/algorithms/chunk_reduction.h7
1 files changed, 5 insertions, 2 deletions
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 )