ukri-excalibur / excalibur-tests

Performance benchmarks and regression tests for the ExCALIBUR project
https://ukri-excalibur.github.io/excalibur-tests/
Apache License 2.0
19 stars 16 forks source link

Parser for the spack_spec #251

Closed kaanolgu closed 6 months ago

kaanolgu commented 10 months ago

Performance Portability post-processing will need the spack_spec parsed, to fish out the compiler name (the thing after %) and the variants (the thing after + is an on-off, which for babelstream is called language, and there are custom ones as well with variant=value).

ilectra commented 8 months ago

It'll be safer to do this with the spack api, and not as a string parsing. But accessing the spack API is a PITA, so @giordano has some ideas of how to do it. Ideally, the parsing of the spack_spec will be done during the benchmarking run, and then its components will be saved in separate columns in the perflog.

giordano commented 8 months ago

I have already a proof of concept of doing something like this in #35. The main ingredients are:

How to print out the desired information

In #35 I was running the command $(spack -e <path to environment> build-env <spack spec> | grep -oP '^SPACK_CC=\K.*) --version, but that was a very clunky way to do it. A better way is to use Spack Python API (see for example spack tutorial about scripting). Spack isn't usually installed as a regular Python package, so accessing its module isn't straightforward short of fiddling with PYTHONPATH, which can be very fragile, but Spack provides the command spack python to run a Python interpreter which knows how to access the spack module. For example, to show the list of specs in the active environment, assuming it has been already concretized (which is the case for the environment we use in our case) you can do something like

spack -e <path to environment> python -c 'from spack import environment; [x for x in environment.active_environment().added_specs()]'

In practice, you'll need to tweak the command to print exactly what you want.

Caveats

There are a few caveats to be aware of:

ilectra commented 6 months ago

Addressed in #262