Skip to content

Commit

Permalink
Print info about OMP_STACKSIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrack committed Sep 29, 2021
1 parent b93b6e1 commit 47f9fa0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
37 changes: 28 additions & 9 deletions src/base/machine.F
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ MODULE machine
PUBLIC :: m_walltime, m_datum, m_hostnm, m_flush, &
m_getcwd, m_getlog, m_getpid, m_procrun, m_abort, &
m_chdir, m_mov, m_memory, m_memory_details, m_energy, &
m_cpuinfo, m_cpuid_static, m_cpuid, m_cpuid_name
m_cpuinfo, m_cpuid_static, m_cpuid, m_cpuid_name, &
m_get_omp_stacksize

INTERFACE
! **********************************************************************************************
Expand Down Expand Up @@ -628,21 +629,39 @@ END SUBROUTINE m_mov
!> \param user ...
! **************************************************************************************************
SUBROUTINE m_getlog(user)
CHARACTER(len=*), INTENT(OUT) :: user
INTEGER :: status
CHARACTER(LEN=*), INTENT(OUT) :: user
INTEGER :: istat
! on a posix system LOGNAME should be defined
CALL get_environment_variable("LOGNAME", value=user, status=status)
CALL get_environment_variable("LOGNAME", value=user, status=istat)
! nope, check alternative
IF (status /= 0) &
CALL get_environment_variable("USER", value=user, status=status)
IF (istat /= 0) &
CALL get_environment_variable("USER", value=user, status=istat)
! nope, check alternative
IF (status /= 0) &
CALL get_environment_variable("USERNAME", value=user, status=status)
IF (istat /= 0) &
CALL get_environment_variable("USERNAME", value=user, status=istat)
! fall back
IF (status /= 0) &
IF (istat /= 0) &
user = "<unknown>"
END SUBROUTINE m_getlog
! **************************************************************************************************
!> \brief Retrieve environment variable OMP_STACKSIZE
!> \param omp_stacksize Value of OMP_STACKSIZE
! **************************************************************************************************
SUBROUTINE m_get_omp_stacksize(omp_stacksize)
CHARACTER(LEN=*), INTENT(OUT) :: omp_stacksize
INTEGER :: istat
omp_stacksize = ""
CALL get_environment_variable("OMP_STACKSIZE", value=omp_stacksize, status=istat)
! Fall back, if OMP_STACKSIZE is not set
IF (istat /= 0) omp_stacksize = "default"
END SUBROUTINE m_get_omp_stacksize
END MODULE machine
18 changes: 9 additions & 9 deletions src/environment.F
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,9 @@ MODULE environment
dp,&
int_8,&
print_kind_info
USE machine, ONLY: flush_should_flush,&
m_cpuid,&
m_cpuid_name,&
m_cpuid_static,&
m_cpuinfo,&
m_energy,&
m_memory_details,&
m_procrun
USE machine, ONLY: &
flush_should_flush, m_cpuid, m_cpuid_name, m_cpuid_static, m_cpuinfo, m_energy, &
m_get_omp_stacksize, m_memory_details, m_procrun
USE message_passing, ONLY: add_mp_perf_env,&
describe_mp_perf_env,&
mp_collect_timings,&
Expand Down Expand Up @@ -490,7 +485,7 @@ SUBROUTINE read_global_section(root_section, para_env, globenv)

CHARACTER(LEN=6), PARAMETER :: start_section_label = "GLOBAL"

CHARACTER(len=13) :: tracing_string
CHARACTER(len=13) :: omp_stacksize, tracing_string
CHARACTER(len=6) :: print_level_string
CHARACTER(len=default_path_length) :: basis_set_file_name, coord_file_name, &
mm_potential_file_name, &
Expand Down Expand Up @@ -848,6 +843,11 @@ SUBROUTINE read_global_section(root_section, para_env, globenv)
num_threads, &
start_section_label//"| This output is from process", para_env%mepos

CALL m_get_omp_stacksize(omp_stacksize)
WRITE (UNIT=output_unit, FMT="(T2,A,T68,A13)") &
start_section_label//"| Stack size for threads created by OpenMP (OMP_STACKSIZE)", &
ADJUSTR(omp_stacksize)

CALL m_cpuinfo(model_name)
WRITE (UNIT=output_unit, FMT="(T2,A,T30,A51)") &
start_section_label//"| CPU model name", ADJUSTR(TRIM(model_name))
Expand Down
4 changes: 3 additions & 1 deletion tools/regtesting/do_regtest
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,9 @@ file_info
echo "---------------------------- Settings ------------------------------------"
echo "maxtasks = ${maxtasks}"
echo "numprocs = ${numprocs}"
echo "OMP_NUM_THREADS = ${OMP_NUM_THREADS}"
echo "OMP_NUM_THREADS = ${OMP_NUM_THREADS:-(default)}"
echo "OMP_STACKSIZE = ${OMP_STACKSIZE:-(default)}"
echo "KMP_STACKSIZE = ${KMP_STACKSIZE:-(not set)}"
echo "cp2k_run_prefix = ${cp2k_run_prefix}"
echo "cp2k_run_postfix = ${cp2k_run_postfix}"
echo "cp2k_prefix = ${cp2k_prefix}"
Expand Down

0 comments on commit 47f9fa0

Please sign in to comment.