conda-forge/conda-forge.github.io

Where does conda-forge specify the minimum supported CPU instruction set, e.g. `-march=nocona`

Opened this issue ยท 7 comments

Your question:

A bioconda recipe I maintain caused some issues by using AVX instructions. The source code build script hard coded -mavx ignoring the default -march flag of gcc and clang, which are at the time of writing -march=core2 -mssse3 or -march=nocona.

The fact that there are default arch flags took some time to figure out, because what the flags are does not seem to be documented explicitly (at least a few folks at bioconda weren't aware, see Gitter thread). I was wondering if we could improve the situation around this.

If I'm not mistaken, there is no single central place (like for example conda-forge-pinnings) setting those flags across compilers in a consistent manner. Instead, each compiler compiler sets its own flags in its feedstock code. Examples:

For x86-64 and ppc but not for arm/aarch, there's been work on allowing build-variants for differing instruction sets: https://github.com/conda-forge/microarch-level-feedstock/blob/1b446dbab3999c5e27f1e0b000231f18fa1b6df1/recipe/install_scripts.sh#L7

A few other mentions of -march I found through search:

  • Compiler flag unification meeting notes (2017-11-16):
    ## Compiler flag unification
    - GCC
    - toolchain: https://github.com/conda-forge/toolchain-feedstock/blob/master/recipe/activate.sh
    - toolchain3: https://github.com/conda-forge/toolchain3-feedstock/blob/master/recipe/activate.sh
    - anaconda: https://github.com/AnacondaRecipes/aggregate/blob/master/ctng-compilers-activation-feedstock/recipe/conda_build_config.cos6.x86_64.yaml#L41-L54
    | Variable | toolchain only | anaconda only | |
    | -------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | |
    | CFLAGS | -m${ARCH} | march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe | |
    | CPPFLAGS | | -D_FORTIFY_SOURCE=2 -O2 | |
    | CXXFLAGS | -DBOOST_MATH_DISABLE_FLOAT128 -m${ARCH} | -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe | |
    | LDFLAGS | -Wl,-rpath,$PREFIX/lib | Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now | |
    - LLVM/clang
    - toolchain: https://github.com/conda-forge/toolchain-feedstock/blob/master/recipe/activate.sh
    - toolchain3: https://github.com/conda-forge/toolchain3-feedstock/blob/master/recipe/activate.sh
    - anaconda: https://github.com/AnacondaRecipes/aggregate/blob/master/clang/build.sh
    | Variable | toolchain only | anaconda only |
    | ---------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | CPPFLAGS | | -mmacosx-version-min=${MACOSX_VERSION_MIN} |
    | CFLAGS | -mmacosx-version-min=${MACOSX_VERSION_MIN} -m${ARCH} | -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe |
    | CXXFLAGS | -mmacosx-version-min=${MACOSX_VERSION_MIN} -m${ARCH} | -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 |
    | LDFLAGS | -mmacosx-version-min=${MACOSX_VERSION_MIN} -lc++ -Wl,-rpath,$PREFIX/lib | -pie |
    | LDFLAGS_CC | | -Wl,-pie -Wl,-headerpad_max_install_names |
    | | | |

A lot of feedstocks override -march in inconsistent ways. Should this be discouraged - unless the package supports graceful degradation when run on lesser hardware? I've seen such recommendations in various issues, maybe this should be made explicit in the docs to make it more discoverable?

The minimum supported architectures have not been updated in a while, should they maybe be?

Here's a collection of somewhat related issues I could find:

CentOS will raise minimum microarch level to x86-64-v2 in version 9 - but end of support of 8 is years away, probably after 2030.

To the best of my knowledge, this is a perfect summary of the current situation. This would be an excellent topic to cover in the conda-forge calls.

@jaimergp - thanks for confirming my investigation didn't go in the wrong direction. Calls are nice, but I don't attend them and so won't many people who might like to know answers to such questions. Written (and search engine indexed) summaries would be very useful in addition!

Yep, the idea is to get some feedback there (because it spans multiple pieces of our infra) and then consolidate the outcome in this issue and, eventually, document it / adjust code as needed.

I added it to our tomorrow's agenda and will present it on your behalf, if that's ok.

Ok @corneliusroemer, better late than never, but I brought this topic up in today's core. Basically everything here seems to be correct, so it would be awesome to have it as part of the documentation. Maybe after this section?

This choice of flag goes waaay back. We'd have to ask some old timers why they picked this versus something else.

I thought we had the ability to improve performance with archspec. it creates a whole build matrix, but maybe worthwhile to look into for your usecase?

#1261

We do @hmaarrfk, but that is not original to conda. The choice of nocona as the min was my by anaconda inc ages ago.