From 0ad59584f9a8dfb613a9b7fd89a78f6adfef503d Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 30 Dec 2015 15:08:39 +0100 Subject: [PATCH 3/4] configure: add -msee when using xmmintin.h Fixes #57 --- configure.ac | 29 ++++++++++++++++++++++------- src/lib/core/core.c | 10 +++++++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 3b7c920..5b5681a 100644 --- a/configure.ac +++ b/configure.ac @@ -538,17 +538,32 @@ AC_CHECK_DECL(sysi86,[ ]) dnl check for SSE intrisics +have_mmx_intrinsics=no ARCH_CFLAGS="" -ARCH_CPPFLAGS="" case "x${target_cpu}" in xi?86|k?|xx86_64|xamd64) - # seems to cause "CPU you selected does not support x86-64 instruction set" on some targets - #ARCH_CFLAGS="-march=native" - ARCH_CPPFLAGS="-D__SSE__ -D__MMX__" - AC_CHECK_HEADERS([xmmintrin.h]) + AC_CHECK_HEADERS([xmmintrin.h], + [ + SAVED_CFLAGS="${CFLAGS}" + AC_MSG_CHECKING([for working mmx intrinsics]) + CFLAGS="-mmmx -msse" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + int main () { + _mm_getcsr (); + }]])], [ + AC_MSG_RESULT(yes) + have_mmx_intrinsics=yes],[ + AC_MSG_RESULT(no)]) + CFLAGS="${SAVED_CFLAGS}" + ARCH_CFLAGS="-mmmx -msse" + ],[]) ;; esac - +if test $have_mmx_intrinsics = yes ; then + AC_DEFINE(USE_X86_MMX, 1, [use x86 MMX compiler intrinsics]) + ARCH_CFLAGS="-mmmx -msse" +fi dnl check for libraries LT_LIB_M @@ -593,7 +608,7 @@ AC_ARG_ENABLE(Bsymbolic, dnl Extra vars BT_INCLUDEDIR='-I${includedir}' dnl -Wl,--as-needed # can be put into CFLAGS to drop all unused libs -BT_CFLAGS="$ARCH_CFLAGS $ARCH_CPPFLAGS $DEBUG_CFLAGS $COVERAGE_CFLAGS $BT_DISABLE_DEPRECATED" +BT_CFLAGS="$ARCH_CFLAGS $DEBUG_CFLAGS $COVERAGE_CFLAGS $BT_DISABLE_DEPRECATED" BT_LIBDIR='-L${libdir}' BT_LIBS="$COVERAGE_LIBS" BT_LDFLAGS="$DEBUG_LDFLAGS" diff --git a/src/lib/core/core.c b/src/lib/core/core.c index 6a03d5e..f9d2061 100644 --- a/src/lib/core/core.c +++ b/src/lib/core/core.c @@ -32,14 +32,16 @@ #ifdef HAVE_SCHED_SETSCHEDULER #include -#if HAVE_MLOCKALL +#ifdef HAVE_MLOCKALL #include #endif #endif -#if HAVE_XMMINTRIN_H +#ifdef USE_X86_MMX +#ifdef HAVE_XMMINTRIN_H #include #endif +#endif /** * bt_major_version: @@ -145,11 +147,13 @@ bt_init_post (void) #endif #endif -#if HAVE_XMMINTRIN_H +#if USE_X86_MMX // TODO(ensonic): we need to probe the CPU capabilities // see http://www.mail-archive.com/linux-audio-dev@music.columbia.edu/msg19520.html // [linux-audio-dev] Channels and best practice // _MM_FLUSH_ZERO_ON = FZ + // TODO(ensonic): wikipedia says we must do this for each thread: + // https://en.wikipedia.org/wiki/Denormal_number#Disabling_denormal_floats_at_the_code_level _mm_setcsr (_mm_getcsr () | 0x8040); // set DAZ and FZ bits #endif -- 2.6.4