TravisWheelerLab / NINJA

Nearly Infinite Neighbor Joining Application
MIT License
5 stars 7 forks source link

Add SSE / AVX detection at runtime #13

Open glesica opened 4 years ago

glesica commented 4 years ago

The makefile should be smart enough not to try to build the software with SSE or AVX if it is unsupported. Eventually it might be nice to make this a runtime check, but this is a reasonable substitute and likely to be simpler.

We want to do the right thing at runtime depending on whether the CPU supports SSE or AVX. The code below (from Sarah) allows us to check, in theory:

if (__builtin_cpu_supports ("avx2")){
    //use avx2
    //TODO: maybe set a global bool as an avx flag?
}
else if (__builtin_cpu_supports ("ssse3")){
    //use ssse3
    //TODO: set bool?getBitsDNA
}
else {
    //TODO: use sse2 - bool?
}