Subject: [PATCH v2 00/12] Tuning packages for CPU micro-architectures

From: Ludovic Courtès <[email-masked]>
Date: Thu, 16 Dec 2021 18:58:15 +0100

Hello!

Here is v2 of the patch set implementing the ‘--tune’ package
transformation option.  Changes since v1:

  • Compiler packages (gcc, clang, gcc-toolchain, clang-toolchain)
    now declare in a package property the supported CPU names;
    ‘--tune’ verifies, when the package a lowered to a bag, whether
    the target CPU is supported by the compiler and errors out
    if not.

    In theory, ‘--tune’ (with no argument) could detect a CPU
    that the compiler does not support, though that’s unlikely
    since (guix cpu) currently corresponds to what GCC 10 supports.
    I considered doing something fancy that would somehow fall
    back to a less accurate but supported CPU name, but gave up
    out of laziness and fear of complexity.

  • Guix now prints which package is being tuned, like so:

      $ ./pre-inst-env guix shell --tune inspekt3d -- Studio
      guix shell: tuning [email-masked] for CPU skylake

  • Documentation reworded as suggested by Josselin.  It also
    clarifies that a compiler wrapper is used and that tests are
    skipped.

  • Inputs of the new packages were simplified.  \o/
  
Something left as future work is AMD processor identification
in (guix cpu).

Those interested in compiler optimizations can use it to compare
the job made by different compilers:

  guix shell --with-c-toolchain=xtensor-benchmark=clang-toolchain \
    --tune xtensor-benchmark -- benchmark_xtensor

Fun fact:

  guix shell --tune eigen-benchmarks -- benchBlasGemm 240 240 240

now gives me 45 Gflops/s on my CORE i7 (skylake), when pre-merge it
would give 36 Gflops/s.  Same result with:

  --with-c-toolchain=eigen-benchmarks=gcc-toolchain@7

Go figure!

I re-pushed the ‘wip-cpu-tuning’ branch so people can give it a try:

  guix time-machine --branch=wip-cpu-tuning -- \
    shell eigen-benchmarks --tune -- \
    benchBlasGemm 240 240 240

Thoughts?

Ludo’.

Ludovic Courtès (12):
  Add (guix cpu).
  gnu: gcc: Add 'compiler-cpu-architectures' property.
  gnu: clang: Add 'compiler-cpu-architectures' property.
  transformations: Add '--tune'.
  ci: Add extra jobs for tunable packages.
  gnu: Add eigen-benchmarks.
  gnu: Add xsimd-benchmark.
  gnu: Add xtensor-benchmark.
  gnu: ceres-solver: Mark as tunable.
  gnu: Add ceres-solver-benchmarks.
  gnu: libfive: Mark as tunable.
  gnu: prusa-slicer: Mark as tunable.

 Makefile.am                   |   1 +
 doc/guix.texi                 |  61 ++++++++++
 gnu/ci.scm                    |  43 +++++--
 gnu/packages/algebra.scm      |  77 +++++++++++++
 gnu/packages/commencement.scm |   1 +
 gnu/packages/cpp.scm          |  23 ++++
 gnu/packages/engineering.scm  |  10 +-
 gnu/packages/gcc.scm          |  31 +++++-
 gnu/packages/llvm.scm         |  71 +++++++++++-
 gnu/packages/maths.scm        |  48 +++++++-
 guix/cpu.scm                  | 143 ++++++++++++++++++++++++
 guix/transformations.scm      | 204 ++++++++++++++++++++++++++++++++++
 tests/transformations.scm     |  35 ++++++
 13 files changed, 733 insertions(+), 15 deletions(-)
 create mode 100644 guix/cpu.scm

base-commit: e642378df3b0d218e463397883e7bf331f528c6a
-- 
2.33.0