roaringbitmap icon indicating copy to clipboard operation
roaringbitmap copied to clipboard

Apple M1 does not support -march=native

Open andreasvc opened this issue 1 year ago • 8 comments

As reported in https://github.com/andreasvc/disco-dop/issues/68#issuecomment-1367505212_

andreasvc avatar Jan 02 '23 09:01 andreasvc

@BrettRey are you using gcc? See [1]. From [2] it seems it might be an issue with clang.

[1] https://github.com/andreasvc/disco-dop/#mac-os-x [2] https://stackoverflow.com/questions/65966969/why-does-march-native-not-work-on-apple-m1/66333485

andreasvc avatar Jan 02 '23 09:01 andreasvc

Observations:

  • Clang 15 supports -march=native, see https://stackoverflow.com/a/72597669
  • gcc can be installed on M1 with homebrew, which may or may not support -march=native. Documentation says it is only supported on Linux: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
  • a workaround is to remove both -march=native and -mtune=native for non-Linux systems, but this may be undesirable as a default, since optimizations probably have a large impact for this datastructure. This is done by https://github.com/Ezibenroc/PyRoaringBitMap/blob/cdea52c55bdb3a517f75151ebddaaf37b30e8b8e/setup.py
  • another option is to detect the architecture and specify the appropriate -march=... option for the most common cases, but this seems like a can of worms, and I'd rather leave this to the compiler.

Also see https://stackoverflow.com/questions/52653025/why-is-march-native-used-so-rarely

andreasvc avatar Jan 04 '23 12:01 andreasvc

python3 setup.py install --with-mtune worked for @BrettRey

nschneid avatar Jan 05 '23 23:01 nschneid

Note that CRoaring supports runtime dispatching and it does not need specific compiler directives.

lemire avatar Jan 06 '23 13:01 lemire

That is, you do not march=native when compiling CRoaring to get good performance at runtime.

lemire avatar Jan 06 '23 13:01 lemire

I recommend updating CRoaring and dropping the march=native.

lemire avatar Jan 12 '23 15:01 lemire

@lemire Correct me if I am wrong, but I think this library does not depend on CRoaring, this is a full reimplementation in Cython.

Ezibenroc avatar Jan 16 '23 12:01 Ezibenroc

@Ezibenroc I think you are correct.

lemire avatar Apr 26 '24 01:04 lemire