Skip to content

Commit 87032b6

Browse files
authored
added gh workflow to build and test (#2)
* added gh workflow to build and test * remove accidentally used C++23 feature * fix ODR in avx2 code
1 parent a6f2e67 commit 87032b6

File tree

2 files changed

+126
-5
lines changed

2 files changed

+126
-5
lines changed

.github/workflows/build.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build
2+
on:
3+
push:
4+
paths-ignore:
5+
- "**/README.md"
6+
7+
env:
8+
USERNAME: kwsp
9+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
10+
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
11+
FEED_URL: https://nuget.pkg.github.com/kwsp/index.json
12+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite;nuget,https://nuget.pkg.github.com/kwsp/index.json,readwrite"
13+
14+
jobs:
15+
Build-Win64:
16+
runs-on: windows-2022
17+
steps:
18+
- name: Export GitHub Actions cache environment variables
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
23+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
24+
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: true
28+
29+
- name: Setup VCPKG
30+
shell: pwsh
31+
run: |
32+
cd ${{ github.workspace }}
33+
git clone https://github.com/microsoft/vcpkg
34+
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat
35+
36+
- name: Add NuGet sources
37+
shell: pwsh
38+
run: |
39+
.$(${{ env.VCPKG_EXE }} fetch nuget) `
40+
sources add `
41+
-Source "${{ env.FEED_URL }}" `
42+
-StorePasswordInClearText `
43+
-Name GitHubPackages `
44+
-UserName "${{ env.USERNAME }}" `
45+
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
46+
.$(${{ env.VCPKG_EXE }} fetch nuget) `
47+
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" `
48+
-Source "${{ env.FEED_URL }}"
49+
50+
- name: CMake configure
51+
run: cmake --preset win64
52+
53+
- name: CMake build
54+
run: cmake --build --preset win64-release
55+
56+
- name: CTest
57+
shell: bash
58+
run: ctest --output-on-failure --test-dir build/win64/test/
59+
60+
Build-mac:
61+
runs-on: macos-latest
62+
steps:
63+
- name: Export GitHub Actions cache environment variables
64+
uses: actions/github-script@v7
65+
with:
66+
script: |
67+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
68+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
69+
70+
- uses: actions/checkout@v4
71+
with:
72+
submodules: true
73+
74+
- name: Install system-wide build tools
75+
shell: bash
76+
# Install
77+
# mono: NuGet requires a dotnet runtime
78+
# ninja: Build system
79+
# llvm: Just for clang-tidy. Need to add to path.
80+
# Just add clang-tidy to path, not all of LLVM clang.
81+
run: |
82+
brew install mono ninja llvm
83+
ln -s $(brew --prefix llvm)/bin/clang-tidy /usr/local/bin/clang-tidy
84+
brew install autoconf autoconf-archive automake libtool
85+
86+
- name: Setup VCPKG
87+
shell: bash
88+
run: |
89+
cd ${{ github.workspace }}
90+
git clone https://github.com/microsoft/vcpkg
91+
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.sh
92+
93+
- name: Add NuGet sources
94+
shell: bash
95+
env:
96+
gh_packages_secret: ${{ secrets.GH_PACKAGES_TOKEN }}
97+
if: ${{ env.gh_packages_secret != '' }}
98+
run: |
99+
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
100+
sources add \
101+
-Source "${{ env.FEED_URL }}" \
102+
-StorePasswordInClearText \
103+
-Name GitHubPackages \
104+
-UserName "${{ env.USERNAME }}" \
105+
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
106+
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
107+
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" \
108+
-Source "${{ env.FEED_URL }}"
109+
110+
- name: CMake configure
111+
shell: bash
112+
run: cmake --preset clang
113+
114+
- name: CMake build
115+
shell: bash
116+
run: cmake --build --preset clang-release
117+
118+
- name: CTest
119+
shell: bash
120+
run: ctest --output-on-failure --test-dir build/clang/test/

include/fftconv/fftconv.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <complex>
99
#include <fftconv/fftw.hpp>
1010
#include <memory>
11-
#include <ranges> // IWYU pragma: keep
1211
#include <span>
1312
#include <type_traits>
1413
#include <unordered_map>
@@ -107,10 +106,11 @@ inline void copy_to_padded_buffer(const std::span<const Tin> src,
107106
assert(src.size() <= dst.size());
108107

109108
// Copy data from source to destination
110-
std::ranges::copy(src, dst.begin());
109+
std::copy(src.begin(), src.end(), dst.begin());
111110

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

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

197197
#include <immintrin.h>
198198

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

@@ -545,7 +545,8 @@ void oaconvolve_fftw(std::span<const T> input, std::span<const T> kernel,
545545
assert(input.size() == output.size());
546546
plan.oaconvolve_same(input, kernel, output);
547547
} else {
548-
static_assert(Mode == ConvMode::Full || Mode == ConvMode::Same, "Unsupported mode.");
548+
static_assert(Mode == ConvMode::Full || Mode == ConvMode::Same,
549+
"Unsupported mode.");
549550
}
550551
}
551552

0 commit comments

Comments
 (0)