From 0d49f47aeb5a38273c4a356dc4780e3819747d60 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sun, 28 May 2017 18:20:02 +0700 Subject: core/conv: do not mix up AVX and SSE code According to GCC's wiki: If you specify command-line switches such as -msse, the compiler could use the extended instruction sets even if the built-ins are not used explicitly in the program. For this reason, applications that perform run-time CPU detection must compile separate files for each supported architecture, using the appropriate flags. In particular, the file containing the CPU detection code should be compiled without these options. So, this change introduces a separate Viterbi implementation, which is almost the same as previous one, but is being compiled with -mavx2. This implementation will be only used by CPUs with both SSE and AVX support: SSE3 and AVX2: viterbi_sse_avx.c SSE3 only: viterbi_sse.c Generic: viterbi_generic.c Change-Id: I042cc76258df7e4c6c90a73af3d0a6e75999b2b0 --- src/Makefile.am | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index e3a0f001..e98c623c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,11 +25,24 @@ libosmocore_la_SOURCES = timer.c timer_gettimeofday.c select.c signal.c msgb.c b if HAVE_SSE3 libosmocore_la_SOURCES += viterbi_sse.c -# Per-object flags hack -viterbi_sse.lo : CFLAGS += $(SIMD_FLAGS) +if HAVE_SSE4_1 +viterbi_sse.lo : CFLAGS += -msse3 -msse4.1 +else +viterbi_sse.lo : CFLAGS += -msse3 +endif + +if HAVE_AVX2 +libosmocore_la_SOURCES += viterbi_sse_avx.c +if HAVE_SSE4_1 +viterbi_sse_avx.lo : CFLAGS += -msse3 -mavx2 -msse4.1 +else +viterbi_sse_avx.lo : CFLAGS += -msse3 -mavx2 +endif +endif endif BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c +EXTRA_DIST = viterbi_sse_common.h if ENABLE_PLUGIN libosmocore_la_SOURCES += plugin.c -- cgit v1.2.3