Skip to content

"xxx" function interface: further separation of data access and calculations? #175

@valassi

Description

@valassi

This is vaguely related to vectorisation issue #71 and the big PR #171.

One question I am considering is whethe we should push even further the separation of data access and calculations.

Presently, the xxx functions

  • take as input an fptype pointer allmomenta for all particles in all events, plus some parameters identifying which particle in which event is needed, and other parameters for the calculation such as mass, helicity, ingoing/outgoing
  • give as output the wavefunction for the given particle and even under the given calculation scenario

In practice, all these functions do two things

  • they decode the allmomenta AOSOA data structure using the pIparIp4Ievt and pIparIp4Ipag functions, extracting only the 4-momenta for the relevant particle and event
  • they then compute the wavefunction for that particle/event under the given scenario (mass, helicity, ingoing/outgoing)

What I am proposing/questioning is that it may be better to have the xxx functions do only the calculation, while the AOSOA decoding should be done externally.

In practice

  • the xxx interface would take as input the momenta for a given particle, and a given event (or range of events, ie "event page" for vectorization): as arrays of references are forbidden, however, this may require passing four separate fptype_sv (one for energy, px, py, pz)
  • in other words, the xxx function swould know nothing of AOSOA structures
  • it would be the caller of the xxx functions, presently calculate_wavefunction, that encapsulates the knowledge of the AOSOA structure, possibly even through an extrenal call

One drawback of the present class structure is that there a lot of hidden couplings through hidden assumptions, eg rambo knows about the AOSOA structure too

This new suggested structure may eventually help interfacing c++/cuda to fortran, or maybe not... to be reconsidered later

In any case, one should understand if the performance remains the same, degrades, or even improves through this refactoring. One should also study if the various input fptype_sv should be passed as references or by value. Hint: in this line I had the impression that passing by value was slightly faster, which I found a bit counterintuitive,

// Return by value: it seems a tiny bit faster than returning a reference (both for scalar and vector), not clear why

Low priority. Just filing so I do not forget this...

Metadata

Metadata

Assignees

Labels

ideaPossible new development (may need further discussion)refactoringRestructure classes and interfaces, improve modularity and encapsulation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions