Add AVX support.

pull/1374/head
Jussi Pakkanen 8 years ago
parent fc68e0c63a
commit 71ffbd5b73
  1. 2
      test cases/common/139 simd/meson.build
  2. 26
      test cases/common/139 simd/simd_avx.c
  3. 6
      test cases/common/139 simd/simdchecker.c

@ -18,7 +18,6 @@ cdata = configuration_data()
# The following headers need to be added. Also Thumb and Altivec. # The following headers need to be added. Also Thumb and Altivec.
#<wmmintrin.h> AES #<wmmintrin.h> AES
#<immintrin.h> AVX
#<zmmintrin.h> AVX512 #<zmmintrin.h> AVX512
simdlibs = [] simdlibs = []
@ -30,6 +29,7 @@ simdarr = [['-mmmx', 'HAVE_MMX', 'simd_mmx', 'simd_mmx.c'],
['-mssse3', 'HAVE_SSSE3', 'simd_ssse3', 'simd_ssse3.c'], ['-mssse3', 'HAVE_SSSE3', 'simd_ssse3', 'simd_ssse3.c'],
['-msse4.1', 'HAVE_SSE41', 'simd_sse41', 'simd_sse41.c'], ['-msse4.1', 'HAVE_SSE41', 'simd_sse41', 'simd_sse41.c'],
['-msse4.2', 'HAVE_SSE42', 'simd_sse42', 'simd_sse42.c'], ['-msse4.2', 'HAVE_SSE42', 'simd_sse42', 'simd_sse42.c'],
['-mavx', 'HAVE_AVX', 'simd_avx', 'simd_avx.c'],
] ]
foreach ia : simdarr foreach ia : simdarr

@ -0,0 +1,26 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<immintrin.h>
#include<cpuid.h>
#include<stdint.h>
int avx_available() {
return __builtin_cpu_supports("avx");
}
void increment_avx(float arr[4]) {
double darr[4];
darr[0] = arr[0];
darr[1] = arr[1];
darr[2] = arr[2];
darr[3] = arr[3];
__m256d val = _mm256_loadu_pd(darr);
__m256d one = _mm256_set1_pd(1.0);
__m256d result = _mm256_add_pd(val, one);
_mm256_storeu_pd(darr, result);
arr[0] = (float)darr[0];
arr[1] = (float)darr[1];
arr[2] = (float)darr[2];
arr[3] = (float)darr[3];
}

@ -17,6 +17,12 @@ int main(int argc, char **argv) {
/* Add here. The first matched one is used so put "better" instruction /* Add here. The first matched one is used so put "better" instruction
* sets at the top. * sets at the top.
*/ */
#if HAVE_AVX
if(fptr == NULL && avx_available()) {
fptr = increment_avx;
type = "AVX";
}
#endif
#if HAVE_SSE42 #if HAVE_SSE42
if(fptr == NULL && sse42_available()) { if(fptr == NULL && sse42_available()) {
fptr = increment_sse42; fptr = increment_sse42;

Loading…
Cancel
Save