Skip to content

Commit

Permalink
added gh workflow to build and test (#2)
Browse files Browse the repository at this point in the history
* added gh workflow to build and test
* remove accidentally used C++23 feature
* fix ODR in avx2 code
  • Loading branch information
kwsp authored Jan 4, 2025
1 parent a6f2e67 commit 87032b6
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 5 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build
on:
push:
paths-ignore:
- "**/README.md"

env:
USERNAME: kwsp
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: https://nuget.pkg.github.com/kwsp/index.json
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite;nuget,https://nuget.pkg.github.com/kwsp/index.json,readwrite"

jobs:
Build-Win64:
runs-on: windows-2022
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup VCPKG
shell: pwsh
run: |
cd ${{ github.workspace }}
git clone https://github.com/microsoft/vcpkg
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat
- name: Add NuGet sources
shell: pwsh
run: |
.$(${{ env.VCPKG_EXE }} fetch nuget) `
sources add `
-Source "${{ env.FEED_URL }}" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ env.USERNAME }}" `
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
.$(${{ env.VCPKG_EXE }} fetch nuget) `
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" `
-Source "${{ env.FEED_URL }}"
- name: CMake configure
run: cmake --preset win64

- name: CMake build
run: cmake --build --preset win64-release

- name: CTest
shell: bash
run: ctest --output-on-failure --test-dir build/win64/test/

Build-mac:
runs-on: macos-latest
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- uses: actions/checkout@v4
with:
submodules: true

- name: Install system-wide build tools
shell: bash
# Install
# mono: NuGet requires a dotnet runtime
# ninja: Build system
# llvm: Just for clang-tidy. Need to add to path.
# Just add clang-tidy to path, not all of LLVM clang.
run: |
brew install mono ninja llvm
ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin/clang-tidy
brew install autoconf autoconf-archive automake libtool
- name: Setup VCPKG
shell: bash
run: |
cd ${{ github.workspace }}
git clone https://github.com/microsoft/vcpkg
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.sh
- name: Add NuGet sources
shell: bash
env:
gh_packages_secret: ${{ secrets.GH_PACKAGES_TOKEN }}
if: ${{ env.gh_packages_secret != '' }}
run: |
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
sources add \
-Source "${{ env.FEED_URL }}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ env.USERNAME }}" \
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" \
-Source "${{ env.FEED_URL }}"
- name: CMake configure
shell: bash
run: cmake --preset clang

- name: CMake build
shell: bash
run: cmake --build --preset clang-release

- name: CTest
shell: bash
run: ctest --output-on-failure --test-dir build/clang/test/
11 changes: 6 additions & 5 deletions include/fftconv/fftconv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <complex>
#include <fftconv/fftw.hpp>
#include <memory>
#include <ranges> // IWYU pragma: keep
#include <span>
#include <type_traits>
#include <unordered_map>
Expand Down Expand Up @@ -107,10 +106,11 @@ inline void copy_to_padded_buffer(const std::span<const Tin> src,
assert(src.size() <= dst.size());

// Copy data from source to destination
std::ranges::copy(src, dst.begin());
std::copy(src.begin(), src.end(), dst.begin());

// Fill the remaining part of the destination with zeros
std::ranges::fill(dst.subspan(src.size()), 0);
auto dst_ = dst.subspan(src.size());
std::fill(dst_.begin(), dst_.end(), 0);
}

// static inline void elementwise_multiply(const fftw_complex *a,
Expand Down Expand Up @@ -196,7 +196,7 @@ inline void multiply_cx_neon_f32(std::span<const std::complex<float>> cx1,

#include <immintrin.h>

__m256d mult_c128_avx2(__m256d vec1, __m256d vec2) {
inline __m256d mult_c128_avx2(__m256d vec1, __m256d vec2) {
// vec1 and vec2 each have 2 128bit complex
const __m256d neg = _mm256_setr_pd(1.0, -1.0, 1.0, -1.0);

Expand Down Expand Up @@ -545,7 +545,8 @@ void oaconvolve_fftw(std::span<const T> input, std::span<const T> kernel,
assert(input.size() == output.size());
plan.oaconvolve_same(input, kernel, output);
} else {
static_assert(Mode == ConvMode::Full || Mode == ConvMode::Same, "Unsupported mode.");
static_assert(Mode == ConvMode::Full || Mode == ConvMode::Same,
"Unsupported mode.");
}
}

Expand Down

0 comments on commit 87032b6

Please sign in to comment.