mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-28 06:05:44 -04:00
use hwloc to get no. hw cores to set max threads
This commit is contained in:
parent
0d5a8afda6
commit
93cd0215bd
1 changed files with 21 additions and 8 deletions
|
|
@ -1,17 +1,30 @@
|
|||
subroutine util_setmaxthreads()
|
||||
c
|
||||
c sets the number of openmp threads as
|
||||
c number of hw cores / no. of process per node
|
||||
c
|
||||
implicit none
|
||||
#include "global.fh"
|
||||
#include "stdio.fh"
|
||||
integer ncpus,util_getncpus,max_thr,ppn
|
||||
external util_getncpus
|
||||
character*255 env_out
|
||||
integer err8
|
||||
c
|
||||
ncpus=util_getncpus()
|
||||
if(ncpus.ne.0) then
|
||||
call util_getppn(ppn)
|
||||
max_thr=ncpus/ppn
|
||||
if(ga_nodeid().eq.0)write(luout,*) ' ### ncpus max_thr',
|
||||
N ncpus,max_thr
|
||||
call omp_set_num_threads(max_thr)
|
||||
c skip if OMP_NUM_THREADS is set
|
||||
c
|
||||
call get_environment_variable(
|
||||
A "OMP_NUM_THREADS", value=env_out, status=err8)
|
||||
if(err8.ne.0) then
|
||||
ncpus=util_getncpus()
|
||||
if(ncpus.ne.0) then
|
||||
call util_getppn(ppn)
|
||||
max_thr=ncpus/ppn
|
||||
if(ga_nodeid().eq.0)write(luout,97)
|
||||
N ncpus,max_thr
|
||||
call omp_set_num_threads(max_thr)
|
||||
endif
|
||||
endif
|
||||
97 format(2x,'NWChem w/ OpenMP: # of HW cores = ',i4,
|
||||
F /2x,'NWChem w/ OpenMP: nprocs/node = ',i4)
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue