using DAMASK_NUM_THREADS controls # workers for add_XXX

This commit is contained in:
Martin Diehl 2020-02-16 09:49:55 +01:00
parent 36c1744a59
commit 065fc9ffde
2 changed files with 5 additions and 4 deletions

View File

@ -14,6 +14,7 @@ from . import util
from . import version from . import version
from . import mechanics from . import mechanics
from . import Orientation from . import Orientation
from . import Environment
# ------------------------------------------------------------------ # ------------------------------------------------------------------
class DADF5(): class DADF5():
@ -1030,8 +1031,8 @@ class DADF5():
"""Call function with input data + extra arguments, returns results + group.""" """Call function with input data + extra arguments, returns results + group."""
args['results'].put({**args['func'](**args['in']),'group':args['group']}) args['results'].put({**args['func'](**args['in']),'group':args['group']})
env = Environment()
N_threads = 1 # ToDo: should be a parameter N_threads = int(env.options['DAMASK_NUM_THREADS'])
results = Queue(N_threads) results = Queue(N_threads)
pool = util.ThreadPool(N_threads) pool = util.ThreadPool(N_threads)

View File

@ -8,7 +8,7 @@ class Environment():
def __init__(self): def __init__(self):
"""Read and provide values of DAMASK configuration.""" """Read and provide values of DAMASK configuration."""
self.options = {} self.options = {}
self.get_options() self.__get_options()
def relPath(self,relative = '.'): def relPath(self,relative = '.'):
return os.path.join(self.rootDir(),relative) return os.path.join(self.rootDir(),relative)
@ -16,7 +16,7 @@ class Environment():
def rootDir(self): def rootDir(self):
return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../')) return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../'))
def get_options(self): def __get_options(self):
for item in ['DAMASK_NUM_THREADS', for item in ['DAMASK_NUM_THREADS',
'MSC_ROOT', 'MSC_ROOT',
'MARC_VERSION', 'MARC_VERSION',