[L1CaloFEXSim] Optimise the use of maps in jFex simulation
Avoid inefficient use of maps (copying and searching) with a few minor code changes that all together speed up the entire Level-1 Trigger simulation by 30%.
Specific changes:
-
jFexFPGA
: calltool->setFPGAEnergy(m_map_Etvalues_FPGA)
before loops because the value doesn't change inside the loops. This is an expensive function copying a large map. -
jFEXForwardJetsAlgo
: introduce new methodglobalEtaPhi
to search a large map only once and return both eta and phi of the found tower. This is 2x faster than searching the map twice - once for eta and once for phi. -
jFEXForwardJetsAlgo
: use references instead of copies as loop variables in loops over maps
The improvements targeted the most expensive calls as found by VTune and are proven to speed up the simulation (the whole L1Sim) by 30%. This is an additional 30% on top of the 25% improved in !49604 (merged) for RPC.
Tested with:
athenaHLT.py -c "setMenu='Dev_pp_run3_v1';doL1Sim=True;doEmptyMenu=True;" --dump-config-reload --nproc=16 -f /afs/cern.ch/work/r/rbielski/public/smallMenuPerfStudy/data18_13TeV.00360026.physics_EnhancedBias.mergedBS._0001.data TriggerJobOpts/runHLT_standalone.py
The last change listed above (use ref as loop variable) changes the output. Reading the code I believe this is actually fixing a bug, but I'll wait for @serodrig to confirm. It is confirmed by @serodrig to be fixing a bug (see discussion below).
FYI @afaulkne
Edited by Rafal Bielski