Skip to content

Commit

Permalink
Updated build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamyang98 committed Feb 19, 2024
1 parent aaa4849 commit 08002d1
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/x86-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
sudo cmake --build build --config ${{env.BUILD_TYPE}} --target install
- name: Configure CMake
run: cmake . -B ${{github.workspace}}/${{env.BUILD_DIR}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_TARGET}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja
run: cmake . -B ${{github.workspace}}/${{env.BUILD_DIR}} --preset clang -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_TARGET}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --target dab_plugin
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/x86-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
./toolchains/ubuntu/install_packages.sh
- name: Configure CMake
run: cmake . -B ${{github.workspace}}/${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja
run: cmake . -B ${{github.workspace}}/${{env.BUILD_DIR}} --preset gcc -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/${{env.BUILD_DIR}} --target dab_plugin
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/x86-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
if: needs.skip_check.outputs.should_skip != 'true'

runs-on: windows-2022
strategy:
matrix:
architecture: ["sse2", "avx2" ]

steps:
- uses: actions/checkout@v3
Expand All @@ -51,7 +54,7 @@ jobs:
run: python -m pip install mako

- name: Configure CMake
run: cmake -B ${{github.workspace}}/${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE:STRING=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -G Ninja
run: cmake -B ${{github.workspace}}/${{env.BUILD_DIR}} --preset windows-msvc-${{matrix.architecture}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE:STRING=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake

- name: Build
run: cmake --build ${{github.workspace}}/${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} --target dab_plugin
Expand All @@ -66,5 +69,5 @@ jobs:
- name: Upload files (Release)
uses: actions/upload-artifact@v3
with:
name: sdrpp_dab_radio_plugin_windows
name: sdrpp_dab_radio_plugin_windows_${{matrix.architecture}}
path: ${{github.workspace}}/${{env.PACKAGE_DIR}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ build-*/
.cache/
plugin_package/
plugin_package.zip
venv/
venv/
CMakeUserPresets.json
22 changes: 0 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,3 @@ add_subdirectory(${DAB_RADIO_DIR}/src/basic_radio)
# build dab plugin
find_package(audio_mixer REQUIRED)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)

# simd and math compile options
function(set_simd_options target)
if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
if(DEFINED MSVC)
# NOTE: If your CPU doesn't support these instructions, modify /arch:?
target_compile_options(${target} PRIVATE /fp:fast /arch:AVX2)
else()
# NOTE: We are optimising specifically for your CPU's microarchitecture
# This is okay since we don't ship prebuilt binaries for linux distributions
target_compile_options(${target} PRIVATE -march=native -ffast-math)
endif()
else()
target_compile_options(${target} PRIVATE -ffast-math)
endif()
endfunction()
set_simd_options(ofdm_core)
set_simd_options(dab_core)
set_simd_options(basic_radio)
set_simd_options(audio_mixer)
set_simd_options(dab_plugin)

70 changes: 70 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "windows-msvc",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_CXX_FLAGS_INIT": "/MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
"CMAKE_C_FLAGS_INIT": "/MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
}
},
{
"name": "windows-msvc-sse2",
"inherits": ["windows-msvc"]
},
{
"name": "windows-msvc-avx",
"inherits": ["windows-msvc"],
"cacheVariables": {
"CMAKE_CXX_FLAGS_INIT": "/arch:AVX /MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
"CMAKE_C_FLAGS_INIT": "/arch:AVX /MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
}
},
{
"name": "windows-msvc-avx2",
"inherits": ["windows-msvc"],
"cacheVariables": {
"CMAKE_CXX_FLAGS_INIT": "/arch:AVX2 /MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING",
"CMAKE_C_FLAGS_INIT": "/arch:AVX2 /MP /fp:fast /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING"
}
},
{
"name": "gcc",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
}
},
{
"name": "clang",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math -march=native",
"CMAKE_C_FLAGS_INIT": "-ffast-math -march=native"
}
},
{
"name": "clang-arm",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_INIT": "-ffast-math",
"CMAKE_C_FLAGS_INIT": "-ffast-math"
}
}
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Download from releases page or build using the instructions below. Make sure you
7. If no sound is present, check the ```Sinks``` tab and make sure that ```DAB Radio``` is set to ```Audio``` and to the correct audio device.
8. You may also copy ```fftw3f.dll``` into the main SDR++ folder since it is compiled with AVX2 which may improve performance. Be sure to backup the original file before replacing it.

Refer to the build instructions if your processor doesn't support AVX2 instructions to compile with SSE2 or AVX instructions.

## Build instructions
Refer to ```toolchains/*/README.md``` for build instructions. The github workflows in ```.github/workflows``` can also be used as a reference for a working build setup.

Expand Down
2 changes: 1 addition & 1 deletion toolchains/macos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Clone the repository recursively so all the submodules are installed.
- Change to volk: ```cd vendor/volk```
- Configure cmake: ```cmake . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja```
- Build and install: ```sudo cmake --build build --config Release --target install```
5. Configure cmake: ```cmake . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja```
5. Configure cmake: ```cmake . -B build --preset clang -DCMAKE_BUILD_TYPE=Release```
6. Build: ```cmake --build build --config Release --target dab_plugin```

## Install files
Expand Down
2 changes: 1 addition & 1 deletion toolchains/ubuntu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Clone the repository recursively so all the submodules are installed.

## Steps
1. Install packages: ```./toolchains/ubuntu/install_packages.sh```.
2. Configure cmake: ```cmake . -B build -DCMAKE_BUILD_TYPE=Release -G Ninja```.
2. Configure cmake: ```cmake . -B build --preset gcc -DCMAKE_BUILD_TYPE=Release```.
3. Build: ```cmake --build build --config Release```.

## Install files
Expand Down
41 changes: 24 additions & 17 deletions toolchains/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,39 @@ Install Visual Studio 2022 with C++ build kit.
### vcpkg package manager
Install vcpkg and integrate install. Refer to instructions [here](https://github.com/microsoft/vcpkg#quick-start-windows)

### Modify CMakeLists.txt and vcpkg.json for SSE2, AVX or AVX2
We are using the MSVC C++ compiler since SDR++ doesn't compile with clang on windows. This requires changing the ```/arch:XXX``` option to use the correct architecture.
Modify [CMakeLists.txt](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/blob/6a4ce5587dd53fcf1ff4d1122c3f74d97798508a/CMakeLists.txt#L76-L77) which is located at the root of the project.
- ```/arch:AVX2```
- ```/arch:AVX```
- Remove the ```/arch:XXX``` flag entirely for SSE2 builds

*(Optional)* FFTW3 is built by default with AVX2 instructions. Modify [vcpkg.json](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/blob/6a4ce5587dd53fcf1ff4d1122c3f74d97798508a/vcpkg.json#L17) so fftw3 uses the correct "features" for your CPU. This might not be necessary since it uses ```cpu_features``` to determine and dispatch calls at runtime.
- ```"features": ["avx"]```
- ```"features": ["sse2"]```
- ```"features": ["sse"]```

## Building plugin
If the vcpkg toolchain file is in a different location modify the ```cmake_configure.sh``` file.

1. Setup Visual Studio C++ **CMD** development environment. Can be found under ```Visual Studio 20XX``` in start menu.
2. Create python virtual environment: ```python -m venv venv```
3. Activate python virtual environment: ```.\venv\Scripts\activate.bat```
4. Install mako: ```pip install mako```
5. Configure cmake: ```cmake . -B build-windows -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystem\vcpkg.cmake```
5. Configure cmake: ```cmake . -B build --preset windows-msvc -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystem\vcpkg.cmake```
- Adjust ```-DCMAKE_TOOLCHAIN_FILE``` to point to your vcpkg installation directory.
6. Build plugin: ```cmake --build build-windows --config Release --target dab_plugin```
- Use ```--preset windows-msvc-*``` instead to change compile flags for ```[sse2,avx,avx2]``` for better architecture specific optimisations.
6. Build plugin: ```cmake --build build --config Release --target dab_plugin```
7. Copy ```dab_plugin.dll``` from build output directory
- Ninja: ```.\build-windows\src\dab_plugin.dll```
- MsBuild: ```.\build-windows\src\Release\dab_plugin.dll```
8. Copy ```dab_plugin.dll``` to ```SDRPP_INSTALL_LOCATION/modules/dab_plugin.dll```
- Ninja: ```.\build\src\dab_plugin.dll```
- MsBuild: ```.\build\src\Release\dab_plugin.dll```
8. Copy ```dab_plugin.dll``` to ```<SDRPP_INSTALL_LOCATION>/modules/dab_plugin.dll```

## Modifying build
### Compile for SSE2, AVX or AVX2
We are using the MSVC C++ compiler since SDR++ doesn't compile with clang on windows.
- Compile for your architecture using in the configure cmake step (shown below) using the ```--preset windows-msvc-*``` option.
- avx2: ```--preset windows-msvc-avx2```
- avx: ```--preset windows-msvc-avx```
- sse2: ```--preset windows-msvc-sse2```
- You can also modify ```CMakePresets.json``` or create your own ```CMakeUserPresets.json``` with your own compiler options.

*(Optional)* FFTW3 is built by default with AVX2 instructions. Modify [vcpkg.json](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/blob/6a4ce5587dd53fcf1ff4d1122c3f74d97798508a/vcpkg.json#L17) so fftw3 uses the correct "features" for your CPU. This might not be necessary since it uses ```cpu_features``` to determine and dispatch calls at runtime.
- ```"features": ["avx"]```
- ```"features": ["sse2"]```
- ```"features": ["sse"]```

### Use different build generator
You can also modify ```CMakePresets.json``` or create your own ```CMakeUserPresets.json``` with your own ```"generator": ?``` choice if Ninja is not available on your system.
Possible generators can be listed using ```cmake --help```.

## Additional notes
Make sure that the version of SDR++ in ```vendor/sdrplusplus``` is the same as your SDR++ installation. For nightly v1.1.0 builds you might not need to have the exact version but breaking changes between v1.1.0 nightly builds is expected for SDR++.
Expand Down

0 comments on commit 08002d1

Please sign in to comment.