Handmade Network»Forums
Jack Mott
110 posts
Web Developer by day, game hobbyist by night.
SIMD Enhanced noise functions in C++
Edited by Jack Mott on Reason: words
Thought some of you may find this handy. I worked with the author of this a bit, my own SIMD noise library inspired him to SIMDify his own, and he expanded on my work and made a much more user friendly version that is even faster:

https://github.com/Auburns/FastNoiseSIMD

It does some nice stuff like runtime detection of the available instruction set, with fallbacks from AVX2->SSE->Scalar automatically.

Mārtiņš Možeiko
2562 posts / 2 projects
SIMD Enhanced noise functions in C++
Edited by Mārtiņš Možeiko on
The way you detect instruction set at runtime won't work with GCC/clang.

For example, if you want to use AVX intrinsics with GCC then it requires to compile whole file with "-mavx" compile switch. This means compiler will generate AVX instructions even in regular code (for optimization purposes). But then if you'll run executable on CPU where there are no AVX instructions available, then it will crash. Sure your GetFastestSIMD function will detect that it cannot use AVX instructions, but they will be present in other code.

The only reasonable way to support multiple instruction sets with runtime detection in GCC/clang is to put it into separate files. one file per instruction set.

Btw, you don't need to include algorithm header for cpuid. algorithm is C++ STL header. __cpuidex is in intrin.h file.
Jack Mott
110 posts
Web Developer by day, game hobbyist by night.
SIMD Enhanced noise functions in C++
Edited by Jack Mott on Reason: new info
I know the author is working on a GCC compatible solution now, I think he had an approach that would work, I'll forward him to this thread so he can see it.

edit: his latest update should work with GCC now