From 9d5c6f765e54a412b421e6ecd26ba678847cddf2 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 10:40:09 +0200 Subject: [PATCH 01/15] libdsdcc: fix path and pkgconfig discovery --- cmake/Modules/FindLibDSDcc.cmake | 6 +++--- plugins/channelrx/demoddsd/dsddecoder.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/FindLibDSDcc.cmake b/cmake/Modules/FindLibDSDcc.cmake index c372583c5..a7fb016b0 100644 --- a/cmake/Modules/FindLibDSDcc.cmake +++ b/cmake/Modules/FindLibDSDcc.cmake @@ -2,11 +2,11 @@ if(NOT LIBDSDCC_FOUND) - pkg_check_modules (LIBDSDCC_PKG libdsdcc) + pkg_check_modules(LIBDSDCC_PKG libdsdcc) find_path(LIBDSDCC_INCLUDE_DIR - NAMES dsd_decoder.h - PATHS ${DSDCC_DIR}/include/dsdcc + NAMES dsdcc/dsd_decoder.h + PATHS ${DSDCC_DIR}/include ${LIBDSDCC_PKG_INCLUDE_DIRS} /usr/include/dsdcc /usr/local/include/dsdcc diff --git a/plugins/channelrx/demoddsd/dsddecoder.h b/plugins/channelrx/demoddsd/dsddecoder.h index 75f57bc78..ca2f84ebb 100644 --- a/plugins/channelrx/demoddsd/dsddecoder.h +++ b/plugins/channelrx/demoddsd/dsddecoder.h @@ -19,7 +19,7 @@ #ifndef PLUGINS_CHANNELRX_DEMODDSD_DSDDECODER_H_ #define PLUGINS_CHANNELRX_DEMODDSD_DSDDECODER_H_ -#include "dsd_decoder.h" +#include "dsdcc/dsd_decoder.h" class AudioFifo; From 941aea3b92bcc9271fde2c07cae2b1a57ea99035 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 10:42:39 +0200 Subject: [PATCH 02/15] cm256cc: fix path and pkgconfig discovery --- cmake/Modules/FindCM256cc.cmake | 8 ++++---- plugins/channelrx/remotesink/remotesinkthread.cpp | 2 +- plugins/channelrx/remotesink/remotesinkthread.h | 2 +- plugins/channeltx/remotesource/remotesource.h | 2 +- plugins/channeltx/remotesource/remotesourcethread.cpp | 2 +- plugins/samplesink/remoteoutput/udpsinkfecworker.h | 2 +- plugins/samplesource/remoteinput/remoteinputbuffer.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/Modules/FindCM256cc.cmake b/cmake/Modules/FindCM256cc.cmake index 1410e6618..43e95eb08 100644 --- a/cmake/Modules/FindCM256cc.cmake +++ b/cmake/Modules/FindCM256cc.cmake @@ -2,12 +2,12 @@ INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(PC_CM256cc "libcm256cc") FIND_PATH(CM256CC_INCLUDE_DIR - NAMES cm256.h + NAMES cm256cc/cm256.h HINTS ${PC_CM256CC_INCLUDE_DIR} ${CMAKE_INSTALL_PREFIX}/include - PATHS ${CM256CC_DIR}/include/cm256cc - /usr/local/include/cm256cc - /usr/include/cm256cc + PATHS ${CM256CC_DIR}/include + /usr/local/include + /usr/include ) FIND_LIBRARY(CM256CC_LIBRARIES diff --git a/plugins/channelrx/remotesink/remotesinkthread.cpp b/plugins/channelrx/remotesink/remotesinkthread.cpp index e1bbb6ce8..0a4a7bfd9 100644 --- a/plugins/channelrx/remotesink/remotesinkthread.cpp +++ b/plugins/channelrx/remotesink/remotesinkthread.cpp @@ -26,7 +26,7 @@ #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" MESSAGE_CLASS_DEFINITION(RemoteSinkThread::MsgStartStop, Message) diff --git a/plugins/channelrx/remotesink/remotesinkthread.h b/plugins/channelrx/remotesink/remotesinkthread.h index 04160bd3a..cfe3af953 100644 --- a/plugins/channelrx/remotesink/remotesinkthread.h +++ b/plugins/channelrx/remotesink/remotesinkthread.h @@ -29,7 +29,7 @@ #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" #include "util/message.h" #include "util/messagequeue.h" diff --git a/plugins/channeltx/remotesource/remotesource.h b/plugins/channeltx/remotesource/remotesource.h index 71494ba29..fb4d7840b 100644 --- a/plugins/channeltx/remotesource/remotesource.h +++ b/plugins/channeltx/remotesource/remotesource.h @@ -24,7 +24,7 @@ #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" #include "dsp/basebandsamplesource.h" #include "channel/channelsourceapi.h" diff --git a/plugins/channeltx/remotesource/remotesourcethread.cpp b/plugins/channeltx/remotesource/remotesourcethread.cpp index c9dc8036e..5a3f4c3e1 100644 --- a/plugins/channeltx/remotesource/remotesourcethread.cpp +++ b/plugins/channeltx/remotesource/remotesourcethread.cpp @@ -22,7 +22,7 @@ #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" diff --git a/plugins/samplesink/remoteoutput/udpsinkfecworker.h b/plugins/samplesink/remoteoutput/udpsinkfecworker.h index ecc2e96bd..c9e5a3bb3 100644 --- a/plugins/samplesink/remoteoutput/udpsinkfecworker.h +++ b/plugins/samplesink/remoteoutput/udpsinkfecworker.h @@ -24,7 +24,7 @@ #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" #include "util/messagequeue.h" #include "util/message.h" diff --git a/plugins/samplesource/remoteinput/remoteinputbuffer.h b/plugins/samplesource/remoteinput/remoteinputbuffer.h index ae8938697..e4bb9c1d2 100644 --- a/plugins/samplesource/remoteinput/remoteinputbuffer.h +++ b/plugins/samplesource/remoteinput/remoteinputbuffer.h @@ -22,7 +22,7 @@ #include #include #include -#include "cm256.h" +#include "cm256cc/cm256.h" #include "util/movingaverage.h" From 190fe374f2c534f49555bbe78afec63f38760268 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 10:45:06 +0200 Subject: [PATCH 03/15] add Boost include to demodbfm channelrx --- pluginssrv/channelrx/demodbfm/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pluginssrv/channelrx/demodbfm/CMakeLists.txt b/pluginssrv/channelrx/demodbfm/CMakeLists.txt index f1862946b..f77867152 100644 --- a/pluginssrv/channelrx/demodbfm/CMakeLists.txt +++ b/pluginssrv/channelrx/demodbfm/CMakeLists.txt @@ -30,7 +30,8 @@ endif() include_directories( . ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client + ${Boost_INCLUDE_DIRS} ) #include(${QT_USE_FILE}) From 21add4642294983a9fa6533605160359524ecfa1 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 10:54:27 +0200 Subject: [PATCH 04/15] libfreedv: fix some inconsistent use of complex, C99, and C++11 done by @guruofquality thanks a lot! --- CMakeLists.txt | 7 +++++++ libfreedv/CMakeLists.txt | 4 +++- libfreedv/freedv_filter.cpp | 2 +- libfreedv/freedv_vhf_framing.h | 1 + libfreedv/ofdm_internal.h | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6664d492..a63e489d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,13 @@ endif() set(QT_USE_QTOPENGL TRUE) set(CMAKE_AUTOMOC ON) +if(APPLE AND EXISTS /usr/local/opt/qt5) + # Homebrew installs Qt5 (up to at least 5.9.1) in + # /usr/local/qt5, ensure it can be found by CMake since + # it is not in the default /usr/local prefix. + list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5") +endif() + #find_package(Qt4 REQUIRED) find_package(Qt5Core 5.0 REQUIRED) find_package(Qt5Widgets 5.0 REQUIRED) diff --git a/libfreedv/CMakeLists.txt b/libfreedv/CMakeLists.txt index b37d83158..d3bc10ad1 100644 --- a/libfreedv/CMakeLists.txt +++ b/libfreedv/CMakeLists.txt @@ -1,5 +1,7 @@ project(freedv) +set(CMAKE_CXX_STANDARD 11) + set(freedv_SOURCES codec2_fft.cpp cohpsk.cpp @@ -80,4 +82,4 @@ target_link_libraries(freedv ${CODEC2_LIBRARIES} ) -install(TARGETS freedv DESTINATION lib) \ No newline at end of file +install(TARGETS freedv DESTINATION lib) diff --git a/libfreedv/freedv_filter.cpp b/libfreedv/freedv_filter.cpp index 8f10b13a3..0070b497b 100644 --- a/libfreedv/freedv_filter.cpp +++ b/libfreedv/freedv_filter.cpp @@ -25,7 +25,7 @@ #include "fdv_arm_math.h" -#define cmplx(value) (std::complex{cosf(value), sinf(value)}) +#define cmplx(value) (COSF(value) + SINF(value) * std::complex(0.0f, 1.0f)) namespace FreeDV { diff --git a/libfreedv/freedv_vhf_framing.h b/libfreedv/freedv_vhf_framing.h index 6f7dc3604..3f08cbb2e 100644 --- a/libfreedv/freedv_vhf_framing.h +++ b/libfreedv/freedv_vhf_framing.h @@ -36,6 +36,7 @@ #ifndef _FREEDV_VHF_FRAMING_H #define _FREEDV_VHF_FRAMING_H +#include #include "freedv_data_channel.h" /* Standard frame type */ diff --git a/libfreedv/ofdm_internal.h b/libfreedv/ofdm_internal.h index e9775f379..50963d1ad 100644 --- a/libfreedv/ofdm_internal.h +++ b/libfreedv/ofdm_internal.h @@ -41,7 +41,7 @@ #endif #define TAU (2.0f * M_PI) -#define ROT45 (M_PI / 4.0f) +#define ROT45 float(M_PI / 4.0f) #define cmplx(value) (std::complex{cosf(value), sinf(value)}) #define cmplxconj(value) (std::complex{cosf(value), -sinf(value)}) From 013eaa79ea11dd5978a10a08ae2155bf280e57d4 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 11:11:15 +0200 Subject: [PATCH 05/15] fix libusb-1.0 discovery --- cmake/Modules/FindLibUSB.cmake | 6 ++++-- fcdhid/CMakeLists.txt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindLibUSB.cmake b/cmake/Modules/FindLibUSB.cmake index 97f3db675..1d8c2544c 100644 --- a/cmake/Modules/FindLibUSB.cmake +++ b/cmake/Modules/FindLibUSB.cmake @@ -1,6 +1,7 @@ if(NOT LIBUSB_FOUND) pkg_check_modules (LIBUSB_PKG libusb-1.0) - find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h + find_path(LIBUSB_INCLUDE_DIR + NAMES libusb-1.0/libusb.h PATHS ${LIBUSB_PKG_INCLUDE_DIRS} /usr/include/libusb-1.0 @@ -8,7 +9,8 @@ if(NOT LIBUSB_FOUND) /usr/local/include ) - find_library(LIBUSB_LIBRARIES NAMES usb-1.0 + find_library(LIBUSB_LIBRARIES + NAMES usb-1.0 PATHS ${LIBUSB_PKG_LIBRARY_DIRS} /usr/lib diff --git a/fcdhid/CMakeLists.txt b/fcdhid/CMakeLists.txt index 668231c49..8001c34fa 100644 --- a/fcdhid/CMakeLists.txt +++ b/fcdhid/CMakeLists.txt @@ -16,6 +16,7 @@ set(fcdhid_HEADERS include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${LIBUSB_INCLUDE_DIR} ) #add_definitions(-DQT_PLUGIN) @@ -27,7 +28,7 @@ add_library(fcdhid SHARED target_link_libraries(fcdhid ${LIBUSB_LIBRARIES} - ${ICONV_LIBRARY} + ${ICONV_LIBRARY} ) install(TARGETS fcdhid DESTINATION lib) From 036eda0a9240eee2de2648f73eaaeaa1d96b433b Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 11:57:30 +0200 Subject: [PATCH 06/15] fcdpro/fcdproplus: disable samplesource on macOS --- plugins/samplesource/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/samplesource/CMakeLists.txt b/plugins/samplesource/CMakeLists.txt index d093126ec..215a7089c 100644 --- a/plugins/samplesource/CMakeLists.txt +++ b/plugins/samplesource/CMakeLists.txt @@ -29,10 +29,10 @@ if(LIBUSB_FOUND AND LIBBLADERF_FOUND) add_subdirectory(bladerf2input) endif(LIBUSB_FOUND AND LIBBLADERF_FOUND) -if(LIBUSB_FOUND) +if(LIBUSB_FOUND AND NOT APPLE) add_subdirectory(fcdpro) add_subdirectory(fcdproplus) -endif() +endif(LIBUSB_FOUND AND NOT APPLE) find_package(LibHACKRF) if(LIBUSB_FOUND AND LIBHACKRF_FOUND) From d1d51a5d34706b77a43ba15810c64b6b3cf25dd7 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 11:59:46 +0200 Subject: [PATCH 07/15] bladerf2output: fix warning format specifies type 'unsigned long' but the argument has type 'uint64_t' --- plugins/samplesink/bladerf2output/bladerf2outputgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/samplesink/bladerf2output/bladerf2outputgui.cpp b/plugins/samplesink/bladerf2output/bladerf2outputgui.cpp index 6797d1801..8b096d3ae 100644 --- a/plugins/samplesink/bladerf2output/bladerf2outputgui.cpp +++ b/plugins/samplesink/bladerf2output/bladerf2outputgui.cpp @@ -50,7 +50,7 @@ BladeRF2OutputGui::BladeRF2OutputGui(DeviceUISet *deviceUISet, QWidget* parent) ui->setupUi(this); m_sampleSink->getFrequencyRange(f_min, f_max, step); - qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getFrequencyRange: [%lu,%lu] step: %d", f_min, f_max, step); + qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getFrequencyRange: [%llu,%llu] step: %d", f_min, f_max, step); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000); From 140c170ac41f73c93dd7d6ef7700a5902dd74051 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 12:07:36 +0200 Subject: [PATCH 08/15] c++ register is deprecated and incompatible with C++17 with modern compiler and not on microcontroller seems useless --- libfreedv/mpdecode_core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreedv/mpdecode_core.cpp b/libfreedv/mpdecode_core.cpp index 50d0d0277..da8c0badc 100644 --- a/libfreedv/mpdecode_core.cpp +++ b/libfreedv/mpdecode_core.cpp @@ -135,7 +135,7 @@ static float max_star0( float delta1, float delta2 ) { - register float diff; + float diff; diff = delta2 - delta1; From 74786f550d9f55541b60a758fc30af9cd13bf65b Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 13:02:39 +0200 Subject: [PATCH 09/15] sdrbase: fix type warning warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') --- sdrbase/device/devicesinkapi.cpp | 36 +++++++++++++++--------------- sdrbase/device/devicesourceapi.cpp | 36 +++++++++++++++--------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sdrbase/device/devicesinkapi.cpp b/sdrbase/device/devicesinkapi.cpp index 45aa6b55e..bc02cb552 100644 --- a/sdrbase/device/devicesinkapi.cpp +++ b/sdrbase/device/devicesinkapi.cpp @@ -320,22 +320,22 @@ void DeviceSinkAPI::addSourceBuddy(DeviceSourceAPI* buddy) { m_sourceBuddies.push_back(buddy); buddy->m_sinkBuddies.push_back(this); - qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list [%lx] <-> [%lx]", + qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSinkAPI::addSinkBuddy(DeviceSinkAPI* buddy) { m_sinkBuddies.push_back(buddy); buddy->m_sinkBuddies.push_back(this); - qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list [%lx] <-> [%lx]", + qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy) @@ -346,21 +346,21 @@ void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy) { if (*it == buddy) { - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", + qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) (*it), - (uint64_t) this); + (quint64) (*it), + (quint64) this); m_sourceBuddies.erase(it); return; } } - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", + qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy) @@ -371,21 +371,21 @@ void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy) { if (*it == buddy) { - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", + qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) (*it), - (uint64_t) this); + (quint64) (*it), + (quint64) this); m_sinkBuddies.erase(it); return; } } - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", + qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSinkAPI::clearBuddiesLists() diff --git a/sdrbase/device/devicesourceapi.cpp b/sdrbase/device/devicesourceapi.cpp index c6e3563d7..972c20f34 100644 --- a/sdrbase/device/devicesourceapi.cpp +++ b/sdrbase/device/devicesourceapi.cpp @@ -323,22 +323,22 @@ void DeviceSourceAPI::addSourceBuddy(DeviceSourceAPI* buddy) { m_sourceBuddies.push_back(buddy); buddy->m_sourceBuddies.push_back(this); - qDebug("DeviceSourceAPI::addSourceBuddy: added buddy %s(%s) [%lx] <-> [%lx]", + qDebug("DeviceSourceAPI::addSourceBuddy: added buddy %s(%s) [%llu] <-> [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSourceAPI::addSinkBuddy(DeviceSinkAPI* buddy) { m_sinkBuddies.push_back(buddy); buddy->m_sourceBuddies.push_back(this); - qDebug("DeviceSourceAPI::addSinkBuddy: added buddy %s(%s) [%lx] <-> [%lx]", + qDebug("DeviceSourceAPI::addSinkBuddy: added buddy %s(%s) [%llu] <-> [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSourceAPI::removeSourceBuddy(DeviceSourceAPI* buddy) @@ -349,21 +349,21 @@ void DeviceSourceAPI::removeSourceBuddy(DeviceSourceAPI* buddy) { if (*it == buddy) { - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", + qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) (*it), - (uint64_t) this); + (quint64) (*it), + (quint64) this); m_sourceBuddies.erase(it); return; } } - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", + qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSourceSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSourceAPI::removeSinkBuddy(DeviceSinkAPI* buddy) @@ -374,21 +374,21 @@ void DeviceSourceAPI::removeSinkBuddy(DeviceSinkAPI* buddy) { if (*it == buddy) { - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", + qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) (*it), - (uint64_t) this); + (quint64) (*it), + (quint64) this); m_sinkBuddies.erase(it); return; } } - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", + qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", qPrintable(buddy->getHardwareId()), qPrintable(buddy->getSampleSinkSerial()), - (uint64_t) buddy, - (uint64_t) this); + (quint64) buddy, + (quint64) this); } void DeviceSourceAPI::clearBuddiesLists() From 2f035dd398592327d406467d351898ce954b0594 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 13:54:16 +0200 Subject: [PATCH 10/15] codec2: fix pkgconfig name codec2 install pkgconfig without lib prefix as stated by source code on debian /usr/lib/x86_64-linux-gnu/pkgconfig/codec2.pc on macports /opt/local/lib/pkgconfig/codec2.pc --- cmake/Modules/FindCodec2.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindCodec2.cmake b/cmake/Modules/FindCodec2.cmake index 972b8c8c3..8e31a0764 100644 --- a/cmake/Modules/FindCodec2.cmake +++ b/cmake/Modules/FindCodec2.cmake @@ -1,5 +1,5 @@ INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_CODEC2 "libcodec2") +PKG_CHECK_MODULES(PC_CODEC2 "codec2") FIND_PATH(CODEC2_INCLUDE_DIR NAMES codec2/codec2.h From 770be1ddfb22b38eb6f3b5c31f557a03e89ea4b3 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 16:11:21 +0200 Subject: [PATCH 11/15] fix apple compatibility library should permit to build sdrangel also with macOS <10.12 --- apple/apple_compat.c | 5 +++-- qrtplib/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apple/apple_compat.c b/apple/apple_compat.c index 0fca664b7..c8775a1d7 100644 --- a/apple/apple_compat.c +++ b/apple/apple_compat.c @@ -57,10 +57,10 @@ int pthread_barrier_wait(pthread_barrier_t *barrier) } } +#ifdef _DARWIN_FEATURE_CLOCK_GETTIME /** * Missing POSIX RealTime/Monotonic Clock */ -/* #include int clock_gettime(int clk_id, struct timespec *t) { @@ -74,5 +74,6 @@ int clock_gettime(int clk_id, struct timespec *t) { t->tv_nsec = nseconds; return 0; } -*/ +#endif + #endif // APPLE Compatibility diff --git a/qrtplib/CMakeLists.txt b/qrtplib/CMakeLists.txt index f194ca43b..c024abf5a 100644 --- a/qrtplib/CMakeLists.txt +++ b/qrtplib/CMakeLists.txt @@ -3,6 +3,7 @@ project(qrtplib) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set (qrtplib_HEADERS + ../apple/apple_compat.h rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h @@ -45,6 +46,7 @@ set (qrtplib_HEADERS ) set(qrtplib_SOURCES + ../apple/apple_compat.c rtcpapppacket.cpp rtcpbyepacket.cpp rtcpcompoundpacket.cpp From 9b1c24ee3db5d5833df880e4a241801adef53a5e Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 16:17:36 +0200 Subject: [PATCH 12/15] plutosdr device: fix warning warning: format specifies type 'long' but the argument has type 'int64_t' (aka 'long long') [-Wformat] --- devices/plutosdr/deviceplutosdrbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devices/plutosdr/deviceplutosdrbox.cpp b/devices/plutosdr/deviceplutosdrbox.cpp index fd7c8c442..6bcc9b359 100644 --- a/devices/plutosdr/deviceplutosdrbox.cpp +++ b/devices/plutosdr/deviceplutosdrbox.cpp @@ -658,8 +658,8 @@ void DevicePlutoSDRBox::getXO() get_param(DEVICE_PHY, "xo_correction", valueStr); try { - m_xoInitial = boost::lexical_cast(valueStr); - qDebug("DevicePlutoSDRBox::getXO: %ld", m_xoInitial); + m_xoInitial = boost::lexical_cast(valueStr); + qDebug("DevicePlutoSDRBox::getXO: %llu", m_xoInitial); } catch (const boost::bad_lexical_cast &e) { From f7612a703d5a7602b3f64b3cc3aee2ec74cf1c8c Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Mon, 15 Apr 2019 21:43:48 +0200 Subject: [PATCH 13/15] generalize architecture and cpu flags detection --- CMakeLists.txt | 262 ++++++++++++++++++++++++--------- cmake/test/test_arm_neon.cxx | 9 ++ cmake/test/test_x86_avx.cxx | 7 + cmake/test/test_x86_avx2.cxx | 7 + cmake/test/test_x86_avx512.cxx | 8 + cmake/test/test_x86_sse2.cxx | 7 + cmake/test/test_x86_sse3.cxx | 8 + cmake/test/test_x86_sse41.cxx | 10 ++ cmake/test/test_x86_sse42.cxx | 7 + cmake/test/test_x86_ssse3.cxx | 8 + 10 files changed, 261 insertions(+), 72 deletions(-) create mode 100644 cmake/test/test_arm_neon.cxx create mode 100644 cmake/test/test_x86_avx.cxx create mode 100644 cmake/test/test_x86_avx2.cxx create mode 100644 cmake/test/test_x86_avx512.cxx create mode 100644 cmake/test/test_x86_sse2.cxx create mode 100644 cmake/test/test_x86_sse3.cxx create mode 100644 cmake/test/test_x86_sse41.cxx create mode 100644 cmake/test/test_x86_sse42.cxx create mode 100644 cmake/test/test_x86_ssse3.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index a63e489d2..69f0e30f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,93 +108,211 @@ if (HOST_RPI) message( STATUS "Compiling on RPi" ) endif() -EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE ) -message( STATUS "Architecture: ${ARCHITECTURE}" ) -if (${ARCHITECTURE} MATCHES "x86_64|AMD64|x86") - EXECUTE_PROCESS( COMMAND grep flags /proc/cpuinfo OUTPUT_VARIABLE CPU_FLAGS ) -# if (${CPU_FLAGS} MATCHES "avx2") -# set(HAS_AVX2 ON CACHE BOOL "Architecture has AVX2 SIMD enabled") -# if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) -# set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx2" ) -# set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx2" ) -# message(STATUS "Use AVX2 SIMD instructions") -# add_definitions(-DUSE_AVX2) -# else() -# set(HAS_AVX2 OFF CACHE BOOL "Architecture does not have AVX2 SIMD enabled") -# endif() -# endif() - if (${CPU_FLAGS} MATCHES "sse4_1") - set(HAS_SSE4_1 ON CACHE BOOL "Architecture has SSE 4.1 SIMD enabled") - if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.1" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.1" ) - message(STATUS "Use SSE 4.1 SIMD instructions") - add_definitions(-DUSE_SSE4_1) - elseif(MSVC) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_1" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_1" ) - set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) - add_definitions (/D "_CRT_SECURE_NO_WARNINGS") - add_definitions(-DUSE_SSE4_1) +set(TEST_DIR ${PROJECT_SOURCE_DIR}/cmake/test) + +# Clang or AppleClang (see CMP0025) +if(NOT DEFINED C_CLANG AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(C_CLANG 1) +endif() +if(NOT DEFINED C_GCC AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set(C_GCC 1) +endif() + +# Detect current compilation architecture and create standard definitions +# ======================================================================= +include(CheckSymbolExists) +function(detect_architecture symbol arch) + if (NOT DEFINED ARCHITECTURE) + set(CMAKE_REQUIRED_QUIET 1) + check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch}) + unset(CMAKE_REQUIRED_QUIET) + + # The output variable needs to be unique across invocations otherwise + # CMake's crazy scope rules will keep it defined + if (ARCHITECTURE_${arch}) + set(ARCHITECTURE "${arch}" PARENT_SCOPE) + set(ARCHITECTURE_${arch} 1 PARENT_SCOPE) + add_definitions(-DARCHITECTURE_${arch}=1) endif() - else() - set(HAS_SSE4_1 OFF CACHE BOOL "Architecture does not have SSE 4.1 SIMD enabled") endif() - if (${CPU_FLAGS} MATCHES "ssse3") - set(HAS_SSSE3 ON CACHE BOOL "Architecture has SSSE3 SIMD enabled") - if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mssse3" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mssse3" ) +endfunction() + +if (NOT ENABLE_GENERIC) + if (MSVC) + detect_architecture("_M_AMD64" x86_64) + detect_architecture("_M_IX86" x86) + detect_architecture("_M_ARM" ARM) + detect_architecture("_M_ARM64" ARM64) + else() + detect_architecture("__x86_64__" x86_64) + detect_architecture("__i386__" x86) + detect_architecture("__arm__" ARM) + detect_architecture("__aarch64__" ARM64) + endif() +endif() +if (NOT DEFINED ARCHITECTURE) + set(ARCHITECTURE "GENERIC") + set(ARCHITECTURE_GENERIC 1) + add_definitions(-DARCHITECTURE_GENERIC=1) +endif() +message(STATUS "Target architecture: ${ARCHITECTURE}") + +# flag that set the minimum cpu flag requirements +# used to create re-distribuitable binary +if (ENABLE_DISTRIBUTION) + if (${ARCHITECTURE} MATCHES "x86_64|x86") + set(HAS_SSSE3 ON CACHE BOOL "SSSE3 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3" ) message(STATUS "Use SSSE3 SIMD instructions") add_definitions(-DUSE_SSSE3) elseif(MSVC) set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSSE3" ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSSE3" ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) + message(STATUS "Use MSVC SSSE3 SIMD instructions") add_definitions (/D "_CRT_SECURE_NO_WARNINGS") add_definitions(-DUSE_SSSE3) endif() - else() - set(HAS_SSSE3 OFF CACHE BOOL "Architecture does not have SSSE3 SIMD enabled") - endif() - if (${CPU_FLAGS} MATCHES "sse2") - set(HAS_SSE2 ON CACHE BOOL "Architecture has SSE2 SIMD enabled") - if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" ) - message(STATUS "Use SSE2 SIMD instructions") - add_definitions(-DUSE_SSE2) - 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_SSE2) - endif() - else() - set(HAS_SSE2 OFF CACHE BOOL "Architecture does not have SSE2 SIMD enabled") - endif() -elseif (${ARCHITECTURE} MATCHES "armv7l") - EXECUTE_PROCESS( COMMAND grep Features /proc/cpuinfo OUTPUT_VARIABLE CPU_FLAGS ) - if (${CPU_FLAGS} MATCHES "neon") - set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled") - if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon" ) - message(STATUS "Use NEON SIMD instructions") - add_definitions(-DUSE_NEON) - endif() - else() - set(HAS_NEON OFF CACHE BOOL "Architecture does not have NEON SIMD enabled") - endif() -elseif (${ARCHITECTURE} MATCHES "aarch64") - set(HAS_NEON ON CACHE BOOL FORCE "Architecture has NEON SIMD enabled") - if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) - message(STATUS "Aarch64 always has NEON SIMD instructions") + elseif (${ARCHITECTURE} MATCHES "ARM|ARM64") + set(HAS_NEON ON CACHE BOOL "NEON SIMD enabled") + message(STATUS "Use NEON SIMD instructions") add_definitions(-DUSE_NEON) endif() +else () +if (${ARCHITECTURE} MATCHES "x86_64|x86") + try_run(RUN_SSE2 COMPILE_SSE2 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_sse2.cxx COMPILE_DEFINITIONS -msse2 -O0) + if(COMPILE_SSE2 AND RUN_SSE2 EQUAL 0) + set(HAS_SSE2 ON CACHE BOOL "Architecture has SSSE2 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2" ) + message(STATUS "Use SSE2 SIMD instructions") + add_definitions(-DUSE_SSE2) + 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_SSE2) + endif() + else() + set(HAS_SSE2 OFF CACHE BOOL "Architecture does not have SSSE2 SIMD enabled") + endif() + try_run(RUN_SSSE3 COMPILE_SSSE3 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_ssse3.cxx COMPILE_DEFINITIONS -mssse3 -O0) + if(COMPILE_SSSE3 AND RUN_SSSE3 EQUAL 0) + set(HAS_SSSE3 ON CACHE BOOL "Architecture has SSSE3 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3" ) + message(STATUS "Use SSSE3 SIMD instructions") + add_definitions(-DUSE_SSSE3) + elseif(MSVC) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSSE3" ) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSSE3" ) + set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) + message(STATUS "Use MSVC SSSE3 SIMD instructions") + add_definitions (/D "_CRT_SECURE_NO_WARNINGS") + add_definitions(-DUSE_SSSE3) + endif() + else() + set(HAS_SSSE3 OFF CACHE BOOL "Architecture does not have SSSE3 SIMD enabled") + endif() + try_run(RUN_SSE4_1 COMPILE_SSE4_1 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_sse41.cxx COMPILE_DEFINITIONS -msse4.1 -O0) + if(COMPILE_SSE4_1 AND RUN_SSE4_1 EQUAL 0) + set(HAS_SSE4_1 ON CACHE BOOL "Architecture has SSE 4.1 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.1" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.1" ) + message(STATUS "Use SSE 4.1 SIMD instructions") + add_definitions(-DUSE_SSE4_1) + elseif(MSVC) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_1" ) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_1" ) + set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) + add_definitions (/D "_CRT_SECURE_NO_WARNINGS") + add_definitions(-DUSE_SSE4_1) + endif() + else() + set(HAS_SSE4_1 OFF CACHE BOOL "Architecture does not have SSE 4.1 SIMD enabled") + endif() + try_run(RUN_SSE4_2 COMPILE_SSE4_2 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_sse42.cxx COMPILE_DEFINITIONS -msse4.2 -O0) + if(COMPILE_SSE4_2 AND RUN_SSE4_2 EQUAL 0) + set(HAS_SSE4_2 ON CACHE BOOL "Architecture has SSE 4.2 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.2" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.2" ) + message(STATUS "Use SSE 4.2 SIMD instructions") + add_definitions(-DUSE_SSE4_2) + elseif(MSVC) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_2" ) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_2" ) + set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" ) + add_definitions (/D "_CRT_SECURE_NO_WARNINGS") + add_definitions(-DUSE_SSE4_2) + endif() + else() + set(HAS_SSE4_2 OFF CACHE BOOL "Architecture does not have SSE 4.2 SIMD enabled") + endif() + try_run(RUN_AVX COMPILE_AVX ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_avx.cxx COMPILE_DEFINITIONS -mavx -O0) + if(COMPILE_AVX AND RUN_AVX EQUAL 0) + set(HAS_AVX ON CACHE BOOL "Architecture has AVX SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx" ) + message(STATUS "Use AVX SIMD instructions") + add_definitions(-DUSE_AVX) + endif() + else() + set(HAS_AVX OFF CACHE BOOL "Architecture does not have AVX SIMD enabled") + endif() + try_run(RUN_AVX2 COMPILE_AVX2 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_avx2.cxx COMPILE_DEFINITIONS -mavx2 -O0) + if(COMPILE_AVX2 AND RUN_AVX2 EQUAL 0) + set(HAS_AVX2 ON CACHE BOOL "Architecture has AVX2 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx2" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx2" ) + message(STATUS "Use AVX2 SIMD instructions") + add_definitions(-DUSE_AVX2) + endif() + else() + set(HAS_AVX2 OFF CACHE BOOL "Architecture does not have AVX2 SIMD enabled") + endif() + try_run(RUN_AVX512 COMPILE_AVX512 ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_x86_avx512.cxx COMPILE_DEFINITIONS -mavx512f -O0) + if(COMPILE_AVX512 AND RUN_AVX512 EQUAL 0) + set(HAS_AVX512 ON CACHE BOOL "Architecture has AVX512 SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx512f" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx512f" ) + message(STATUS "Use AVX512 SIMD instructions") + add_definitions(-DUSE_AVX512) + endif() + else() + set(HAS_AVX512 OFF CACHE BOOL "Architecture does not have AVX512 SIMD enabled") + endif() +elseif(ARCHITECTURE_ARM) + try_run(RUN_NEON COMPILE_NEON ${CMAKE_BINARY_DIR}/tmp ${TEST_DIR}/test_arm_neon.cxx COMPILE_DEFINITIONS -mfpu=neon -O0) + if(COMPILE_NEON AND RUN_NEON EQUAL 0) + set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled") + if(C_GCC OR C_CLANG) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon" ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon" ) + message(STATUS "Use NEON SIMD instructions") + add_definitions(-DUSE_NEON) + endif() + else() + set(HAS_NEON OFF CACHE BOOL "Architecture does not have NEON SIMD enabled") + endif() +elseif(ARCHITECTURE_ARM64) + # Advanced SIMD (aka NEON) is mandatory for AArch64 + set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled") + message(STATUS "Use NEON SIMD instructions") + add_definitions(-DUSE_NEON) endif() +endif() + +# clear binary test folder +FILE(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/tmp) +############################################################################## # Compiler flags. if (RX_SAMPLE_24BIT) diff --git a/cmake/test/test_arm_neon.cxx b/cmake/test/test_arm_neon.cxx new file mode 100644 index 000000000..d80ecedfa --- /dev/null +++ b/cmake/test/test_arm_neon.cxx @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + uint32x4_t x={0}; + x=veorq_u32(x,x); + return 0; +} diff --git a/cmake/test/test_x86_avx.cxx b/cmake/test/test_x86_avx.cxx new file mode 100644 index 000000000..70990d9c9 --- /dev/null +++ b/cmake/test/test_x86_avx.cxx @@ -0,0 +1,7 @@ +#include +int main(int argc, char* argv[]) +{ + __m256d x = _mm256_setzero_pd(); + x=_mm256_addsub_pd(x,x); + return 0; +} diff --git a/cmake/test/test_x86_avx2.cxx b/cmake/test/test_x86_avx2.cxx new file mode 100644 index 000000000..211003f67 --- /dev/null +++ b/cmake/test/test_x86_avx2.cxx @@ -0,0 +1,7 @@ +#include +int main(int argc, char* argv[]) +{ + __m256i x = _mm256_setzero_si256(); + x=_mm256_add_epi64 (x,x); + return 0; +} diff --git a/cmake/test/test_x86_avx512.cxx b/cmake/test/test_x86_avx512.cxx new file mode 100644 index 000000000..9979179c2 --- /dev/null +++ b/cmake/test/test_x86_avx512.cxx @@ -0,0 +1,8 @@ +#include +#include +int main(int argc, char* argv[]) +{ + uint64_t x[8] = {0}; + __m512i y = _mm512_loadu_si512((__m512i*)x); + return 0; +} diff --git a/cmake/test/test_x86_sse2.cxx b/cmake/test/test_x86_sse2.cxx new file mode 100644 index 000000000..ed5c74fc8 --- /dev/null +++ b/cmake/test/test_x86_sse2.cxx @@ -0,0 +1,7 @@ +#include +int main(int argc, char* argv[]) +{ + __m128i x = _mm_setzero_si128(); + x=_mm_add_epi64(x,x); + return 0; +} diff --git a/cmake/test/test_x86_sse3.cxx b/cmake/test/test_x86_sse3.cxx new file mode 100644 index 000000000..90b39d87a --- /dev/null +++ b/cmake/test/test_x86_sse3.cxx @@ -0,0 +1,8 @@ +#include +#include +int main(int argc, char* argv[]) +{ + __m128d x = _mm_setzero_pd(); + x=_mm_addsub_pd(x,x); + return 0; +} diff --git a/cmake/test/test_x86_sse41.cxx b/cmake/test/test_x86_sse41.cxx new file mode 100644 index 000000000..29cb37ed5 --- /dev/null +++ b/cmake/test/test_x86_sse41.cxx @@ -0,0 +1,10 @@ +#include +#include +int main(int argc, char* argv[]) +{ + __m128i x = _mm_setzero_si128(); + __m128i a = _mm_setzero_si128(); + __m128i b = _mm_setzero_si128(); + x=_mm_blend_epi16(a,b,4); + return 0; +} diff --git a/cmake/test/test_x86_sse42.cxx b/cmake/test/test_x86_sse42.cxx new file mode 100644 index 000000000..1ba74eb24 --- /dev/null +++ b/cmake/test/test_x86_sse42.cxx @@ -0,0 +1,7 @@ +#include +int main(int argc, char* argv[]) +{ + unsigned int x=32; + x=_mm_crc32_u8(x,4); + return 0; +} diff --git a/cmake/test/test_x86_ssse3.cxx b/cmake/test/test_x86_ssse3.cxx new file mode 100644 index 000000000..83ed77f5e --- /dev/null +++ b/cmake/test/test_x86_ssse3.cxx @@ -0,0 +1,8 @@ +#include +#include +int main(int argc, char* argv[]) +{ + __m128i x = _mm_setzero_si128(); + x=_mm_alignr_epi8(x,x,2); + return 0; +} From 07c1413c95338fd36df2ab82e8b420140db6d94d Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Tue, 16 Apr 2019 14:52:08 +0200 Subject: [PATCH 14/15] install udev-rules only on linux --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69f0e30f4..b2708e400 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -535,11 +535,13 @@ install(TARGETS sdrangelbench DESTINATION bin) #install(TARGETS sdrbase DESTINATION lib) #install files and directories +if (CMAKE_SYSTEM_NAME EQUAL "Linux") install(DIRECTORY udev-rules DESTINATION share/sdrangel) install(FILES udev-rules/install.sh DESTINATION share/sdrangel/udev-rules PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sdrbase.rcc DESTINATION bin) install(FILES desktop/sdrangel.desktop DESTINATION share/applications) install(FILES desktop/sdrangel_icon.png DESTINATION share/pixmaps) +endif() ############################################################################## From 0182364143d778a0c4123b6c8c5f7319ddcfc20e Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Thu, 18 Apr 2019 16:45:43 +0200 Subject: [PATCH 15/15] libopus-dev is needed on ubuntu/debian --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 0ea9c4dc6..ffea64778 100644 --- a/Readme.md +++ b/Readme.md @@ -89,11 +89,11 @@ To be sure you will need at least Qt version 5.5. It definitely does not work wi

Ubuntu

- - `sudo apt-get install cmake g++ pkg-config libfftw3-dev libqt5multimedia5-plugins qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtbase5-dev libusb-1.0 librtlsdr-dev libboost-all-dev libasound2-dev pulseaudio libopencv-dev libsqlite3-dev libxml2-dev bison flex ffmpeg libavcodec-dev libavformat-dev` + - `sudo apt-get install cmake g++ pkg-config libfftw3-dev libqt5multimedia5-plugins qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtbase5-dev libusb-1.0 librtlsdr-dev libboost-all-dev libasound2-dev pulseaudio libopencv-dev libsqlite3-dev libxml2-dev bison flex ffmpeg libavcodec-dev libavformat-dev libopus-dev`

Debian

- - `sudo apt-get install cmake g++ pkg-config libfftw3-dev libusb-1.0-0-dev libusb-dev qt5-default qtbase5-dev qtchooser libqt5multimedia5-plugins qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtbase5-dev librtlsdr-dev libboost-all-dev libasound2-dev pulseaudio libopencv-dev libsqlite3-dev libxml2-dev bison flex ffmpeg libavcodec-dev libavformat-dev` + - `sudo apt-get install cmake g++ pkg-config libfftw3-dev libusb-1.0-0-dev libusb-dev qt5-default qtbase5-dev qtchooser libqt5multimedia5-plugins qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtbase5-dev librtlsdr-dev libboost-all-dev libasound2-dev pulseaudio libopencv-dev libsqlite3-dev libxml2-dev bison flex ffmpeg libavcodec-dev libavformat-dev libopus-dev`

openSUSE