Added VS support to simd detector.

pull/1374/head
Jussi Pakkanen 8 years ago
parent fefbb296f7
commit 8396c4f3e6
  1. 10
      mesonbuild/compilers/c.py
  2. 24
      mesonbuild/compilers/compilers.py
  3. 4
      mesonbuild/compilers/cpp.py
  4. 3
      mesonbuild/environment.py
  5. 1
      mesonbuild/modules/simd.py
  6. 10
      test cases/common/139 simd/simd_avx.c
  7. 13
      test cases/common/139 simd/simd_avx2.c
  8. 25
      test cases/common/139 simd/simd_mmx.c
  9. 7
      test cases/common/139 simd/simd_sse.c
  10. 12
      test cases/common/139 simd/simd_sse2.c
  11. 9
      test cases/common/139 simd/simd_sse3.c
  12. 15
      test cases/common/139 simd/simd_sse41.c
  13. 14
      test cases/common/139 simd/simd_sse42.c
  14. 14
      test cases/common/139 simd/simd_ssse3.c

@ -810,7 +810,7 @@ class VisualStudioCCompiler(CCompiler):
std_warn_args = ['/W3']
std_opt_args = ['/O2']
def __init__(self, exelist, version, is_cross, exe_wrap):
def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
self.id = 'msvc'
# /showIncludes is needed for build dependency tracking in Ninja
@ -820,6 +820,7 @@ class VisualStudioCCompiler(CCompiler):
'2': ['/W3'],
'3': ['/W4']}
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like
self.is_64 = True
# Override CCompiler.get_always_args
def get_always_args(self):
@ -1005,3 +1006,10 @@ class VisualStudioCCompiler(CCompiler):
if not isinstance(args, list):
args = [args]
return ['/WHOLEARCHIVE:' + x for x in args]
def get_instruction_set_args(self, instruction_set):
if self.is_64:
return vs64_instruction_set_args.get(instruction_set, None)
return vs32_instruction_set_args.get(instruction_set, None)

@ -240,6 +240,30 @@ gnulike_instruction_set_args = {'mmx': ['-mmmx'],
'neon': ['-mfpu=neon'],
}
vs32_instruction_set_args = {'mmx': ['/arch:SSE'], # There does not seem to be a flag just for MMX
'sse': ['/arch:SSE'],
'sse2': ['/arch:SSE2'],
'sse3': ['/arch:AVX'], # VS leaped from SSE2 directly to AVX.
'sse41': ['/arch:AVX'],
'sse42': ['/arch:AVX'],
'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'],
'neon': None,
}
# The 64 bit compiler defaults to /arch:avx.
vs64_instruction_set_args = {'mmx': ['/arch:AVX'],
'sse': ['/arch:AVX'],
'sse2': ['/arch:AVX'],
'sse3': ['/arch:AVX'],
'ssse3': ['/arch:AVX'],
'sse41': ['/arch:AVX'],
'sse42': ['/arch:AVX'],
'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'],
'neon': None,
}
def sanitizer_compile_args(value):
if value == 'none':

@ -173,10 +173,10 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap):
def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
self.language = 'cpp'
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap, is_64)
self.base_options = ['b_pch'] # FIXME add lto, pgo and the like
def get_options(self):

@ -537,8 +537,9 @@ class Environment:
# Visual Studio prints version number to stderr but
# everything else to stdout. Why? Lord only knows.
version = search_version(err)
is_64 = err.split()[0].endswith(' x64')
cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler
return cls(compiler, version, is_cross, exe_wrap)
return cls(compiler, version, is_cross, exe_wrap, is_64)
if '(ICC)' in out:
# TODO: add microsoft add check OSX
inteltype = ICC_STANDARD

@ -57,6 +57,7 @@ class SimdModule(ExtensionModule):
iset_fname = kwargs[iset] # Migth also be an array or Files. static_library will validate.
args = compiler.get_instruction_set_args(iset)
if args is None:
mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
continue
if len(args) > 0:
if not compiler.has_multi_arguments(args, state.environment):

@ -1,13 +1,21 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<stdint.h>
#ifdef _MSC_VER
#include<intrin.h>
int avx_available() {
return 1;
}
#else
#include<immintrin.h>
#include<cpuid.h>
#include<stdint.h>
int avx_available() {
return __builtin_cpu_supports("avx");
}
#endif
void increment_avx(float arr[4]) {
double darr[4];

@ -1,13 +1,24 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<stdint.h>
/*
* FIXME add proper runtime detection for VS.
*/
#ifdef _MSC_VER
#include<intrin.h>
int avx2_available() {
return 0;
}
#else
#include<immintrin.h>
#include<cpuid.h>
#include<stdint.h>
int avx2_available() {
return __builtin_cpu_supports("avx2");
}
#endif
void increment_avx2(float arr[4]) {
double darr[4];

@ -1,10 +1,27 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<mmintrin.h>
#include<cpuid.h>
#include<stdint.h>
#ifdef _MSC_VER
#include<intrin.h>
int mmx_available() {
return 1;
}
/* Contrary to MSDN documentation, MMX intrinsics
* just plain don't work.
*/
void increment_mmx(float arr[4]) {
arr[0]++;
arr[1]++;
arr[2]++;
arr[3]++;
}
#else
#include<mmintrin.h>
#include<cpuid.h>
int mmx_available() {
return __builtin_cpu_supports("mmx");
}
@ -19,7 +36,9 @@ void increment_mmx(float arr[4]) {
int64_t unpacker = _m_to_int64(result);
_mm_empty();
for(int i=0; i<4; i++) {
arr[i] = unpacker & ((1<<16)-1);
arr[i] = (float)(unpacker & ((1<<16)-1));
unpacker >>= 16;
}
}
#endif

@ -1,6 +1,12 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#ifdef _MSC_VER
#include<intrin.h>
int sse_available() {
return 1;
}
#else
#include<xmmintrin.h>
#include<cpuid.h>
#include<stdint.h>
@ -8,6 +14,7 @@
int sse_available() {
return __builtin_cpu_supports("sse");
}
#endif
void increment_sse(float arr[4]) {
__m128 val = _mm_load_ps(arr);

@ -1,19 +1,26 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<emmintrin.h>
#ifdef _MSC_VER
int sse2_available() {
return 1;
}
#else
#include<cpuid.h>
#include<stdint.h>
int sse2_available() {
return __builtin_cpu_supports("sse2");
}
#endif
void increment_sse2(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d one = _mm_set_pd(1.0, 1.0);
__m128d result = _mm_add_pd(val1, one);
_mm_store_pd(darr, result);
result = _mm_add_pd(val2, one);
@ -23,3 +30,4 @@ void increment_sse2(float arr[4]) {
arr[2] = (float)darr[3];
arr[3] = (float)darr[2];
}

@ -1,6 +1,12 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#ifdef _MSC_VER
#include<intrin.h>
int sse3_available() {
return 1;
}
#else
#include<pmmintrin.h>
#include<cpuid.h>
#include<stdint.h>
@ -8,12 +14,13 @@
int sse3_available() {
return __builtin_cpu_supports("sse3");
}
#endif
void increment_sse3(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d one = _mm_set_pd(1.0, 1.0);
__m128d result = _mm_add_pd(val1, one);
_mm_store_pd(darr, result);
result = _mm_add_pd(val2, one);

@ -1,19 +1,30 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<stdint.h>
#ifdef _MSC_VER
#include<intrin.h>
int sse41_available() {
return 1;
}
#else
#include<smmintrin.h>
#include<cpuid.h>
#include<stdint.h>
int sse41_available() {
return __builtin_cpu_supports("sse4.1");
}
#endif
void increment_sse41(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d one = _mm_set_pd(1.0, 1.0);
__m128d result = _mm_add_pd(val1, one);
result = _mm_ceil_pd(result); /* A no-op, only here to use a SSE4.1 intrinsic. */
_mm_store_pd(darr, result);

@ -1,19 +1,29 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<stdint.h>
#ifdef _MSC_VER
#include<intrin.h>
int sse42_available() {
return 1;
}
#else
#include<nmmintrin.h>
#include<cpuid.h>
#include<stdint.h>
int sse42_available() {
return __builtin_cpu_supports("sse4.2");
}
#endif
void increment_sse42(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d one = _mm_set_pd(1.0, 1.0);
__m128d result = _mm_add_pd(val1, one);
_mm_store_pd(darr, result);
result = _mm_add_pd(val2, one);

@ -3,6 +3,16 @@
#include<emmintrin.h>
#include<tmmintrin.h>
#ifdef _MSC_VER
#include<intrin.h>
int ssse3_available() {
return 1;
}
#else
#include<cpuid.h>
#include<stdint.h>
@ -14,11 +24,13 @@ int ssse3_available() {
#endif
}
#endif
void increment_ssse3(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d one = _mm_set_pd(1.0, 1.0);
__m128d result = _mm_add_pd(val1, one);
__m128i tmp1, tmp2;
tmp1 = tmp2 = _mm_set1_epi16(0);

Loading…
Cancel
Save