Commit e37b1ab9 authored by Jack Poulson's avatar Jack Poulson

Falling back to multithreaded factorization if omp_get_max_threads() is 1.

parent cb3e0217
......@@ -41,12 +41,17 @@ void RunCholeskyFactorization(Int tile_size, Int block_size,
int num_pivots;
#ifdef CATAMARI_OPENMP
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots = OpenMPLowerCholeskyFactorization(tile_size, block_size, matrix);
catamari::SetNumBlasThreads(old_max_threads);
if (omp_get_max_threads() > 1) {
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots =
OpenMPLowerCholeskyFactorization(tile_size, block_size, matrix);
catamari::SetNumBlasThreads(old_max_threads);
} else {
num_pivots = LowerCholeskyFactorization(block_size, matrix);
}
#else
num_pivots = LowerCholeskyFactorization(block_size, matrix);
#endif
......@@ -75,13 +80,17 @@ void RunLDLAdjointFactorization(Int tile_size, Int block_size,
int num_pivots;
#ifdef CATAMARI_OPENMP
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots = OpenMPLowerLDLAdjointFactorization(tile_size, block_size, matrix,
extra_buffer);
catamari::SetNumBlasThreads(old_max_threads);
if (omp_get_max_threads() > 1) {
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots = OpenMPLowerLDLAdjointFactorization(tile_size, block_size,
matrix, extra_buffer);
catamari::SetNumBlasThreads(old_max_threads);
} else {
num_pivots = LowerLDLAdjointFactorization(block_size, matrix);
}
#else
num_pivots = LowerLDLAdjointFactorization(block_size, matrix);
#endif
......@@ -109,13 +118,17 @@ void RunLDLTransposeFactorization(Int tile_size, Int block_size,
int num_pivots;
#ifdef CATAMARI_OPENMP
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots = OpenMPLowerLDLTransposeFactorization(tile_size, block_size,
matrix, extra_buffer);
catamari::SetNumBlasThreads(old_max_threads);
if (omp_get_max_threads() > 1) {
const int old_max_threads = catamari::GetMaxBlasThreads();
catamari::SetNumBlasThreads(1);
#pragma omp parallel
#pragma omp single
num_pivots = OpenMPLowerLDLTransposeFactorization(tile_size, block_size,
matrix, extra_buffer);
catamari::SetNumBlasThreads(old_max_threads);
} else {
num_pivots = LowerLDLTransposeFactorization(block_size, matrix);
}
#else
num_pivots = LowerLDLTransposeFactorization(block_size, matrix);
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment