Skip to content

Commit

Permalink
start: show warning when using __ACCELERATE and VECLIB_MAXIMUM_THREAD…
Browse files Browse the repository at this point in the history
…S not set

fixes #1319
  • Loading branch information
dev-zero committed Mar 23, 2021
1 parent 3a74a97 commit b81463b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/start/cp2k.F
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
! **************************************************************************************************
PROGRAM cp2k

USE OMP_LIB, ONLY: omp_set_num_threads
USE OMP_LIB, ONLY: omp_get_max_threads,&
omp_set_num_threads
USE cp2k_info, ONLY: compile_revision,&
cp2k_flags,&
cp2k_version,&
Expand Down Expand Up @@ -125,6 +126,25 @@ PROGRAM cp2k
CALL omp_set_num_threads(1)
ENDIF

#ifdef __ACCELERATE
IF (omp_get_max_threads() > 1) THEN
BLOCK
CHARACTER(len=default_path_length) :: env_var
INTEGER :: veclib_max_threads, ierr
CALL get_environment_variable("VECLIB_MAXIMUM_THREADS", env_var, status=ierr)
veclib_max_threads = 0
IF (ierr == 0) &
READ (env_var, *) veclib_max_threads
IF (ierr == 1 .OR. (ierr == 0 .AND. veclib_max_threads > 1)) THEN
CALL cp_warn(__LOCATION__, &
"macOS' Accelerate framework has its own threading enabled which may interfere"// &
" with the OpenMP threading. You can disable the Accelerate threading by setting"// &
" the environment variable VECLIB_MAXIMUM_THREADS=1")
END IF
END BLOCK
END IF
#endif

i_arg = 0
arg_loop: DO WHILE (i_arg < COMMAND_ARGUMENT_COUNT())
i_arg = i_arg + 1
Expand Down

0 comments on commit b81463b

Please sign in to comment.