Commit f8b7ddb9 authored by Andreas Marek's avatar Andreas Marek
Browse files

Fix a newly introduced error in OpenMP code path

parent 6385071d
...@@ -438,7 +438,6 @@ ...@@ -438,7 +438,6 @@
#ifdef WITH_OPENMP #ifdef WITH_OPENMP
call obj%timer%start("OpenMP parallel" // PRECISION_SUFFIX) call obj%timer%start("OpenMP parallel" // PRECISION_SUFFIX)
! OPENMP_CHANGE here
!$OMP PARALLEL PRIVATE(i,my_thread,delta,s,info,j) !$OMP PARALLEL PRIVATE(i,my_thread,delta,s,info,j)
my_thread = omp_get_thread_num() my_thread = omp_get_thread_num()
!$OMP DO !$OMP DO
......
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
&_impl &_impl
use elpa use elpa
use elpa_abstract_impl use elpa_abstract_impl
#ifdef WITH_OPENMP
use omp_lib
#endif
implicit none implicit none
integer(kind=ik) :: na, nev, ldq, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols integer(kind=ik) :: na, nev, ldq, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols
real(kind=REAL_DATATYPE) :: d(na), e(na) real(kind=REAL_DATATYPE) :: d(na), e(na)
...@@ -75,6 +78,9 @@ ...@@ -75,6 +78,9 @@
logical :: success ! the return value logical :: success ! the return value
integer :: error integer :: error
class(elpa_t), pointer :: obj class(elpa_t), pointer :: obj
#ifdef WITH_OPENMP
integer :: nrThreads
#endif
!call timer%start("elpa_solve_tridi_& !call timer%start("elpa_solve_tridi_&
!&PRECISION& !&PRECISION&
...@@ -132,6 +138,14 @@ ...@@ -132,6 +138,14 @@
return return
endif endif
#ifdef WITH_OPENMP
nrThreads = omp_get_max_threads()
call obj%set("omp_threads", nrThreads, error)
#else
call obj%set("omp_threads", 1, error)
#endif
if (wantDebug) then if (wantDebug) then
call obj%set("debug",1, error) call obj%set("debug",1, error)
if (error .ne. ELPA_OK) then if (error .ne. ELPA_OK) then
......
...@@ -708,14 +708,12 @@ static int omp_threads_cardinality(elpa_index_t index) { ...@@ -708,14 +708,12 @@ static int omp_threads_cardinality(elpa_index_t index) {
if (set_max_threads_glob == 0) { if (set_max_threads_glob == 0) {
max_threads_glob = omp_get_max_threads(); max_threads_glob = omp_get_max_threads();
set_max_threads_glob = 1; set_max_threads_glob = 1;
//printf("Setting global max threads to %d \n",max_threads_glob);
} }
#else #else
max_threads_glob = 1; max_threads_glob = 1;
set_max_threads_glob = 1; set_max_threads_glob = 1;
#endif #endif
max_threads = max_threads_glob; max_threads = max_threads_glob;
//printf("Setting max threads to %d \n",max_threads);
return max_threads; return max_threads;
} }
...@@ -726,11 +724,15 @@ static int omp_threads_enumerate(elpa_index_t index, int i) { ...@@ -726,11 +724,15 @@ static int omp_threads_enumerate(elpa_index_t index, int i) {
static int omp_threads_is_valid(elpa_index_t index, int n, int new_value) { static int omp_threads_is_valid(elpa_index_t index, int n, int new_value) {
int max_threads; int max_threads;
#ifdef WITH_OPENMP #ifdef WITH_OPENMP
max_threads = max_threads_glob; if (set_max_threads_glob == 0) {
max_threads_glob = omp_get_max_threads();
set_max_threads_glob = 1;
}
#else #else
max_threads = 1; max_threads_glob = 1;
set_max_threads_glob = 1;
#endif #endif
//printf("In valid max threads to %d \n",max_threads); max_threads = max_threads_glob;
return (1 <= new_value) && (new_value <= max_threads); return (1 <= new_value) && (new_value <= max_threads);
} }
......
...@@ -120,6 +120,9 @@ program test ...@@ -120,6 +120,9 @@ program test
#ifdef HAVE_REDIRECT #ifdef HAVE_REDIRECT
use test_redirect use test_redirect
#endif
#ifdef WITH_OPENMP
use omp_lib
#endif #endif
implicit none implicit none
...@@ -176,6 +179,10 @@ program test ...@@ -176,6 +179,10 @@ program test
do_test_toeplitz_eigenvalues, do_test_cholesky, & do_test_toeplitz_eigenvalues, do_test_cholesky, &
do_test_hermitian_multiply do_test_hermitian_multiply
#ifdef WITH_OPENMP
integer :: max_threads
#endif
call read_input_parameters_traditional(na, nev, nblk, write_to_file, skip_check_correctness) call read_input_parameters_traditional(na, nev, nblk, write_to_file, skip_check_correctness)
call setup_mpi(myid, nprocs) call setup_mpi(myid, nprocs)
#ifdef HAVE_REDIRECT #ifdef HAVE_REDIRECT
...@@ -568,6 +575,12 @@ program test ...@@ -568,6 +575,12 @@ program test
assert_elpa_ok(error) assert_elpa_ok(error)
#endif #endif
#ifdef WITH_OPENMP
max_threads=omp_get_max_threads()
call e%set("omp_threads", max_threads, error)
assert_elpa_ok(error)
#endif
if (myid == 0) print *, "" if (myid == 0) print *, ""
#ifdef TEST_ALL_KERNELS #ifdef TEST_ALL_KERNELS
......
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