Skip to content

Support generation of Allen sequences with Moore, make all outputs immutable

Daniel Campora Perez requested to merge dcampora_nnolte_configuration into master

This MR aims to allow to use the Gaudi configuration machinery to generate Allen configurations.

The workflow to generate a configuration and compile Allen will be as of !361 (merged) as follows:

  • Create / modify the sequence, located at configuration/sequence/<sequence>.py
  • cmake -DSEQUENCE=<sequence> ..
  • make -j

This MR permits to use instead PyConf to generate the configuration. The process is similar:

  • Create / modify the sequence in the Gaudi sequence format, located at configuration/gaudi/<sequence>.py
  • cmake -DSEQUENCE=<sequence> -DMOORE_GENERATOR=ON -DMOORE_INSTALL_DIR=/home/dcampora/projects/dcampora_nnolte_configuration/Moore/build.x86_64-centos7-gcc9-opt ..
  • make -j

Here is an example of it in action:

$ cmake -DSEQUENCE=VELO -DMOORE_GENERATOR=ON -DMOORE_INSTALL_DIR=/home/dcampora/projects/dcampora_nnolte_configuration/Moore/build.x86_64-centos7-gcc9-opt ..
...
-- Testing code generation with LLVM
-- Testing code generation with LLVM - Configured generator: Moore
-- Testing code generation with LLVM - Success
...
$ make -j
...
Parsing algorithms...
Generating /home/dcampora/projects/allen/build/sequences/definitions/algorithms.py in Gaudi format...
File /home/dcampora/projects/allen/build/sequences/definitions/algorithms.py was successfully generated.
Generating sequence file...
Generated sequence file Sequence.h
Generating JSON configuration file...
Generated JSON configuration file Sequence.json
[ 43%] Built target configured_sequence
...
$ ./Allen
...

How does it work

  • The Allen codebase is parsed with libClang, and an output algorithms.py file is generated at compile time. Algorithms in this file are of type AllenAlgorithm.

  • Moore is used to run over the configured <sequence>.py. Whenever each algorithm is instantiated, it is registered in the global AllenAlgorithm object. This list of algorithms is then traversed to generate both the Sequence.h and Sequence.json that Allen require.

  • TES locations are converted to an "Allen-like" format (essentially a valid class identifier). For instance: /Event/host_global_event_cut/dev_input_buffer_t becomes host_global_event_cut__dev_input_buffer_t.

Some examples

  • Example of algorithm in generated algorithms.py:
from GaudiKernel.DataObjectHandleBase import DataObjectHandleBase
from AllenKernel import AllenAlgorithm


class pv_beamline_calculate_denom_t(AllenAlgorithm):
  __slots__ = dict(
    host_number_of_selected_events_t = DataObjectHandleBase("host_number_of_selected_events_t", "R", "uint"),
    host_number_of_reconstructed_velo_tracks_t = DataObjectHandleBase("host_number_of_reconstructed_velo_tracks_t", "R", "uint"),
    dev_offsets_all_velo_tracks_t = DataObjectHandleBase("dev_offsets_all_velo_tracks_t", "R", "uint"),
    dev_offsets_velo_track_hit_number_t = DataObjectHandleBase("dev_offsets_velo_track_hit_number_t", "R", "uint"),
    dev_pvtracks_t = DataObjectHandleBase("dev_pvtracks_t", "R", "PVTrack"),
    dev_pvtracks_denom_t = DataObjectHandleBase("dev_pvtracks_denom_t", "W", "float"),
    dev_zpeaks_t = DataObjectHandleBase("dev_zpeaks_t", "R", "float"),
    dev_number_of_zpeaks_t = DataObjectHandleBase("dev_number_of_zpeaks_t", "R", "uint")
  )

  def __init__(self, name, **kwargs):
    super(pv_beamline_calculate_denom_t, self).__init__(name)
    for n,v in kwargs.items():
      setattr(self, n, v)

  @classmethod
  def namespace(cls):
    return "pv_beamline_calculate_denom"

  @classmethod
  def filename(cls):
    return "../cuda/PV/beamlinePV/include/pv_beamline_calculate_denom.cuh"

  @classmethod
  def getType(cls):
    return "pv_beamline_calculate_denom_t"

Some thoughts for the next steps:

At the moment, this is a proof of concept on top of which one can build the required functionality. Among others:

  • In the future, only one format should be maintained (ie. the sequences in configuration/gaudi).
  • Similarly, only one format should be maintained as input to the generator of Sequence.h, Sequence.json files.
  • Support for lines will come at a later stage.

Note: This work is ongoing with @nnolte

Edited by Dorothea Vom Bruch

Merge request reports