Refactor code of Legendre polynomials?

Dear experts,

I noticed that the Legendre polynomials are used by INCL, ABLA and HP models, and each one uses a different implementation [1-3]. In addition, there is a wrapper of GSL [4] in CLHEP [5].

Since these Legendre polynomials are used at every step to calculate angular distributions, they are likely very hot and maybe the particular implementation of these functions in hadronic processes are not fully optimal. Would it be worth to refactor the calls to these functions, so hadronic models use the CLHEP implementation instead?

Thank you for your time.

Best,
Alvaro
[1] geant4/source/processes/hadronic/util/include/G4LegendrePolynomial.hh at e58e650b32b961c8093f3dd6a2c3bc917b2552be · Geant4/geant4 · GitHub
[2] geant4/source/processes/hadronic/models/abla/include/G4Abla.hh at e58e650b32b961c8093f3dd6a2c3bc917b2552be · Geant4/geant4 · GitHub
[3] geant4/source/processes/hadronic/models/coherent_elastic/src/G4NuclNuclDiffuseElastic.cc at e58e650b32b961c8093f3dd6a2c3bc917b2552be · Geant4/geant4 · GitHub
[4] Special Functions — GSL 2.8 documentation
[5] legendre · Search · GitLab

Hi Alvaro,

yes, what you suggest makes a lot of sense and should be put in our (quite long) to-do list!

By the way: while considerable effort has been put (for good reasons) on speeding up electromagnetic physics, in hadronic physics little attention has been paid so far to its computational impact, except perhaps for hadronic cross sections…
Therefore, there are plenty of opportunities for speeding-up hadronic physics, and in particular final-state models.

Thanks for the useful suggestion!
Cheers,
Alberto

Hi @atolosad, may be worth rolling this into the related and long standing GitHub PR on optimization of these functions. Feel free to create an internal GitLab issue to track this!

1 Like