From 32cb416893518e5ebf09eb163dd416ff2fa77d84 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Thu, 3 Dec 2026 17:13:36 +0100 Subject: [PATCH] Add a --GeantMT option for multi-threaded Geant4 transport This adds a --GeantMT option to o2dpg_sim_workflow.py that runs the Geant4 transport multi-threaded. - It adds --isMT 1 to the o2-sim signal and background transport commands only. - It needs -e TGeant4 and stops with an error for the other engines. - Anchored productions can pass it through ALIEN_JDL_ANCHOR_SIM_OPTIONS. --- MC/bin/o2dpg_sim_workflow.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index 4de2b8b46..281815904 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -164,6 +164,7 @@ parser.add_argument('--tpc-corrmap-lumi-mode', default=2, type=int, help='TPC corrections mode (0=linear, 1=derivative, 2=derivative for special MC maps') parser.add_argument('--ctp-scaler', default=0, type=float, help='CTP raw scaler value used for distortion simulation') parser.add_argument('--no-tpc-mt-digitizer', action='store_true', help='Digitize TPC with one process per lane instead of one multithreaded device') +parser.add_argument('--GeantMT', action='store_true', help='Run the Geant4 transport multi-threaded (o2-sim --isMT 1, needs -e TGeant4)') parser.add_argument('--tpc-mt-digitizer', action='store_true', help=argparse.SUPPRESS) # the default now; kept for compatibility parser.add_argument('--tpc-sector-seeding', action='store_true', help='Seed the TPC digitizer per sector so that the digits do not depend on the number of lanes') # Global Forward reconstruction configuration @@ -479,6 +480,11 @@ def extractVertexArgs(configKeyValuesStr, finalDiamondDict): SKIPMODULES = " ".join(["--skipModules"] + args.skipModules) if len(args.skipModules) > 0 else "" SIMENGINE=args.e +if args.GeantMT and SIMENGINE != 'TGeant4': + print('ERROR: --GeantMT needs -e TGeant4') + sys.exit(1) +# multi-threaded Geant4 transport, added to the o2-sim transport commands only +SIMMT = ' --isMT 1' if args.GeantMT else '' # Geant4 is loaded by dlopen and needs a glibc static TLS reserve. It is set per task, because the global # environment does not replace a GLIBC_TUNABLES that already exists, as it does truncated in GRID jobs. GEANT4_TASK_ENV={'GLIBC_TUNABLES': 'glibc.rtld.optional_static_tls=32768'} @@ -836,7 +842,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): bkgsimneeds = [BKG_CONFIG_task['name'], GRP_TASK['name'], PreCollContextTask['name']] BKGtask=createTask(name='bkgsim', lab=["GEANT"], needs=bkgsimneeds, cpu=NWORKERS) - BKGtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + SIMENGINE + ' -j ' + str(NWORKERS) + ' -n ' + str(NBKGEVENTS) \ + BKGtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + SIMENGINE + SIMMT + ' -j ' + str(NWORKERS) + ' -n ' + str(NBKGEVENTS) \ + ' -g ' + str(GENBKG) + ' ' + str(SKIPMODULES) + ' -o bkg ' + str(INIBKG) \ + ' --field ccdb ' + str(CONFKEYBKG) \ + ('',' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run) \ @@ -1057,7 +1063,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): sgnmem = 6000 if COLTYPE == 'PbPb' else 4000 SGNtask=createTask(name='sgnsim_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEANT"], relative_cpu=7/8, n_workers=NWORKERS_TF, mem=str(sgnmem)) - sgncmdbase = '${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(SKIPMODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \ + sgncmdbase = '${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + SIMMT + ' ' + str(SKIPMODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \ + ' --field ccdb -j ' + str(NWORKERS_TF) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) + ' -o ' + signalprefix + ' ' + embeddinto \ + ' --detectorList ' + args.detectorList \ + ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run)