Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and Benchmarks #2

Merged
merged 17 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Bench

on:
pull_request:
branches:
- main
- develop
push:
branches:
- ci

workflow_dispatch:

jobs:
build_and_test:
name: Benchmark library on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
include:
- name: Linux
os: ubuntu-22.04
cmake_args: "-DCMAKE_LINKER_TYPE=MOLD -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15"
nparallel: 4
- name: Windows
os: windows-2022
cmake_args: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
nparallel: 4
- name: MacOS
os: macos-14
cmake_args: ""
nparallel: 4

steps:
- name: Install Linux Deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install libasound2-dev libcurl4-openssl-dev libx11-dev libxinerama-dev libxext-dev libfreetype6-dev libwebkit2gtk-4.0-dev libglu1-mesa-dev libjack-jackd2-dev
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
sudo apt install clang-15 -y

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Get latest CMake
uses: lukka/get-cmake@latest

- uses: rui314/setup-mold@v1
if: runner.os == 'Linux'

- name: Upgrade LLVM
if: runner.os == 'Windows'
run: choco upgrade llvm --version=18.1.8 --allow-downgrade

- name: Add msbuild to PATH
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v2

- name: Setup MSVC devcmd
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Checkout code
uses: actions/checkout@v2

- name: Cmake Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCHOWDSP_FFT_TESTING=ON ${{ matrix.cmake_args }}

- name: Build Benchmarks
run: cmake --build build --config Release --parallel ${{ matrix.nparallel }} --target bench_chowdsp_fft

- name: Run Benchmarks
run: ./build/bench/Release/bench_chowdsp_fft
82 changes: 82 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Coverage

on:
pull_request:
branches:
- main
- develop
push:
branches:
- ci

workflow_dispatch:

jobs:
build_and_test:
name: Test library with coverage
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
include:
- name: Linux
os: ubuntu-22.04
nparallel: 4
# - name: MacOS
# os: macos-14
# nparallel: 4

steps:
- name: Install Linux Deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install libasound2-dev libcurl4-openssl-dev libx11-dev libxinerama-dev libxext-dev libfreetype6-dev libwebkit2gtk-4.0-dev libglu1-mesa-dev libjack-jackd2-dev

- name: Install lcov (Linux)
if: runner.os == 'Linux'
run: sudo apt install lcov

- name: Install lcov (Mac)
if: runner.os == 'MacOS'
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
brew install lcov

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Get latest CMake
uses: lukka/get-cmake@latest

- uses: rui314/setup-mold@v1
if: runner.os == 'Linux'

- name: Checkout code
uses: actions/checkout@v2

- name: Cmake Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCHOWDSP_FFT_TESTING=ON -DCHOWDSP_FFT_COVERAGE=ON

- name: Build Test
run: cmake --build build --config Debug --parallel --target test_chowdsp_fft_cpp

- name: Run Test
run: ./build/test/Debug/test_chowdsp_fft_cpp

- name: Collect Coverage Data
run: |
lcov --version
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '/Applications/Xcode*' '*build*' '*test*' --output-file coverage.info

- name: Report Coverage Data
run: lcov --list coverage.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.info
verbose: true
87 changes: 87 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Test

on:
pull_request:
branches:
- main
- develop
push:
branches:
- ci

workflow_dispatch:

jobs:
build_and_test:
name: Test library on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
include:
- name: Linux
os: ubuntu-22.04
cmake_args: "-DCMAKE_LINKER_TYPE=MOLD -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15"
nparallel: 4
- name: Windows
os: windows-2022
cmake_args: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
nparallel: 4
- name: MacOS
os: macos-14
cmake_args: "-D\"CMAKE_OSX_ARCHITECTURES=arm64;x86_64\""
nparallel: 4

steps:
- name: Install Linux Deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install libasound2-dev libcurl4-openssl-dev libx11-dev libxinerama-dev libxext-dev libfreetype6-dev libwebkit2gtk-4.0-dev libglu1-mesa-dev libjack-jackd2-dev
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
sudo apt install clang-15 -y

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Get latest CMake
uses: lukka/get-cmake@latest

- uses: rui314/setup-mold@v1
if: runner.os == 'Linux'

- name: Upgrade LLVM
if: runner.os == 'Windows'
run: choco upgrade llvm --version=18.1.8 --allow-downgrade

- name: Add msbuild to PATH
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v2

- name: Setup MSVC devcmd
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Checkout code
uses: actions/checkout@v2

- name: Cmake Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCHOWDSP_FFT_TESTING=ON ${{ matrix.cmake_args }}

- name: Build Test C++ (Debug)
run: cmake --build build --config Debug --parallel ${{ matrix.nparallel }} --target test_chowdsp_fft_cpp

- name: Run Test C++ (Debug)
run: ./build/test/Debug/test_chowdsp_fft_cpp

- name: Build Test C (Debug)
run: cmake --build build --config Debug --parallel ${{ matrix.nparallel }} --target test_chowdsp_fft_c

- name: Run Test C (Debug)
run: ./build/test/Debug/test_chowdsp_fft_c

- name: Build Test C++ (Release)
run: cmake --build build --config Release --parallel ${{ matrix.nparallel }} --target test_chowdsp_fft_cpp

- name: Run Test C++ (Release)
run: ./build/test/Release/test_chowdsp_fft_cpp
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build*/

.vscode/
.idea/
19 changes: 12 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.20)
project(chowdsp_fft)

set(CMAKE_CXX_STANDARD 20)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

add_library(chowdsp_fft STATIC)
target_sources(chowdsp_fft
PRIVATE
Expand All @@ -12,34 +9,42 @@ target_sources(chowdsp_fft
)
target_include_directories(chowdsp_fft PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(chowdsp_fft PRIVATE _USE_MATH_DEFINES=1)
target_compile_features(chowdsp_fft PRIVATE cxx_std_17)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("/arch:AVX2" COMPILER_OPT_ARCH_AVX_MSVC_SUPPORTED)
CHECK_CXX_COMPILER_FLAG("-mavx -mfma" COMPILER_OPT_ARCH_AVX_GCC_CLANG_SUPPORTED)
if(COMPILER_OPT_ARCH_AVX_MSVC_SUPPORTED)
message(STATUS "Compiler supports flags: /arch:AVX2")
message(STATUS "chowdsp_fft -- Compiler supports flags: /arch:AVX2")
add_library(chowdsp_fft_avx STATIC simd/chowdsp_fft_impl_avx.cpp)
target_compile_options(chowdsp_fft_avx PRIVATE /arch:AVX2)
target_compile_definitions(chowdsp_fft_avx PRIVATE _USE_MATH_DEFINES=1)
target_compile_features(chowdsp_fft_avx PRIVATE cxx_std_17)
target_link_libraries(chowdsp_fft PRIVATE chowdsp_fft_avx)
target_compile_definitions(chowdsp_fft PRIVATE CHOWDSP_FFT_COMPILER_SUPPORTS_AVX=1)
else()
if(COMPILER_OPT_ARCH_AVX_GCC_CLANG_SUPPORTED)
message(STATUS "Compiler supports flags: -mavx2 -mfma")
message(STATUS "chowdsp_fft -- Compiler supports flags: -mavx2 -mfma")
add_library(chowdsp_fft_avx STATIC simd/chowdsp_fft_impl_avx.cpp)
target_compile_options(chowdsp_fft_avx PRIVATE -mavx2 -mfma -Wno-unused-command-line-argument)
target_compile_features(chowdsp_fft_avx PRIVATE cxx_std_17)
target_compile_definitions(chowdsp_fft_avx PRIVATE _USE_MATH_DEFINES=1)
target_link_libraries(chowdsp_fft PRIVATE chowdsp_fft_avx)
target_compile_definitions(chowdsp_fft PRIVATE CHOWDSP_FFT_COMPILER_SUPPORTS_AVX=1)
else()
message(STATUS "Compiler DOES NOT supports flags: -mavx2 -mfma")
message(STATUS "chowdsp_fft -- Compiler DOES NOT supports flags: -mavx2 -mfma")
target_compile_definitions(chowdsp_fft PRIVATE CHOWDSP_FFT_COMPILER_SUPPORTS_AVX=0)
endif()
endif()

## JUCE compatibility
if(EXISTS "${JUCE_MODULES_DIR}")
message(STATUS "Configuring chowdsp_fft for JUCE")
message(STATUS "chowdsp_fft -- Configuring chowdsp_fft_juce")
juce_add_module(chowdsp_fft_juce ALIAS_NAMESPACE chowdsp)
target_link_libraries(chowdsp_fft_juce INTERFACE chowdsp_fft)
endif()

if(CHOWDSP_FFT_TESTING)
add_subdirectory(test)
add_subdirectory(bench)
endif()
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# chowdsp_fft

[![Test](https://github.com/Chowdhury-DSP/chowdsp_fft/actions/workflows/test.yml/badge.svg)](https://github.com/Chowdhury-DSP/chowdsp_fft/actions/workflows/test.yml)
[![Bench](https://github.com/Chowdhury-DSP/chowdsp_fft/actions/workflows/bench.yml/badge.svg)](https://github.com/Chowdhury-DSP/chowdsp_fft/actions/workflows/bench.yml)
[![codecov](https://codecov.io/gh/Chowdhury-DSP/chowdsp_fft/graph/badge.svg?token=A5BJ6CS859)](https://codecov.io/gh/Chowdhury-DSP/chowdsp_fft)

`chowdsp_fft` is a fork of the [`pffft`](https://bitbucket.org/jpommier/pffft/src/master/)
library for computing Fast Fourier Transforms. This fork adds a couple
of optimizations, most importantly the ability to use AVX intrinsics
Expand Down
7 changes: 7 additions & 0 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
message(STATUS "chowdsp_fft -- Configuring benchmarks")

add_executable(bench_chowdsp_fft bench.cpp)
target_link_libraries(bench_chowdsp_fft PRIVATE chowdsp_fft)
target_include_directories(bench_chowdsp_fft PRIVATE ${CMAKE_BINARY_DIR}/_deps/pffft-src)
target_compile_definitions(bench_chowdsp_fft PRIVATE _USE_MATH_DEFINES=1)
target_compile_features(bench_chowdsp_fft PRIVATE cxx_std_20)
Loading
Loading