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

Add arm64 mac CI using locally hosted runner #113

Merged
merged 9 commits into from
Oct 31, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:

env:
BUILD_TYPE: Release
HAMMING_WITH_SSE2: OFF
HAMMING_WITH_AVX2: OFF
HAMMING_WITH_AVX512: OFF
HAMMING_WITH_OPENMP: OFF
Expand All @@ -29,6 +30,8 @@ jobs:
open-mp: "ON"
- os: macos-latest
open-mp: "OFF"
- os: macos-arm64-ssc
open-mp: "OFF"
- os: windows-latest
open-mp: "OFF"

Expand All @@ -48,7 +51,7 @@ jobs:
- name: configure cmake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=ON -DHAMMING_WITH_AVX2=$HAMMING_WITH_AVX2 -DHAMMING_WITH_AVX512=$HAMMING_WITH_AVX512 -DHAMMING_BUILD_PYTHON=ON -DHAMMING_WITH_OPENMP=${{ matrix.open-mp }}
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=$HAMMING_WITH_SSE2 -DHAMMING_WITH_AVX2=$HAMMING_WITH_AVX2 -DHAMMING_WITH_AVX512=$HAMMING_WITH_AVX512 -DHAMMING_BUILD_PYTHON=ON -DHAMMING_WITH_OPENMP=${{ matrix.open-mp }}

- name: build
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, macos-arm64-ssc, windows-latest]

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion include/hamming/hamming_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
#define _HAMMING_IMPL_HH

#include <array>
#if defined(__aarch64__) || defined(_M_ARM64)
#include <cpuinfo_aarch64.h>
#else
#include <cpuinfo_x86.h>
#endif
#include <cstdint>
#include <limits>
#include <string>
Expand Down Expand Up @@ -93,9 +97,15 @@ std::vector<DistIntType> distances(std::vector<std::string> &data,
if (clear_input_data) {
data.clear();
}
const auto features = cpu_features::GetX86Info().features;
int (*distance_func)(const std::vector<GeneBlock> &a,
const std::vector<GeneBlock> &b) = distance_cpp;

#if defined(__aarch64__) || defined(_M_ARM64)
const auto features = cpu_features::GetAarch64Info().features;
#else
const auto features = cpu_features::GetX86Info().features;
#endif

#ifdef HAMMING_WITH_SSE2
if (features.sse2) {
distance_func = distance_sse2;
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ HAMMING_BUILD_BENCHMARKS = "OFF"
HAMMING_BUILD_PYTHON = "ON"

[tool.cibuildwheel]
skip = "*-manylinux_i686"
skip = "*-manylinux_i686 cp38-macosx_arm64"
test-skip = "pp* *-musllinux*"
test-extras = "test"
test-command = "pytest {project}/python/tests -v"
Expand All @@ -52,3 +52,7 @@ build-verbosity = 3

[tool.cibuildwheel.linux]
environment = { CMAKE_ARGS="-DHAMMING_WITH_OPENMP=ON" }

[[tool.cibuildwheel.overrides]]
select = "*-macosx_arm64*"
environment = { CMAKE_ARGS="-DHAMMING_WITH_SSE2=OFF -DHAMMING_WITH_AVX2=OFF -DHAMMING_WITH_AVX512=OFF" }
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build hamming library
add_library(hamming STATIC hamming.cc hamming_impl.cc)
target_include_directories(hamming PUBLIC ../include)
target_link_libraries(hamming PUBLIC CpuFeature::cpu_features)
target_link_libraries(hamming PUBLIC CpuFeatures::cpu_features)
if(HAMMING_WITH_OPENMP)
find_package(OpenMP REQUIRED)
target_compile_definitions(hamming PUBLIC HAMMING_WITH_OPENMP)
Expand Down Expand Up @@ -50,7 +50,7 @@ if(HAMMING_BUILD_BENCHMARKS)
target_link_libraries(bench PRIVATE distance_avx512)
endif()
target_link_libraries(bench PRIVATE hamming benchmark::benchmark
CpuFeature::cpu_features)
CpuFeatures::cpu_features)
endif()

# Build tests
Expand All @@ -70,6 +70,6 @@ if(BUILD_TESTING)
target_link_libraries(tests PRIVATE distance_avx512)
endif()
target_link_libraries(tests PRIVATE hamming Catch2::Catch2
CpuFeature::cpu_features)
CpuFeatures::cpu_features)
catch_discover_tests(tests)
endif()