The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
#include<simdfuncs.h> |
|
#include<stdio.h> |
|
|
|
/* |
|
* A function that checks at runtime which simd accelerations are |
|
* available and calls the best one. Falls |
|
* back to plain C implementation if SIMD is not available. |
|
*/ |
|
|
|
int main(int argc, char **argv) { |
|
float four[4] = {2.0, 3.0, 4.0, 5.0}; |
|
const float expected[4] = {3.0, 4.0, 5.0, 6.0}; |
|
void (*fptr)(float[4]) = NULL; |
|
const char *type; |
|
int i; |
|
|
|
/* Add here. The first matched one is used so put "better" instruction |
|
* sets at the top. |
|
*/ |
|
#if HAVE_SSE3 |
|
if(fptr == NULL && sse3_available()) { |
|
fptr = increment_sse3; |
|
type = "SSE3"; |
|
} |
|
#endif |
|
#if HAVE_SSE2 |
|
if(fptr == NULL && sse2_available()) { |
|
fptr = increment_sse2; |
|
type = "SSE2"; |
|
} |
|
#endif |
|
#if HAVE_SSE |
|
if(fptr == NULL && sse_available()) { |
|
fptr = increment_sse; |
|
type = "SSE"; |
|
} |
|
#endif |
|
#if HAVE_MMX |
|
if(fptr == NULL && mmx_available()) { |
|
fptr = increment_mmx; |
|
type = "MMX"; |
|
} |
|
#endif |
|
if(fptr == NULL) { |
|
fptr = increment_fallback; |
|
type = "fallback"; |
|
} |
|
printf("Using %s.\n", type); |
|
fptr(four); |
|
for(i=0; i<4; i++) { |
|
if(four[i] != expected[i]) { |
|
printf("Increment function failed, got %f expected %f.\n", four[i], expected[i]); |
|
return 1; |
|
} |
|
} |
|
return 0; |
|
}
|
|
|