From 4968bf1ccdc640257e02821fdbae06cfaf4e3816 Mon Sep 17 00:00:00 2001 From: Hoernchen Date: Sun, 5 Jul 2015 17:08:06 +0200 Subject: [PATCH 1/2] Allow building without SSE. --- CMakeLists.txt | 25 ++++++++++++++++--------- include-gpl/dsp/interpolator.h | 2 ++ sdrbase/gui/glspectrum.cpp | 5 +++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 593c9db7d..aeac073de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,10 @@ find_package(PkgConfig) find_package(FFTW3F) +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|x86") + SET(USE_SIMD "SSE2" CACHE STRING "Use SIMD instructions") +ENDIF() + ############################################################################## #include(${QT_USE_FILE}) @@ -259,15 +263,18 @@ include_directories( ${OPENGL_INCLUDE_DIR} ) -if(MSVC) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE2" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE2" ) - set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) - add_definitions (/D "_CRT_SECURE_NO_WARNINGS") -else() - #set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" ) - #set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" ) - add_definitions(-msse2 -Wall) +if(USE_SIMD MATCHES SSE2) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" ) + add_definitions(-DUSE_SIMD) + elseif(MSVC) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE2" ) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE2" ) + set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) + add_definitions (/D "_CRT_SECURE_NO_WARNINGS") + add_definitions(-DUSE_SIMD) + endif() endif() ############################################################################## diff --git a/include-gpl/dsp/interpolator.h b/include-gpl/dsp/interpolator.h index 26a423f2c..e498fb3d4 100644 --- a/include-gpl/dsp/interpolator.h +++ b/include-gpl/dsp/interpolator.h @@ -1,7 +1,9 @@ #ifndef INCLUDE_INTERPOLATOR_H #define INCLUDE_INTERPOLATOR_H +#ifdef USE_SIMD #include +#endif #include "dsp/dsptypes.h" #include "util/export.h" #include diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 619b7f611..45ff99582 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -15,7 +15,9 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#ifdef USE_SIMD #include +#endif #include #include "gui/glspectrum.h" @@ -313,8 +315,7 @@ void GLSpectrum::updateHistogram(const std::vector& spectrum) m_histogramHoldoffCount = m_histogramHoldoffBase; } -//#define NO_AVX -#ifdef NO_AVX +#ifndef USE_SIMD for(int i = 0; i < m_fftSize; i++) { int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0); From 5a3dbe4bfce4ee4f1a06851f5bd25d99fd14b586 Mon Sep 17 00:00:00 2001 From: Hoernchen Date: Tue, 7 Jul 2015 22:28:50 +0200 Subject: [PATCH 2/2] Allow building without sse #2. --- include-gpl/dsp/interpolator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include-gpl/dsp/interpolator.h b/include-gpl/dsp/interpolator.h index e498fb3d4..961db9123 100644 --- a/include-gpl/dsp/interpolator.h +++ b/include-gpl/dsp/interpolator.h @@ -55,7 +55,7 @@ private: { if (phase < 0) phase = 0; -#if 1 +#if USE_SIMD // beware of the ringbuffer if(m_ptr == 0) { // only one straight block