Comment 3 for bug 2000771

Revision history for this message
Daniele Massaro (dmassaro) wrote :

Hi Olivier,

(I used Pythia 8.306 with MadGraph LTS for the following tests)

I have an update on this question. I have run the main101 of MadDM using the same model and same LHEF file in few ways:
1. using Pythia compiled from MadGraph;
2. using an independent version of Pythia compiled by myself with the default flags.

In the case 2. I record an improvement of 5 in speed (from 24 s to 3 s for 10k events).

I then inspected the compilation flags that MadGraph uses, from the pythia8_install.log with respect to the ones used when compiling Pythia myself.
I found that in the latter case, there is also `-O2` which should optimize the code.
At this point, I used the installPYTHIA8.sh script in HEPToolsInstaller folder to compile a version of Pythia like MadGraph would do (I passed the same options that MadGraph also passes) and I have added the flag `-O2` to CXX_COMMON.

I repeated the test 1. and I recorded a time of 5 s.
In conclusion, I think that if we could add the optimization flag to the Pythia compilation happening in MadGraph, we could record a performance improvement in Pythia runs.

However, I ignore if there is a particular reason for which the optimization flag for the Pythia compilation has not been added.

Cheers.
--
Daniele

PS:
I verified that in the HEPToolsInstaller.py, the `-O2` flag is not passed for Pythia (like it happens for ninja, for e.g.).
Moreover, I inspected the configure script of pythia8 and I found that if --cxx-common is passed as a configuration option, and no debug is selected (as MadGraph is doing), then the following construct that sets CXX_COMMON is skipped (lines :
```
if [ -z "$CXX_COMMON" ]; then
    CXX_COMMON="${ENABLE_DEBUG}${ENABLE_64BIT}"
    CXX_COMMON="${CXX_COMMON}-std=c++11 -pedantic -W -Wall -Wshadow -fPIC"; fi
```
it contains the variable ENABLE_DEBUG, which is set at line 304:
```
[ "$ENABLE_DEBUG_SET" = true ] && ENABLE_DEBUG="-g " || ENABLE_DEBUG="-O2 "
```
So ENABLE_DEBUG contains the optimization flag, which is added to CXX_COMMON only in the case this is not passed from outside.
This demonstrates why the optimization is active if Pythia is compiled with no flags (like I did in the test 2.)
The slight changes in the configure script of Pythia in version 8.308 (latest version) do not affect what I wrote.