Avoid -march=native / -mtune=skylake

Issue #63 resolved
Martin Schreiber created an issue

Using -march=native and -mtune=skylake per default might generate code which can’t be executed on some compute nodes on a heterogeneous system (or in valgrind where it made in particular trouble for me).

It would be good to have a ./configure option to disable these optimizations or to modify the -march or -mtune compile flags. Overriding them with CFLAGS=-mtune=generic doesn’t seem to work.

Comments (5)

  1. Nathanaël Schaeffer repo owner

    -march=native is really important for performance, and I think it should remain the default. I mean you will not get AVX* instructions without the proper march. On intel cpu, you can loose up to a factor 8 in performance compared to x86-64 generic architecture.
    It does imply you have to compile shtns on the machine you plan to run.

    I have to think what is the best way to solve this, while having high performance by default. Maybe a --with-march option that overrides the native setting? I don’t think -mtune=skylake is a problem though, as it does not emmit any skylake instructions (it only affects instruction order).
    I’m also not sure adding another comfigure option is any simpler than editing the Makefile to change -march=native to your choice (it appears only in two nearby places).

  2. Martin Schreiber reporter

    Yes, I’m OK with having the current options still to be the default, but there should be IMHO some override to set them.

  3. Nathanaël Schaeffer repo owner

    commit 72cd287 introduces --enable-march configure option. You can specify your target cpu architecture (e.g. --enable-march=skylake) or disable it to pick system default (--disable-march).
    The default value is --enable-march=native.
    This is now part of master branch and v3.6 release.

  4. Log in to comment