diff --git a/.github/workflows/x86-windows.yml b/.github/workflows/x86-windows.yml
index 095e427..6b14946 100644
--- a/.github/workflows/x86-windows.yml
+++ b/.github/workflows/x86-windows.yml
@@ -35,6 +35,10 @@ jobs:
with:
submodules: recursive
+ - uses: ilammy/msvc-dev-cmd@v1
+ with:
+ arch: x64
+
- name: Setup vcpkg with caching
uses: friendlyanon/setup-vcpkg@v1
with:
@@ -42,16 +46,18 @@ jobs:
path: vcpkg
- name: Configure CMake
- run: cmake -B ${{github.workspace}}/build-windows -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE:STRING=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -A"x64" -G"Visual Studio 17 2022"
+ shell: bash
+ run: VCPKG_ROOT=./vcpkg ./toolchains/windows/cmake_configure.sh
- name: Build
- run: cmake --build ${{github.workspace}}/build-windows --config ${{env.BUILD_TYPE}}
+ shell: bash
+ run: ninja -C build-windows
- - name: Copy files (Release)
+ - name: Copy files
shell: bash
run: ./toolchains/windows/create_package.sh
- - name: Upload files (Release)
+ - name: Upload files
uses: actions/upload-artifact@v3
with:
name: dab_radio_windows_x64
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ea4330..57d0b9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ find_package(implot REQUIRED)
set(viterbi_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/viterbi_decoder)
find_package(viterbi CONFIG REQUIRED)
-if(DEFINED WIN32)
+if(WIN32)
set(rtlsdr_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/librtlsdr)
find_package(rtlsdr CONFIG REQUIRED)
set(RTLSDR_LIBS rtlsdr::rtlsdr)
@@ -23,7 +23,7 @@ else()
set(RTLSDR_LIBS PkgConfig::rtlsdr)
endif()
-if(MSVC)
+if(WIN32)
find_package(portaudio CONFIG REQUIRED)
find_package(FFTW3f CONFIG REQUIRED)
set(PORTAUDIO_LIBS portaudio)
@@ -39,7 +39,7 @@ endif()
target_compile_definitions(easyloggingpp PRIVATE ELPP_THREAD_SAFE)
# for posix threads
-if(NOT DEFINED WIN32)
+if(NOT WIN32)
find_package(Threads REQUIRED)
add_compile_options(-pthread)
link_libraries(Threads::Threads)
@@ -47,7 +47,7 @@ endif()
# simd and math compile options
if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
- if(DEFINED MSVC)
+ if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING)
# for msvc multi processor compilation
diff --git a/src/ofdm/dsp/apply_pll.cpp b/src/ofdm/dsp/apply_pll.cpp
index ad534c6..81b9bcf 100644
--- a/src/ofdm/dsp/apply_pll.cpp
+++ b/src/ofdm/dsp/apply_pll.cpp
@@ -50,9 +50,13 @@ void create_dt_step_simd(float* arr, const size_t K, const float dt) {
}
}
+#if defined(_MSC_VER) && !defined(__clang__)
+#define IS_INTEL_SVML 1
+#endif
+
#if defined(__SSE3__)
-#if !defined(_MSC_VER)
+#if !IS_INTEL_SVML
#define USE_SSE_AUTO
#define SSE_MATHFUN_WITH_CODE
#include "./x86/sse_mathfun.h"
@@ -104,7 +108,7 @@ float apply_pll_sse3(
#if defined(__AVX__)
-#if !defined(_MSC_VER)
+#if !IS_INTEL_SVML
#include "./x86/avx_mathfun.h"
#define _mm256_cos_ps(x) cos256_ps(x)
#endif
diff --git a/src/ofdm/dsp/x86/sse_mathfun.h b/src/ofdm/dsp/x86/sse_mathfun.h
index 32c82b0..3b7e5c7 100644
--- a/src/ofdm/dsp/x86/sse_mathfun.h
+++ b/src/ofdm/dsp/x86/sse_mathfun.h
@@ -200,8 +200,8 @@ _PS_CONST(cephes_log_q2, 0.693359375);
// _PD_CONST_TYPE(mant_mask, int, 0x7f800000);
// _PD_CONST_TYPE(inv_mant_mask, int, ~0x7f800000);
- _PD_CONST_TYPE(sign_mask, uint64_t, 0x8000000000000000LL);
- _PD_CONST_TYPE(inv_sign_mask, uint64_t, ~0x8000000000000000LL);
+ _PD_CONST_TYPE(sign_mask, uint64_t, 0x8000000000000000ULL);
+ _PD_CONST_TYPE(inv_sign_mask, uint64_t, ~0x8000000000000000ULL);
#endif
@@ -1307,18 +1307,18 @@ static inline double scalCumSumSumSq( double *xa, int n, double *sumSQ )
# if defined(__x86_64__) || defined(x86_64) || defined(_LP64)
// static inline v2df _mm_abs_pd( v2df a )
-// { _PD_CONST_TYPE(abs_mask, uint64_t, ~0x8000000000000000LL);
+// { _PD_CONST_TYPE(abs_mask, uint64_t, ~0x8000000000000000ULL);
// return _mm_and_pd(a, *(v2df*)_pd_abs_mask);
// }
/*!
SSE2 'intrinsic' to take the absolute value of a
*/
static inline v2df _mm_abs_pd( v2df a )
- { const static uint64_t am1[2] = {~0x8000000000000000LL,~0x8000000000000000LL};
+ { const static uint64_t am1[2] = {~0x8000000000000000ULL,~0x8000000000000000ULL};
return _mm_and_pd(a, *((v2df*)am1) );
}
static inline double _mm_abs_sd( double a )
- { const static uint64_t am2 = {~0x8000000000000000LL};
+ { const static uint64_t am2 = {~0x8000000000000000ULL};
v2si r = _mm_and_si64( *((v2si*)&a), *((v2si*)&am2) );
return *((double*) &r);
}
diff --git a/toolchains/windows/README.md b/toolchains/windows/README.md
index 7638343..286088e 100644
--- a/toolchains/windows/README.md
+++ b/toolchains/windows/README.md
@@ -1,4 +1,19 @@
## Instructions
-1. ./toolchains/windows/cmake_configure.bat
-2. ./toolchains/windows/build.bat
-3. ./build-windows/\
+1. ```./toolchains/windows/cmake_configure.sh```
+2. ```ninja -C build-windows```
+3. ```./build-windows/\```
+
+## Compiling with clang-cl
+Compiling with clang gives better performing binaries compared to MSVC cl.
+
+1. Setup x64 developer environment for C++ for MSVC.
+2. Make sure clang for C++ is installed through Visual Studio.
+3. Enter a bash shell.
+4. ```CC=clang CXX=clang++ ./toolchains/windows/cmake_configure.sh```
+
+## Compiling with different SIMD flags
+The default windows build compiles with AVX2 instructions. If your CPU doesn't support these then you will have to modify the scripts.
+
+```vcpkg.json``` contains ```fftw3f``` which uses the ```avx2``` feature. Change this to ```[avx, sse2, sse]```.
+
+```CMakeLists.txt``` contains ```/arch:AVX2```. Change this to ```/arch:AVX``` or remove this compiler option.
diff --git a/toolchains/windows/build.bat b/toolchains/windows/build.bat
deleted file mode 100644
index 099f692..0000000
--- a/toolchains/windows/build.bat
+++ /dev/null
@@ -1,50 +0,0 @@
-@echo off
-
-set PROJ_PATH="%2"
-if "%~2" == "" set PROJ_PATH="build-windows\ALL_BUILD.vcxproj"
-
-set BUILD_REF="true"
-if "%3" == "--ignore-ref" set BUILD_REF="false"
-
-set ARGS=^
- /p:CL_MPCOUNT=%NUMBER_OF_PROCESSORS%^
- /m:%NUMBER_OF_PROCESSORS%^
- /p:BuildProjectReferences=%BUILD_REF%^
- /v:minimal^
- /nologo
-
-if /I "%1" == "" (
- set BUILD_TYPE="Release"
- goto BUILD
-)
-if /I "%1" == "release" (
- set BUILD_TYPE="Release"
- goto BUILD
-)
-if /I "%1" == "debug" (
- set BUILD_TYPE="Debug"
- goto BUILD
-)
-if /I "%1" == "reldeb" (
- set BUILD_TYPE="RelWithDebInfo"
- goto BUILD
-)
-if /I "%1" == "minsize" (
- set BUILD_TYPE="MinSizeRel"
- goto BUILD
-)
-goto ERROR
-
-
-:BUILD
-@echo on
-call msbuild /p:Configuration=%BUILD_TYPE% %PROJ_PATH% %ARGS%
-@echo off
-goto EXIT
-
-
-:ERROR
-echo Invalid build type: "%1"
-goto EXIT
-
-:EXIT
diff --git a/toolchains/windows/cmake_configure.bat b/toolchains/windows/cmake_configure.bat
deleted file mode 100644
index 3da00c4..0000000
--- a/toolchains/windows/cmake_configure.bat
+++ /dev/null
@@ -1,17 +0,0 @@
-@echo off
-
-set BUILD_TYPE="Release"
-set TOOLCHAIN_FILE="C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake"
-set BUILD_OUT="build-windows"
-set BUILD_GENERATOR="Visual Studio 17 2022"
-set ARCHITECTURE="x64"
-
-@echo on
-
-call cmake^
- -B %BUILD_OUT%^
- -DCMAKE_BUILD_TYPE:STRING=%BUILD_TYPE%^
- -DCMAKE_TOOLCHAIN_FILE:STRING=%TOOLCHAIN_FILE%^
- -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE^
- -G %BUILD_GENERATOR%^
- -A %ARCHITECTURE%
diff --git a/toolchains/windows/cmake_configure.sh b/toolchains/windows/cmake_configure.sh
new file mode 100755
index 0000000..4248005
--- /dev/null
+++ b/toolchains/windows/cmake_configure.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+if [[ -z "$VCPKG_ROOT" ]]; then
+ TOOLCHAIN_FILE="C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake"
+else
+ TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
+fi
+
+if [[ -z "$BUILD_OUT" ]]; then
+ BUILD_OUT="build-windows"
+fi
+
+if [[ -z "$BUILD_TYPE" ]]; then
+ BUILD_TYPE="Release"
+fi
+
+cmake .\
+ -B $BUILD_OUT\
+ -G Ninja\
+ -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE\
+ -DCMAKE_TOOLCHAIN_FILE:STRING=$TOOLCHAIN_FILE\
+ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE