From 3813e73087fde80d87b781b2744e1de1cdfaeba1 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Fri, 18 Nov 2016 16:20:22 +0000 Subject: [PATCH] Task #10118: Enforce OMP_NUM_THREADS for all recipes --- .../lofarpipe/support/remotecommand.py | 19 ++++++++++++------- CEP/Pipeline/recipes/sip/nodes/dppp.py | 4 ---- .../recipes/sip/nodes/imager_prepare.py | 3 --- .../recipes/sip/nodes/selfcal_awimager.py | 5 ----- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/CEP/Pipeline/framework/lofarpipe/support/remotecommand.py b/CEP/Pipeline/framework/lofarpipe/support/remotecommand.py index 4df285da05b..cdef09c0b91 100644 --- a/CEP/Pipeline/framework/lofarpipe/support/remotecommand.py +++ b/CEP/Pipeline/framework/lofarpipe/support/remotecommand.py @@ -276,19 +276,24 @@ class ComputeJob(object): self.results['returncode'] = 1 error.set() return 1 - cmdarray = run_remote_command( - config, - logger, - self.host, - self.command, - { + + environment = { "PATH": os.environ.get('PATH'), "PYTHONPATH": os.environ.get('PYTHONPATH'), "LD_LIBRARY_PATH": os.environ.get('LD_LIBRARY_PATH'), "LOFARROOT" : os.environ.get('LOFARROOT'), "LOFARENV" : os.environ.get('LOFARENV',''), "QUEUE_PREFIX" : os.environ.get('QUEUE_PREFIX','') - }, + } + if "cores" in self.resources: + environment["OMP_NUM_THREADS"] = str(self.resources["cores"]) + + cmdarray = run_remote_command( + config, + logger, + self.host, + self.command, + environment, arguments = [id, jobhost, jobport], resources = self.resources ) diff --git a/CEP/Pipeline/recipes/sip/nodes/dppp.py b/CEP/Pipeline/recipes/sip/nodes/dppp.py index 6ef03658284..7f803b6704d 100644 --- a/CEP/Pipeline/recipes/sip/nodes/dppp.py +++ b/CEP/Pipeline/recipes/sip/nodes/dppp.py @@ -111,10 +111,6 @@ class dppp(LOFARnodeTCP): ) shutil.copytree(infile, tmpfile) - # Limit number of threads used. - self.environment['OMP_NUM_THREADS'] = str(nthreads) - self.logger.debug("Using %s threads for NDPPP" % nthreads) - # ***************************************************************** # 3. Update the parset with locally calculate information diff --git a/CEP/Pipeline/recipes/sip/nodes/imager_prepare.py b/CEP/Pipeline/recipes/sip/nodes/imager_prepare.py index b590cc80680..7ff314cd110 100644 --- a/CEP/Pipeline/recipes/sip/nodes/imager_prepare.py +++ b/CEP/Pipeline/recipes/sip/nodes/imager_prepare.py @@ -220,9 +220,6 @@ class imager_prepare(LOFARnodeTCP): Muckable function running the dppp executable. Wraps dppp with catchLog4CPLus and catch_segfaults """ - # TODO: cpu limited is static at this location - environment['OMP_NUM_THREADS'] = str(8) - self.logger.debug("Using %s threads for ndppp" % 8) with CatchLog4CPlus(working_dir, self.logger.name + "." + os.path.basename("imager_prepare_ndppp"), os.path.basename(ndppp)) as logger: diff --git a/CEP/Pipeline/recipes/sip/nodes/selfcal_awimager.py b/CEP/Pipeline/recipes/sip/nodes/selfcal_awimager.py index db7267f7c3f..3343b52f0f3 100644 --- a/CEP/Pipeline/recipes/sip/nodes/selfcal_awimager.py +++ b/CEP/Pipeline/recipes/sip/nodes/selfcal_awimager.py @@ -174,11 +174,6 @@ class selfcal_awimager(LOFARnodeTCP): # ***************************************************************** # 5. Run the awimager with the parameterset - # TODO: FIXME: manually Limit number of threads used. - omp_num_threads = 8 - self.environment['OMP_NUM_THREADS'] = str(omp_num_threads) - self.logger.debug("Using %s threads for swimager" % omp_num_threads) - cmd = [executable, calculated_parset_path] self.logger.debug("Parset used for awimager run:") self.logger.debug(cmd) -- GitLab