despacer icon indicating copy to clipboard operation
despacer copied to clipboard

Use `-march=haswell` or similar flags instead of `-march=native`

Open aminya opened this issue 2 years ago • 4 comments

The CMake file uses -march=native, which generates binaries that are not usable on other machines that might lack the instruction set. I think the better approach would be to use -march=haswell, which is a good default these days.

For avx512, a CMake option could be exposed.

https://github.com/lemire/despacer/blob/579530b9cc3470787dbba7aa43ac72fd6a97967b/CMakeLists.txt#L17-L19

-march=haswell includes AVX2 and older SSE instruction sets : https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html

aminya avatar Dec 04 '23 05:12 aminya

I think it makes a lot of sense to build this on the machine you intend to run it on.

sharpobject avatar Dec 04 '23 05:12 sharpobject

@aminya

Intel recently disable AVX on some processors due to a vulnerability. So you cannot count on haswell to work on nearly all systems today.

The real solution is to use runtime dispatching.

lemire avatar Dec 04 '23 15:12 lemire

There's also the libsimdpp, which already handles the runtime dispatch, and it could also fix the issue for supporting more architectures like Arm Neon (#4)

https://github.com/p12tic/libsimdpp

The dispatching part can be reused in case we don't want to rewrite the functions. https://github.com/p12tic/libsimdpp/tree/master/simdpp/dispatch

aminya avatar Dec 04 '23 19:12 aminya

Well, I know how to do the runtime dispatching. That's not a problem.

The question is whether anyone is planning to use this software for something serious. If so, they should get in touch with me and we can put in the effort.

I just wrote this code for research purposes.

lemire avatar Dec 04 '23 19:12 lemire