Added SSE support.

pull/1374/head
Jussi Pakkanen 8 years ago
parent 4a8ca14d44
commit 9e5578ac47
  1. 16
      test cases/common/139 simd/meson.build
  2. 3
      test cases/common/139 simd/simd_mmx.c
  3. 17
      test cases/common/139 simd/simd_sse.c
  4. 16
      test cases/common/139 simd/simdchecker.c

@ -16,6 +16,17 @@ cdata = configuration_data()
#
# and then have a target that uses the result in links_with.
# The following headers need to be added. Also Thumb and Altivec.
#<emmintrin.h> SSE2
#<pmmintrin.h> SSE3
#<tmmintrin.h> SSSE3
#<smmintrin.h> SSE4.1
#<nmmintrin.h> SSE4.2
#<ammintrin.h> SSE4A
#<wmmintrin.h> AES
#<immintrin.h> AVX
#<zmmintrin.h> AVX512
simdlibs = []
if cc.has_argument('-mmmx')
@ -23,6 +34,11 @@ if cc.has_argument('-mmmx')
simdlibs += static_library('simd_mmx', 'simd_mmx.c', c_args : '-mmmx')
endif
if cc.has_argument('-msse')
cdata.set('HAVE_SSE', 1)
simdlibs += static_library('simd_sse', 'simd_sse.c', c_args : '-msse')
endif
configure_file(output : 'simdconfig.h',
configuration : cdata)

@ -1,3 +1,6 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<mmintrin.h>
#include<cpuid.h>
#include<stdint.h>

@ -0,0 +1,17 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<xmmintrin.h>
#include<cpuid.h>
#include<stdint.h>
int sse_available() {
return __builtin_cpu_supports("sse");
}
void increment_sse(float arr[4]) {
__m128 val = _mm_load_ps(arr);
__m128 one = _mm_set_ps1(1.0);
__m128 result = _mm_add_ps(val, one);
_mm_storeu_ps(arr, result);
}

@ -12,12 +12,18 @@ int main(int argc, char **argv) {
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_SSE
/* Add here. The first matched one is used so put "better" instruction
* sets at the top.
*/
#elif HAVE_MMX
if(fptr == NULL && sse_available()) {
fptr = increment_sse;
type = "SSE";
}
#endif
#if HAVE_MMX
if(fptr == NULL && mmx_available()) {
fptr = increment_mmx;
type = "MMX";
@ -29,7 +35,7 @@ int main(int argc, char **argv) {
}
printf("Using %s.\n", type);
fptr(four);
for(int i=0; i<4; i++) {
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;

Loading…
Cancel
Save