From 84e5dcc6138dd435f6b886338a71c027188973ac Mon Sep 17 00:00:00 2001
From: Klaus Rabbertz <klaus.rabbertz@cern.ch>
Date: Mon, 2 Oct 2023 11:00:25 +0200
Subject: [PATCH] Set OMP_NUM_THREADS now also for FastWarm and FastProd

---
 analysis/tasks/FastProd.py | 6 ++++++
 analysis/tasks/FastWarm.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/analysis/tasks/FastProd.py b/analysis/tasks/FastProd.py
index 8e157b8..fd8bd17 100644
--- a/analysis/tasks/FastProd.py
+++ b/analysis/tasks/FastProd.py
@@ -167,6 +167,12 @@ class FastProd(Task, TarballExtractionMixin, HTCondorWorkflow, law.LocalWorkflow
                     )
                     f.write(runcard)
 
+                # KR: With hyperthreading it might be necessary to request more cpus on a node than one wants to use for the calculation!
+                #     --> Differentiate between request and use CPUs!
+                #      os.environ['OMP_NUM_THREADS'] = self.htcondor_request_cpus
+                logger.debug("Setting no. of threads to use: self.htcondor_use_cpus[index] = {}".format(self.htcondor_use_cpus[self.branch_data['index']]))
+                os.environ['OMP_NUM_THREADS'] = self.htcondor_use_cpus[self.branch_data['index']]
+
                 logger.debug("Starting NNLOJET with runcard: %s", runfile)
 
                 command_line_args = ['NNLOJET', '-run', runfile]
diff --git a/analysis/tasks/FastWarm.py b/analysis/tasks/FastWarm.py
index 08ef537..2fdc275 100644
--- a/analysis/tasks/FastWarm.py
+++ b/analysis/tasks/FastWarm.py
@@ -157,6 +157,12 @@ class FastWarm(Task, TarballExtractionMixin, HTCondorWorkflow, law.LocalWorkflow
                     )
                     f.write(runcard)
 
+                # KR: With hyperthreading it might be necessary to request more cpus on a node than one wants to use for the calculation!
+                #     --> Differentiate between request and use CPUs!
+                #      os.environ['OMP_NUM_THREADS'] = self.htcondor_request_cpus
+                logger.debug("Setting no. of threads to use: self.htcondor_use_cpus[index] = {}".format(self.htcondor_use_cpus[self.branch_data['index']]))
+                os.environ['OMP_NUM_THREADS'] = self.htcondor_use_cpus[self.branch_data['index']]
+
                 logger.debug("Starting NNLOJET with runcard: %s", runfile)
 
                 command_line_args = ['NNLOJET', '-run', runfile]
-- 
GitLab