mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Create use_all_threads variable instead of n_threads
This commit is contained in:
parent
0ce75aa21b
commit
8e0b616075
4 changed files with 19 additions and 26 deletions
|
|
@ -32,9 +32,7 @@ int nx, ny, nz, ng;
|
|||
|
||||
xt::xtensor<int, 2> indexmap;
|
||||
|
||||
int n_threads;
|
||||
|
||||
int n_threads_reset;
|
||||
int use_all_threads;
|
||||
|
||||
} // namespace cmfd
|
||||
|
||||
|
|
@ -108,7 +106,7 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
|||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction (+:err) num_threads(cmfd::n_threads)
|
||||
#pragma omp parallel for reduction (+:err) if(cmfd::use_all_threads)
|
||||
for (int irow = 0; irow < cmfd::dim; irow++) {
|
||||
int g, i, j, k;
|
||||
matrix_to_indices(irow, g, i, j, k);
|
||||
|
|
@ -175,7 +173,7 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
||||
// Loop around matrix rows
|
||||
#pragma omp parallel for reduction (+:err) num_threads(cmfd::n_threads)
|
||||
#pragma omp parallel for reduction (+:err) if(cmfd::use_all_threads)
|
||||
for (int irow = 0; irow < cmfd::dim; irow+=2) {
|
||||
int g, i, j, k;
|
||||
matrix_to_indices(irow, g, i, j, k);
|
||||
|
|
@ -311,7 +309,7 @@ extern "C"
|
|||
void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
||||
const int* indices, int n_elements, int dim,
|
||||
double spectral, const int* cmfd_indices,
|
||||
const int* map, int n_threads)
|
||||
const int* map, bool use_all_threads)
|
||||
{
|
||||
// Store elements of indptr
|
||||
for (int i = 0; i < len_indptr; i++)
|
||||
|
|
@ -339,12 +337,8 @@ void openmc_initialize_linsolver(const int* indptr, int len_indptr,
|
|||
set_indexmap(map);
|
||||
}
|
||||
|
||||
#ifdef _OPENMP
|
||||
// Set number of threads to run CMFD solver on and store number of threads
|
||||
// to reset to after solver finishes executing
|
||||
cmfd::n_threads = n_threads;
|
||||
cmfd::n_threads_reset = omp_get_max_threads();
|
||||
#endif
|
||||
// Use all threads allocated to OpenMC simulation to run CMFD solver
|
||||
cmfd::use_all_threads = use_all_threads;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue