Skip to content

Commit

Permalink
Merge pull request #13 from neo-sonar/radix-fft
Browse files Browse the repository at this point in the history
Emscripten
  • Loading branch information
tobiashienzsch authored May 16, 2024
2 parents 15bd190 + 2569b2d commit 9a88584
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 100 deletions.
115 changes: 72 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ concurrency:
cancel-in-progress: true

env:
DEBIAN_FRONTEND: noninteractive
HOMEBREW_NO_INSTALL_CLEANUP: 1

jobs:
Expand All @@ -25,41 +26,56 @@ jobs:
matrix:
include:
- name: Linux-Clang
os: ubuntu-20.04
os: ubuntu-24.04
build_type: Release
generator: Ninja
clang_version: 15
clang_version: latest
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="-march=native" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: "/opt/intel/oneapi/ipp/latest:/opt/intel/oneapi/mkl/latest"
cmake_targets: all
macos_target: ""

- name: Linux-GCC
os: ubuntu-22.04
os: ubuntu-24.04
build_type: Debug
generator: Ninja
clang_version: ""
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="-g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all -march=native" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: "/opt/intel/oneapi/ipp/latest:/opt/intel/oneapi/mkl/latest"
cmake_targets: all
macos_target: ""

- name: macOS-13.3
os: macos-13
- name: Emscripten
os: ubuntu-24.04
build_type: Release
generator: Ninja
clang_version: ""
cmake_flags: '-D CMAKE_OSX_ARCHITECTURES="arm64;x86_64"'
cmake_bin: "emcmake cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="-msimd128 -msse4.2 -fexceptions" -D NEO_ENABLE_BENCHMARKS=OFF -D NEO_ENABLE_TOOLS=OFF -D NEO_ENABLE_XSIMD=ON'
cmake_prefix_path: ""
cmake_targets: all
macos_target: "13.3"
macos_target: ""

- name: macOS-10.15
os: macos-12
- name: macOS-ARM64
os: macos-14
build_type: Release
generator: Ninja
clang_version: ""
cmake_flags: '-D CMAKE_OSX_ARCHITECTURES="arm64;x86_64"'
cmake_bin: "cmake"
cmake_flags: ""
cmake_prefix_path: ""
cmake_targets: all
macos_target: "11.0"

- name: macOS-X64
os: macos-13
build_type: Release
generator: Ninja
clang_version: ""
cmake_bin: "cmake"
cmake_flags: ""
cmake_prefix_path: ""
cmake_targets: all
macos_target: "10.15"
Expand All @@ -69,8 +85,9 @@ jobs:
build_type: Release
generator: Ninja
clang_version: latest
cmake_flags: '-D CMAKE_CXX_FLAGS="-march=native" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: C:\Program Files (x86)\Intel\oneAPI\ipp\latest\lib\cmake\ipp;C:\Program Files (x86)\Intel\oneAPI\mkl\latest\lib\cmake\mkl
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="-march=native" -D NEO_ENABLE_INTEL_IPP=OFF -D NEO_ENABLE_INTEL_MKL=OFF -D NEO_ENABLE_BENCHMARKS=OFF'
cmake_prefix_path: C:\Program Files (x86)\Intel\oneAPI\ipp\latest;C:\Program Files (x86)\Intel\oneAPI\mkl\latest
cmake_targets: all
macos_target: ""

Expand All @@ -79,8 +96,9 @@ jobs:
build_type: Release
generator: Ninja
clang_version: ""
cmake_flags: '-D CMAKE_CXX_FLAGS="/arch:AVX2 /EHsc" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: C:\Program Files (x86)\Intel\oneAPI\ipp\latest\lib\cmake\ipp;C:\Program Files (x86)\Intel\oneAPI\mkl\latest\lib\cmake\mkl
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="/arch:AVX2 /EHsc" -D NEO_ENABLE_INTEL_IPP=OFF -D NEO_ENABLE_INTEL_MKL=OFF'
cmake_prefix_path: C:\Program Files (x86)\Intel\oneAPI\ipp\latest;C:\Program Files (x86)\Intel\oneAPI\mkl\latest
cmake_targets: all
macos_target: ""

Expand All @@ -89,6 +107,7 @@ jobs:
build_type: Debug
generator: Ninja
clang_version: ""
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="--coverage -march=native" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: "/opt/intel/oneapi/ipp/latest:/opt/intel/oneapi/mkl/latest"
cmake_targets: neosonar-neo-tests
Expand All @@ -99,7 +118,8 @@ jobs:
build_type: Debug
generator: Ninja
clang_version: ""
cmake_flags: '-D CMAKE_CXX_FLAGS="--coverage -march=nehalem" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="--coverage -march=x86-64-v2" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: "/opt/intel/oneapi/ipp/latest:/opt/intel/oneapi/mkl/latest"
cmake_targets: neosonar-neo-tests
macos_target: ""
Expand All @@ -109,7 +129,8 @@ jobs:
build_type: Debug
generator: Ninja
clang_version: ""
cmake_flags: '-D CMAKE_CXX_FLAGS="--coverage -msse2" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_bin: "cmake"
cmake_flags: '-D CMAKE_CXX_FLAGS="--coverage -march=x86-64" -D NEO_ENABLE_INTEL_IPP=ON -D NEO_ENABLE_INTEL_MKL=ON'
cmake_prefix_path: "/opt/intel/oneapi/ipp/latest:/opt/intel/oneapi/mkl/latest"
cmake_targets: neosonar-neo-tests
macos_target: ""
Expand All @@ -128,11 +149,8 @@ jobs:
sudo apt install
libcurl4-openssl-dev
libasound2-dev
libx11-dev
libxinerama-dev
libxext-dev
xorg-dev
libfreetype6-dev
libwebkit2gtk-4.0-dev
libglu1-mesa-dev
xvfb
ninja-build
Expand All @@ -154,36 +172,42 @@ jobs:
version: ${{ matrix.clang_version }}

- name: Install IPP/MKL (Linux)
if: runner.os == 'Linux'
if: contains(matrix.name, 'Linux') || contains(matrix.name, 'Coverage')
shell: bash
run: |
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update
sudo apt install intel-oneapi-mkl-devel intel-oneapi-ipp-devel
- name: Cache IPP (Windows)
if: runner.os == 'Windows'
id: cache-ipp
uses: actions/cache@v4
with:
key: ipp-v4
path: C:\Program Files (x86)\Intel
# - name: Cache IPP (Windows)
# if: runner.os == 'Windows'
# id: cache-ipp
# uses: actions/cache@v4
# with:
# key: ipp-v4
# path: C:\Program Files (x86)\Intel

- name: Install IPP (Windows)
if: (runner.os == 'Windows') && (steps.cache-ipp.outputs.cache-hit != 'true')
shell: bash
run: |
curl --output oneapi.exe https://registrationcenter-download.intel.com/akdlm/IRC_NAS/5cb30fb9-21e9-47e8-82da-a91e00191670/w_BaseKit_p_2024.0.1.45_offline.exe
./oneapi.exe -s -x -f oneapi
./oneapi/bootstrapper.exe -s -c --action install --components=intel.oneapi.win.ipp.devel:intel.oneapi.win.mkl.devel --eula=accept -p=NEED_VS2022_INTEGRATION=1 --log-dir=.
# - name: Install IPP (Windows)
# if: (runner.os == 'Windows') && (steps.cache-ipp.outputs.cache-hit != 'true')
# shell: bash
# run: |
# curl --output oneapi.exe https://registrationcenter-download.intel.com/akdlm/IRC_NAS/5cb30fb9-21e9-47e8-82da-a91e00191670/w_BaseKit_p_2024.0.1.45_offline.exe
# ./oneapi.exe -s -x -f oneapi
# ./oneapi/bootstrapper.exe -s -c --action install --components=intel.oneapi.win.ipp.devel:intel.oneapi.win.mkl.devel --eula=accept -p=NEED_VS2022_INTEGRATION=1 --log-dir=.

- name: Save IPP cache (even on CI fail)
if: runner.os == 'Windows' && (steps.cache-ipp.outputs.cache-hit != 'true')
uses: actions/cache/save@v4
# - name: Save IPP cache (even on CI fail)
# if: runner.os == 'Windows' && (steps.cache-ipp.outputs.cache-hit != 'true')
# uses: actions/cache/save@v4
# with:
# path: C:\Program Files (x86)\Intel
# key: ipp-v4

- name: Setup emsdk
if: matrix.name == 'Emscripten'
uses: mymindstorm/setup-emsdk@v14
with:
path: C:\Program Files (x86)\Intel
key: ipp-v4
version: latest

- name: Set up Visual Studio shell
if: ${{ matrix.name }} == 'Windows-MSVC'
Expand All @@ -202,7 +226,7 @@ jobs:
- name: CMake configure
shell: bash
run: >
cmake -S .
${{ matrix.cmake_bin }} -S .
-B build
-G "${{ matrix.generator }}"
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
Expand All @@ -213,10 +237,15 @@ jobs:
shell: bash
run: cmake --build build --config ${{ matrix.build_type }} --target ${{ matrix.cmake_targets }}

- name: CTest
- name: Test
if: matrix.name != 'Emscripten'
shell: bash
run: ctest --test-dir build -C ${{ matrix.build_type }} --output-on-failure

- name: Test (Emscripten)
if: matrix.name == 'Emscripten'
run: node build/test/neosonar-neo-tests.js -v high

- name: Coverage report
if: contains(matrix.name, 'Coverage')
shell: bash
Expand All @@ -231,7 +260,7 @@ jobs:
-o build/coverage.xml
- name: Upload coverage report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
if: contains(matrix.name, 'Coverage')
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.7", "3.12", "pypy-3.9"]
python-version: ["3.9", "3.12", "pypy-3.9"]
steps:
- uses: actions/checkout@v4

Expand All @@ -29,7 +29,7 @@ jobs:
run: pytest --cov=neo --cov-branch

- name: Upload coverage report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_stages: [commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -21,6 +21,6 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.5
hooks:
- id: clang-format
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.23...3.27)
project(neosonar-neo-dev VERSION 0.1.0)

option(NEO_ENABLE_BENCHMARKS "Build benchmarks" ON)
option(NEO_ENABLE_TESTS "Build tests" ON)
option(NEO_ENABLE_TOOLS "Build tools" ON)

option(NEO_ENABLE_APPLE_ACCELERATE "Link against Apple Accelerate" ON)
option(NEO_ENABLE_INTEL_IPP "Link against Intel IPP" OFF)
option(NEO_ENABLE_INTEL_MKL "Link against Intel MKL" OFF)
Expand Down Expand Up @@ -48,8 +52,15 @@ if(DEFINED SKBUILD)
return()
endif()

add_subdirectory(test)
if(NEO_ENABLE_TESTS)
add_subdirectory(test)
endif()

add_subdirectory(extra/benchmark)
add_subdirectory(extra/cli)
add_subdirectory(extra/plugin)
if(NEO_ENABLE_BENCHMARKS)
add_subdirectory(extra/benchmark)
endif()

if(NEO_ENABLE_TOOLS)
add_subdirectory(extra/cli)
add_subdirectory(extra/plugin)
endif()
3 changes: 2 additions & 1 deletion extra/benchmark/src/fixed_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ struct cmulp
{
explicit cmulp() : _lhs(2, Size), _rhs(2, Size), _out(2, Size)
{
if constexpr (std::same_as<FloatOrFixed, neo::q7> or std::same_as<FloatOrFixed, neo::q15> or std::same_as<FloatOrFixed, neo::fixed_point<int16_t, 14>>) {
if constexpr (std::same_as<FloatOrFixed, neo::q7> or std::same_as<FloatOrFixed, neo::q15>
or std::same_as<FloatOrFixed, neo::fixed_point<int16_t, 14>>) {
auto copy_to_fixed_point = [](auto src, auto dest) {
for (auto i{0}; i < src.extent(0); ++i) {
dest[i] = FloatOrFixed(src[i]);
Expand Down
4 changes: 2 additions & 2 deletions extra/benchmark/src/simd_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ struct simd_split_fft_plan
}

template<neo::in_vector_of<FloatBatch> InVec, neo::out_vector_of<FloatBatch> OutVec>
auto operator()(neo::split_complex<InVec> in, neo::split_complex<OutVec> out, neo::fft::direction dir) noexcept
-> void
auto
operator()(neo::split_complex<InVec> in, neo::split_complex<OutVec> out, neo::fft::direction dir) noexcept -> void
{
assert(std::cmp_equal(in.real.extent(0), size()));
assert(neo::detail::extents_equal(in.real, in.imag, out.real, out.imag));
Expand Down
4 changes: 2 additions & 2 deletions extra/cli/src/wav.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ template<std::floating_point Float>
}
}

inline auto write_wav_file(audio_buffer<float> const& buffer, double sampleRate, std::filesystem::path const& path)
-> void
inline auto
write_wav_file(audio_buffer<float> const& buffer, double sampleRate, std::filesystem::path const& path) -> void
{
auto format = drwav_data_format{};
format.container = drwav_container_riff;
Expand Down
7 changes: 7 additions & 0 deletions extra/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ target_link_libraries(PerceptualConvolution
# juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "15.1")
target_compile_definitions(PerceptualConvolution PUBLIC JUCE_SILENCE_XCODE_15_LINKER_WARNING=1)
target_link_options(PerceptualConvolution PUBLIC -Wl,-ld_classic)
endif()
endif()
8 changes: 4 additions & 4 deletions extra/plugin/src/dsp/AudioBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ struct BufferWithSampleRate
double sampleRate;
};

[[nodiscard]] auto resample(BufferWithSampleRate<float> const& buf, double destSampleRate)
-> BufferWithSampleRate<float>;
[[nodiscard]] auto
resample(BufferWithSampleRate<float> const& buf, double destSampleRate) -> BufferWithSampleRate<float>;

template<std::floating_point Float>
[[nodiscard]] auto to_mdarray(juce::AudioBuffer<Float> const& buffer)
-> stdex::mdarray<Float, stdex::dextents<std::size_t, 2>>
[[nodiscard]] auto to_mdarray(juce::AudioBuffer<Float> const& buffer
) -> stdex::mdarray<Float, stdex::dextents<std::size_t, 2>>
{
auto result = stdex::mdarray<Float, stdex::dextents<std::size_t, 2>>{
static_cast<std::size_t>(buffer.getNumChannels()),
Expand Down
4 changes: 2 additions & 2 deletions extra/python/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ auto fft(py::array_t<Complex> array, std::optional<std::size_t> n, neo::fft::nor
}

template<neo::convolution::method Method, std::floating_point Float>
[[nodiscard]] auto convolve(py::array_t<Float> in1, py::array_t<Float> in2, neo::convolution::mode mode)
-> py::array_t<Float>
[[nodiscard]] auto
convolve(py::array_t<Float> in1, py::array_t<Float> in2, neo::convolution::mode mode) -> py::array_t<Float>
{
if (in1.ndim() != 1 or in1.ndim() != 1) {
throw std::runtime_error{"unsupported dimension: in1 and in2 must be 1-D"};
Expand Down
4 changes: 2 additions & 2 deletions extra/snippet/split_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ struct static_dit2_stage
static_dit2_stage<Float, Order, Stage + 1>{}(x, twiddles);
}

auto operator()(std::complex<Float>* __restrict__ /*x*/, std::complex<Float> const* __restrict__ /*twiddles*/)
-> void
auto
operator()(std::complex<Float>* __restrict__ /*x*/, std::complex<Float> const* __restrict__ /*twiddles*/) -> void
requires(Stage == Order)
{}
};
Expand Down
Loading

0 comments on commit 9a88584

Please sign in to comment.