Skip to content

Commit

Permalink
Merge pull request #370 from akva2/default_auto_threads
Browse files Browse the repository at this point in the history
Default number of threads to auto
  • Loading branch information
andlaus authored Aug 27, 2018
2 parents f1491c4 + 61354df commit 0f452e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ opm_add_test(waterair_pvs_ni
TEST_ARGS --grid-global-refinements=1)

opm_add_test(lens_immiscible_vcfv_ad
TEST_ARGS --end-time=3000)
TEST_ARGS --end-time=3000 --threads-per-process=1)

opm_add_test(lens_immiscible_vcfv_fd
TEST_ARGS --end-time=3000)
TEST_ARGS --end-time=3000 --threads-per-process=1)

opm_add_test(lens_immiscible_ecfv_ad
TEST_ARGS --end-time=3000)
Expand Down Expand Up @@ -235,10 +235,10 @@ foreach(tapp co2injection_flash_ni_vcfv
opm_add_test(${tapp})
endforeach()

opm_add_test(reservoir_blackoil_vcfv TEST_ARGS --end-time=8750000)
opm_add_test(reservoir_blackoil_vcfv TEST_ARGS --end-time=8750000 --threads-per-process=1)
opm_add_test(reservoir_blackoil_ecfv TEST_ARGS --end-time=8750000)
opm_add_test(reservoir_ncp_vcfv TEST_ARGS --end-time=8750000)
opm_add_test(reservoir_ncp_ecfv TEST_ARGS --end-time=8750000)
opm_add_test(reservoir_ncp_vcfv TEST_ARGS --end-time=8750000 --threads-per-process=1)
opm_add_test(reservoir_ncp_ecfv TEST_ARGS --end-time=8750000 --threads-per-process=1)

opm_add_test(fracture_discretefracture
CONDITION ${DUNE_ALUGRID_FOUND}
Expand Down Expand Up @@ -278,15 +278,15 @@ opm_add_test(lens_immiscible_vcfv_fd_parallel
PROCESSORS 4
CONDITION ${MPI_FOUND}
DRIVER_ARGS --parallel-simulation=4
TEST_ARGS --end-time=250 --initial-time-step-size=250)
TEST_ARGS --end-time=250 --initial-time-step-size=250 --threads-per-process=1)

opm_add_test(lens_immiscible_vcfv_ad_parallel
EXE_NAME lens_immiscible_vcfv_ad
NO_COMPILE
PROCESSORS 4
CONDITION ${MPI_FOUND}
DRIVER_ARGS --parallel-simulation=4
TEST_ARGS --end-time=250 --initial-time-step-size=250)
TEST_ARGS --end-time=250 --initial-time-step-size=250 --threads-per-process=1)

opm_add_test(lens_immiscible_ecfv_ad_parallel
EXE_NAME lens_immiscible_ecfv_ad
Expand Down
2 changes: 1 addition & 1 deletion ewoms/disc/common/fvbasediscretization.hh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ SET_TYPE_PROP(FvBaseDiscretization, ConstraintsContext, Ewoms::FvBaseConstraints
* \brief The OpenMP threads manager
*/
SET_TYPE_PROP(FvBaseDiscretization, ThreadManager, Ewoms::ThreadManager<TypeTag>);
SET_INT_PROP(FvBaseDiscretization, ThreadsPerProcess, 1);
SET_INT_PROP(FvBaseDiscretization, ThreadsPerProcess, -1);
SET_BOOL_PROP(FvBaseDiscretization, UseLinearizationLock, true);

/*!
Expand Down
6 changes: 6 additions & 0 deletions ewoms/parallel/threadmanager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public:
// used in the end.
if (numThreads_ > 0)
omp_set_num_threads(numThreads_);
else {
if (!getenv("OMP_NUM_THREADS")) {
int num_core = omp_get_num_procs();
omp_set_num_threads(std::min(2, num_core));
}
}

numThreads_ = omp_get_max_threads();
#endif
Expand Down

0 comments on commit 0f452e7

Please sign in to comment.