-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cmake build system revamped completely, more modern practices. It auto selects compiler flags based on the supported ones on all operating systems. Added support for Windows (llvm, msvc), Linux (llvm, gcc) and MacOS (llvm, gcc). * cmake support for both ducc0 and fftw * cmake adding nvcc and msvc optimization flags * updated CI to test multiple combinations of ffts, os, compilers
- Loading branch information
1 parent
4e89cf9
commit 4a176c4
Showing
17 changed files
with
914 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,57 @@ | ||
name: cmake ci linux macos windows | ||
on: | ||
push: | ||
release: | ||
types: [published] | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.generate_matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Generate matrix | ||
id: generate_matrix | ||
run: | | ||
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV | ||
MATRIX=$(python3 ${{ github.workspace }}/.github/workflows/generate_cmake_matrix.py) | ||
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT | ||
cmake-ci: | ||
runs-on: ${{ matrix.os }} | ||
needs: prepare | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- windows-2022 | ||
- ubuntu-22.04 | ||
- macos-13 | ||
compiler: | ||
- llvm | ||
- gcc-12 | ||
# you can specify the version after `-` like `llvm-13.0.0`. | ||
generator: | ||
- "Ninja" | ||
build_type: | ||
- Release | ||
finufft_static_linking: | ||
- ON | ||
include: | ||
- os: "windows-2022" | ||
compiler: "msvc" | ||
generator: "Ninja" | ||
build_type: "Release" | ||
finufft_static_linking: "OFF" | ||
exclude: | ||
- os: "windows-2022" | ||
compiler: "gcc-12" | ||
generator: "Ninja" | ||
build_type: "Release" | ||
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Unlink gcc | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew unlink gcc | ||
continue-on-error: true | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup Cpp | ||
uses: aminya/setup-cpp@v1 | ||
with: | ||
compiler: ${{ matrix.compiler }} | ||
compiler: ${{ matrix.toolchain }} | ||
vcvarsall: ${{ contains(matrix.os, 'windows') }} | ||
cmake: true | ||
ninja: true | ||
vcpkg: false | ||
cppcheck: false | ||
clangtidy: false | ||
|
||
- name: Install macOS dependencies | ||
- name: Set min macOS version and install fftw | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install fftw | ||
- name: Install fftw | ||
if: runner.os == 'linux' | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libfftw3-dev | ||
- name: Configure Cmake | ||
run: | | ||
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DFINUFFT_BUILD_TESTS=ON -DFINUFFT_STATIC_LINKING=${{matrix.finufft_static_linking}} | ||
cmake -S . -B ./build -G Ninja -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DFINUFFT_ARCH_FLAGS=${{ matrix.arch_flags }} -DFINUFFT_BUILD_TESTS=ON -DFINUFFT_STATIC_LINKING=${{matrix.finufft_static_linking}} -DFINUFFT_USE_DUCC0=${{ matrix.ducc_fft }} | ||
- name: Build | ||
run: | | ||
cmake --build ./build --config ${{matrix.build_type}} | ||
- name: Test | ||
working-directory: ./build | ||
run: | | ||
ctest -C ${{matrix.build_type}} | ||
# may change to cpack and action-gh-release later | ||
- name: Upload static and shared lib | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{matrix.os}}-${{matrix.compiler}}-finufft-lib | ||
path: ${{runner.workspace}}/finufft/build/*finufft* | ||
|
||
- name: Pack For Release | ||
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' && github.event.action == 'published' | ||
shell: bash | ||
run: | | ||
cd build | ||
if [[ "${{ matrix.os }}" == "windows-2022" ]] | ||
then | ||
7z a ../${{matrix.os}}-${{matrix.compiler}}-finufft-lib.zip *finufft* | ||
else | ||
tar czvf ../${{matrix.os}}-${{matrix.compiler}}-finufft-lib.tar.gz *finufft* | ||
fi | ||
cd - | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' && github.event.action == 'published' | ||
with: | ||
files: | | ||
*-finufft-lib* | ||
ctest -C ${{matrix.build_type}} --output-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import json | ||
|
||
matrix = { | ||
"include": [] | ||
} | ||
|
||
static_linking = ["On", "Off"] | ||
|
||
combinations = [ | ||
("ubuntu-22.04", { | ||
"build_type": ["Release", "Debug"], | ||
"toolchain": ["llvm", "gcc"], | ||
"arch_flags": ["-march=native", "-march=x86-64", "native"], | ||
"ducc_fft": ["On", "Off"] | ||
}), | ||
("windows-2022", { | ||
"build_type": ["Release", "Debug"], | ||
"toolchain": ["msvc"], | ||
"arch_flags": ["/arch:AVX2", "/arch:SSE2", "native"], | ||
"ducc_fft": ["On", "Off"] | ||
}), | ||
("windows-2022", { | ||
"build_type": ["Release"], | ||
"toolchain": ["llvm"], | ||
"arch_flags": ["-march=native", "-march=x86-64", "native"], | ||
"ducc_fft": ["On", "Off"] | ||
}), | ||
("macos-13", { | ||
"build_type": ["Release", "Debug"], | ||
"toolchain": ["llvm", "gcc-14"], | ||
"arch_flags": ["-march=native", "-march=x86-64", "native"], | ||
"ducc_fft": ["On", "Off"] | ||
}) | ||
] | ||
|
||
|
||
def get_c_compiler(toolchain): | ||
if "gcc" in toolchain: | ||
return "gcc" | ||
elif toolchain == "llvm": | ||
return "clang" | ||
elif toolchain == "msvc": | ||
return "cl" | ||
else: | ||
raise ValueError(f"Unknown toolchain: {toolchain}") | ||
|
||
|
||
def get_cxx_compiler(toolchain): | ||
if "gcc" in toolchain: | ||
return "g++" | ||
elif toolchain == "llvm": | ||
return "clang++" | ||
elif toolchain == "msvc": | ||
return "cl" | ||
else: | ||
raise ValueError(f"Unknown toolchain: {toolchain}") | ||
|
||
|
||
for platform, value in combinations: | ||
for toolchain in value["toolchain"]: | ||
for arch_flag in value["arch_flags"]: | ||
for linking in static_linking: | ||
for build in value["build_type"]: | ||
for ducc in value["ducc_fft"]: | ||
matrix["include"].append({ | ||
"os": platform, | ||
"toolchain": toolchain, | ||
"arch_flags": arch_flag, | ||
"finufft_static_linking": linking, | ||
"build_type": build, | ||
"c_compiler": get_c_compiler(toolchain), | ||
"cxx_compiler": get_cxx_compiler(toolchain), | ||
"ducc_fft": ducc | ||
}) | ||
json_str = json.dumps(matrix, ensure_ascii=False) | ||
print(json_str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.