From d135faa35f6ca02b70db9764f85b57be64e8f299 Mon Sep 17 00:00:00 2001 From: Benedikt Volkel Date: Thu, 21 Mar 2024 14:36:20 +0100 Subject: [PATCH] [SimWF] Recompute number of workers used in TFs --- MC/bin/o2dpg_sim_workflow.py | 7 +++++-- MC/bin/o2dpg_workflow_utils.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index d1ae5ced4..0e8638259 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -34,7 +34,7 @@ sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils')) -from o2dpg_workflow_utils import createTask, createGlobalInitTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector, deactivate_detector +from o2dpg_workflow_utils import createTask, createGlobalInitTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector, deactivate_detector, compute_n_workers from o2dpg_qc_finalization_workflow import include_all_QC_finalization from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg @@ -638,6 +638,9 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True): QEDdigiargs=' --simPrefixQED qed_' + str(tf) + ' --qed-x-section-ratio ' + str(QEDXSecExpected/PbPbXSec) workflow['stages'].append(QED_task) + # recompute the number of workers to increase CPU efficiency + NWORKERS = compute_n_workers(INTRATE, COLTYPE) + # produce the signal configuration SGN_CONFIG_task=createTask(name='gensgnconf_'+str(tf), tf=tf, cwd=timeframeworkdir) SGN_CONFIG_task['cmd'] = 'echo "placeholder / dummy task"' @@ -1300,7 +1303,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''): needs=[PHSRECOtask['name']], readerCommand='o2-phos-reco-workflow --input-type cells --output-type clusters --disable-mc --disable-root-output', configFilePath='json://${O2DPG_ROOT}/MC/config/QC/json/phs-cells-clusters-task.json') - + ### MID if isActive('MID'): addQCPerTF(taskName='MIDTaskQC', diff --git a/MC/bin/o2dpg_workflow_utils.py b/MC/bin/o2dpg_workflow_utils.py index 18fd600c9..6544c3a1b 100755 --- a/MC/bin/o2dpg_workflow_utils.py +++ b/MC/bin/o2dpg_workflow_utils.py @@ -24,6 +24,28 @@ def deactivate_detector(det): def isActive(det): return det not in INACTIVE_DETECTORS and ("all" in ACTIVE_DETECTORS or det in ACTIVE_DETECTORS) +def compute_n_workers(interaction_rate, collision_system, n_workers_user=8, n_workers_min=1, interaction_rate_linear_below=300000): + """ + Compute number of workers + + n_workers = m * IR + b + + based on + https://indico.cern.ch/event/1395900/contributions/5868567/attachments/2823967/4932440/20240320_slides_cpu_eff.pdf, slide 3 + + Assume n_workers_in=8 to be ideal for pp IR > interaction_rate_linear_below + + Start with 1 worker at IR=0 + Go linearly until interaction_rate_linear_below + """ + if collision_system == "PbPb": + return n_workers_user + + n_workers_min = max(1, n_workers_min) + m = (n_workers_user - n_workers_min) / interaction_rate_linear_below + # at least 1 worker + return min(1, round(m * interaction_rate + n_workers_min)) + def relativeCPU(n_rel, n_workers): # compute number of CPUs from a given number of workers # n_workers and a fraction n_rel