Description
Investigating McStas performance in conda envs with @willend, we concluded what in hindsight appears obvious: applications (like mcstas and simplebuild both) where users both compile+run code themselves, can benefit greatly from having the compilation targeting the native platform. In particular it might be useful to tack on -march=native -mtune=native
. Investigating in a conda-forge env on ubuntu 22, we found that tacking the following flags all helped (the two first was for an executable obviously):
-fno-PIC -fPIE -flto -O3 -mtune=native -march=native -fno-math-errno -ftree-vectorize -g -DNDEBUG
Another related revelation we made is that while conda-forge provide a modern gcc-12 compiler, the std c library is in an ancient version. There is not much to do about that, but for C code using the defines in math.h
, we saw extremely slow isnan
and isinf
due to some obnoxious macros, so it helped a lot to inject the following after math.h
was included:
#if defined(__GNUC__) || defined(__clang__)
# ifdef isnan
# undef isnan
# endif
# ifdef isinf
# undef isinf
# endif
# define isnan(x) __builtin_isnan(x)
# define isinf(x) __builtin_isinf(x)
#endif
C++ code might not be affected by this.
Activity