standard name

This commit is contained in:
Martin Diehl 2021-01-13 12:48:20 +01:00
parent 4b0b288054
commit a7d998dd48
8 changed files with 32 additions and 36 deletions

6
env/CONFIG vendored
View File

@ -1,5 +1,5 @@
# "set"-syntax needed only for tcsh (but works with bash and zsh) # "set"-syntax needed only for tcsh (but works with bash and zsh)
set DAMASK_NUM_THREADS = 4 set OMP_NUM_THREADS = 4
set MSC_ROOT = /opt/msc set MSC_ROOT = /opt/msc
set MSC_VERSION = 2020 set MSC_VERSION = 2020

8
env/DAMASK.csh vendored
View File

@ -10,8 +10,8 @@ source $ENV_ROOT/CONFIG
set path = ($DAMASK_ROOT/bin $path) set path = ($DAMASK_ROOT/bin $path)
set SOLVER=`which DAMASK_grid` set SOLVER=`which DAMASK_grid`
if ( "x$DAMASK_NUM_THREADS" == "x" ) then if ( "x$OMP_NUM_THREADS" == "x" ) then
set DAMASK_NUM_THREADS=1 set OMP_NUM_THREADS=1
endif endif
# currently, there is no information that unlimited stack size causes problems # currently, there is no information that unlimited stack size causes problems
@ -38,13 +38,13 @@ if ( $?prompt ) then
echo "MSC.Marc/Mentat $MSC_ROOT" echo "MSC.Marc/Mentat $MSC_ROOT"
endif endif
echo echo
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo `limit datasize` echo `limit datasize`
echo `limit stacksize` echo `limit stacksize`
echo echo
endif endif
setenv DAMASK_NUM_THREADS $DAMASK_NUM_THREADS setenv OMP_NUM_THREADS $OMP_NUM_THREADS
if ( ! $?PYTHONPATH ) then if ( ! $?PYTHONPATH ) then
setenv PYTHONPATH $DAMASK_ROOT/python setenv PYTHONPATH $DAMASK_ROOT/python
else else

6
env/DAMASK.sh vendored
View File

@ -38,7 +38,7 @@ PATH=${DAMASK_ROOT}/bin:$PATH
SOLVER=$(type -p DAMASK_grid || true 2>/dev/null) SOLVER=$(type -p DAMASK_grid || true 2>/dev/null)
[ "x$SOLVER" == "x" ] && SOLVER=$(blink 'Not found!') [ "x$SOLVER" == "x" ] && SOLVER=$(blink 'Not found!')
[ "x$DAMASK_NUM_THREADS" == "x" ] && DAMASK_NUM_THREADS=1 [ "x$OMP_NUM_THREADS" == "x" ] && OMP_NUM_THREADS=1
# currently, there is no information that unlimited stack size causes problems # currently, there is no information that unlimited stack size causes problems
# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it # still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it
@ -66,7 +66,7 @@ if [ ! -z "$PS1" ]; then
echo -n "MSC.Marc/Mentat " echo -n "MSC.Marc/Mentat "
[ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT [ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT
echo echo
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo -n "heap size " echo -n "heap size "
[[ "$(ulimit -d)" == "unlimited" ]] \ [[ "$(ulimit -d)" == "unlimited" ]] \
&& echo "unlimited" \ && echo "unlimited" \
@ -86,7 +86,7 @@ if [ ! -z "$PS1" ]; then
echo echo
fi fi
export DAMASK_NUM_THREADS export OMP_NUM_THREADS
export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH
for var in BASE STAT SOLVER BRANCH; do for var in BASE STAT SOLVER BRANCH; do

6
env/DAMASK.zsh vendored
View File

@ -30,7 +30,7 @@ PATH=${DAMASK_ROOT}/bin:$PATH
SOLVER=$(which DAMASK_grid || true 2>/dev/null) SOLVER=$(which DAMASK_grid || true 2>/dev/null)
[[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!') [[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!')
[[ "x$DAMASK_NUM_THREADS" == "x" ]] && DAMASK_NUM_THREADS=1 [[ "x$OMP_NUM_THREADS" == "x" ]] && OMP_NUM_THREADS=1
# currently, there is no information that unlimited stack size causes problems # currently, there is no information that unlimited stack size causes problems
# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it # still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it
@ -60,7 +60,7 @@ if [ ! -z "$PS1" ]; then
echo -n "MSC.Marc/Mentat " echo -n "MSC.Marc/Mentat "
[ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT [ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT
echo echo
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS" echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo -n "heap size " echo -n "heap size "
[[ "$(ulimit -d)" == "unlimited" ]] \ [[ "$(ulimit -d)" == "unlimited" ]] \
&& echo "unlimited" \ && echo "unlimited" \
@ -80,7 +80,7 @@ if [ ! -z "$PS1" ]; then
echo echo
fi fi
export DAMASK_NUM_THREADS export OMP_NUM_THREADS
export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH
for var in SOLVER BRANCH; do for var in SOLVER BRANCH; do

View File

@ -26,10 +26,7 @@ class Environment:
@property @property
def options(self): def options(self):
options = {} options = {}
for item in ['DAMASK_NUM_THREADS', for item in ['MSC_ROOT', 'MSC_VERSION']:
'MSC_ROOT',
'MSC_VERSION',
]:
options[item] = os.environ[item] if item in os.environ else None options[item] = os.environ[item] if item in os.environ else None
return options return options

View File

@ -1,7 +1,7 @@
import copy import copy
import multiprocessing as mp import multiprocessing as mp
from functools import partial from functools import partial
from os import path import os
import warnings import warnings
import numpy as np import numpy as np
@ -278,14 +278,14 @@ class Grid:
""" """
root_dir ='DataContainers' root_dir ='DataContainers'
f = h5py.File(fname, 'r') f = h5py.File(fname, 'r')
g = path.join(root_dir,base_group,'_SIMPL_GEOMETRY') g = os.path.join(root_dir,base_group,'_SIMPL_GEOMETRY')
cells = f[path.join(g,'DIMENSIONS')][()] cells = f[os.path.join(g,'DIMENSIONS')][()]
size = f[path.join(g,'SPACING')][()] * cells size = f[os.path.join(g,'SPACING')][()] * cells
origin = f[path.join(g,'ORIGIN')][()] origin = f[os.path.join(g,'ORIGIN')][()]
ma = np.arange(cells.prod(),dtype=int) \ ma = np.arange(cells.prod(),dtype=int) \
if point_data is None else \ if point_data is None else \
np.reshape(f[path.join(root_dir,base_group,point_data,material)],cells.prod()) np.reshape(f[os.path.join(root_dir,base_group,point_data,material)],cells.prod())
return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D')) return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D'))
@ -355,7 +355,7 @@ class Grid:
seeds_p = seeds seeds_p = seeds
coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3) coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3)
pool = mp.Pool(processes = int(environment.options['DAMASK_NUM_THREADS'])) pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1)))
result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), [coord for coord in coords]) result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), [coord for coord in coords])
pool.close() pool.close()
pool.join() pool.join()

View File

@ -1134,8 +1134,7 @@ class Result:
""" """
chunk_size = 1024**2//8 chunk_size = 1024**2//8
num_threads = damask.environment.options['DAMASK_NUM_THREADS'] pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1)))
pool = mp.Pool(int(num_threads) if num_threads is not None else None)
lock = mp.Manager().Lock() lock = mp.Manager().Lock()
groups = self.groups_with_datasets(datasets.values()) groups = self.groups_with_datasets(datasets.values())

View File

@ -32,7 +32,7 @@ contains
subroutine parallelization_init subroutine parallelization_init
integer :: err, typeSize integer :: err, typeSize
!$ integer :: got_env, DAMASK_NUM_THREADS, threadLevel !$ integer :: got_env, OMP_NUM_THREADS, threadLevel
!$ character(len=6) NumThreadsString !$ character(len=6) NumThreadsString
#ifdef PETSc #ifdef PETSc
PetscErrorCode :: petsc_err PetscErrorCode :: petsc_err
@ -87,19 +87,19 @@ call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,err)
open(OUTPUT_UNIT,file='/dev/null',status='replace') ! close() alone will leave some temp files in cwd open(OUTPUT_UNIT,file='/dev/null',status='replace') ! close() alone will leave some temp files in cwd
endif endif
!$ call get_environment_variable(name='DAMASK_NUM_THREADS',value=NumThreadsString,STATUS=got_env) !$ call get_environment_variable(name='OMP_NUM_THREADS',value=NumThreadsString,STATUS=got_env)
!$ if(got_env /= 0) then !$ if(got_env /= 0) then
!$ print*, 'Could not determine value of $DAMASK_NUM_THREADS' !$ print*, 'Could not determine value of $OMP_NUM_THREADS'
!$ DAMASK_NUM_THREADS = 1_pI32 !$ OMP_NUM_THREADS = 1_pI32
!$ else !$ else
!$ read(NumThreadsString,'(i6)') DAMASK_NUM_THREADS !$ read(NumThreadsString,'(i6)') OMP_NUM_THREADS
!$ if (DAMASK_NUM_THREADS < 1_pI32) then !$ if (OMP_NUM_THREADS < 1_pI32) then
!$ print*, 'Invalid DAMASK_NUM_THREADS: '//trim(NumThreadsString) !$ print*, 'Invalid OMP_NUM_THREADS: '//trim(NumThreadsString)
!$ DAMASK_NUM_THREADS = 1_pI32 !$ OMP_NUM_THREADS = 1_pI32
!$ endif !$ endif
!$ endif !$ endif
!$ print'(a,i2)', ' DAMASK_NUM_THREADS: ',DAMASK_NUM_THREADS !$ print'(a,i2)', ' OMP_NUM_THREADS: ',OMP_NUM_THREADS
!$ call omp_set_num_threads(DAMASK_NUM_THREADS) !$ call omp_set_num_threads(OMP_NUM_THREADS)
end subroutine parallelization_init end subroutine parallelization_init