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.
144 lines
3.4 KiB
144 lines
3.4 KiB
8 years ago
|
#include<simdfuncs.h>
|
||
|
#include<stdio.h>
|
||
6 years ago
|
#include<string.h>
|
||
8 years ago
|
|
||
6 years ago
|
typedef void (*simd_func)(float*);
|
||
|
|
||
|
int check_simd_implementation(float *four,
|
||
|
const float *four_initial,
|
||
|
const char *simd_type,
|
||
|
const float *expected,
|
||
|
simd_func fptr,
|
||
|
const int blocksize) {
|
||
|
int rv = 0;
|
||
|
memcpy(four, four_initial, blocksize*sizeof(float));
|
||
|
printf("Using %s.\n", simd_type);
|
||
|
fptr(four);
|
||
|
for(int i=0; i<blocksize; i++) {
|
||
|
if(four[i] != expected[i]) {
|
||
|
printf("Increment function failed, got %f expected %f.\n", four[i], expected[i]);
|
||
|
rv = 1;
|
||
|
}
|
||
|
}
|
||
|
return rv;
|
||
|
}
|
||
8 years ago
|
|
||
|
int main(int argc, char **argv) {
|
||
6 years ago
|
static const float four_initial[4] = {2.0, 3.0, 4.0, 5.0};
|
||
6 years ago
|
ALIGN_16 float four[4];
|
||
8 years ago
|
const float expected[4] = {3.0, 4.0, 5.0, 6.0};
|
||
6 years ago
|
int r=0;
|
||
|
const int blocksize = 4;
|
||
8 years ago
|
|
||
6 years ago
|
/*
|
||
|
* Test all implementations that the current CPU supports.
|
||
8 years ago
|
*/
|
||
8 years ago
|
#if HAVE_NEON
|
||
6 years ago
|
if(neon_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"NEON",
|
||
|
expected,
|
||
|
increment_neon,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_AVX2
|
||
6 years ago
|
if(avx2_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"AVX2",
|
||
|
expected,
|
||
|
increment_avx2,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_AVX
|
||
6 years ago
|
if(avx_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"AVC",
|
||
|
expected,
|
||
|
increment_avx,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSE42
|
||
6 years ago
|
if(sse42_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSR42",
|
||
|
expected,
|
||
|
increment_sse42,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSE41
|
||
6 years ago
|
if(sse41_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSE41",
|
||
|
expected,
|
||
|
increment_sse41,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSSE3
|
||
6 years ago
|
if(ssse3_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSSE3",
|
||
|
expected,
|
||
|
increment_ssse3,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSE3
|
||
6 years ago
|
if(sse3_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSE3",
|
||
|
expected,
|
||
|
increment_sse3,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSE2
|
||
6 years ago
|
if(sse2_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSE2",
|
||
|
expected,
|
||
|
increment_sse2,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
8 years ago
|
#if HAVE_SSE
|
||
6 years ago
|
if(sse_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"SSE",
|
||
|
expected,
|
||
|
increment_sse,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
|
#if HAVE_MMX
|
||
6 years ago
|
if(mmx_available()) {
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"MMX",
|
||
|
expected,
|
||
|
increment_mmx,
|
||
|
blocksize);
|
||
8 years ago
|
}
|
||
|
#endif
|
||
6 years ago
|
r += check_simd_implementation(four,
|
||
|
four_initial,
|
||
|
"fallback",
|
||
|
expected,
|
||
|
increment_fallback,
|
||
|
blocksize);
|
||
6 years ago
|
return r;
|
||
8 years ago
|
}
|