Skip to content

Commit

Permalink
Add GitHub Actions CI for Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Maratyszcza committed May 27, 2024
1 parent 680f06d commit 6de8675
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,30 @@ jobs:
- name: Install ninja
run: sudo apt install ninja-build
- name: Configure
run: cmake -Bbuild -S. -GNinja -DCMAKE_BUILD_TYPE=Release -DFP16_BUILD_COMPARATIVE_BENCHMARKS=ON
run: cmake -Bbuild -S. -G Ninja -DCMAKE_BUILD_TYPE=Release -DFP16_BUILD_COMPARATIVE_BENCHMARKS=ON
- name: Build
run: cmake --build build
- name: Test
run: ctest --test-dir build
cmake-macos-x86_64:
runs-on: macos-12
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -Bbuild -S. -G Xcode -DCMAKE_CONFIGURATION_TYPES=Release -DHAVE_STD_REGEX=TRUE -DFP16_BUILD_COMPARATIVE_BENCHMARKS=ON -DCMAKE_OSX_ARCHITECTURES=x86_64
- name: Build
run: cmake --build build --config Release --parallel $(sysctl -n hw.ncpu) -- -quiet
- name: Test
run: ctest --test-dir build
cmake-macos-arm64:
runs-on: macos-14
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -Bbuild -S. -G Xcode -DCMAKE_CONFIGURATION_TYPES=Release -DHAVE_STD_REGEX=TRUE -DFP16_BUILD_COMPARATIVE_BENCHMARKS=ON -DCMAKE_OSX_ARCHITECTURES=arm64e
- name: Build
run: cmake --build build --config Release --parallel $(sysctl -n hw.ncpu) -- -quiet
- name: Test
run: ctest --test-dir build
6 changes: 4 additions & 2 deletions bench/from-ieee-array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ BENCHMARK(fp16_ieee_to_fp32_value)->RangeMultiplier(2)->Range(1<<10, 64<<20);
float* output = fp32.data();
const size_t n = state.range(0);
#if defined(__aarch64__)
const unsigned int fpcr = __builtin_aarch64_get_fpcr();
unsigned int fpcr;
__asm__ __volatile__("MRS %[fpcr], fpcr" : [fpcr] "=r" (fpcr));
/* Disable flush-to-zero (bit 24) and Alternative FP16 format (bit 26) */
__builtin_aarch64_set_fpcr(fpcr & 0xF6FFFFFFu);
__asm__ __volatile__("MSR fpcr, %[fpcr]" :
: [fpcr] "r" (fpcr & 0xF6FFFFFFu));
#else
unsigned int fpscr;
__asm__ __volatile__ ("VMRS %[fpscr], fpscr" : [fpscr] "=r" (fpscr));
Expand Down
6 changes: 4 additions & 2 deletions bench/to-ieee-array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ BENCHMARK(fp16_ieee_from_fp32_value)->RangeMultiplier(2)->Range(1<<10, 64<<20);
uint16_t* output = fp16.data();
const size_t n = state.range(0);
#if defined(__aarch64__)
const unsigned int fpcr = __builtin_aarch64_get_fpcr();
unsigned int fpcr;
__asm__ __volatile__("MRS %[fpcr], fpcr" : [fpcr] "=r" (fpcr));
/* Disable flush-to-zero (bit 24) and Alternative FP16 format (bit 26) */
__builtin_aarch64_set_fpcr(fpcr & 0xF6FFFFFFu);
__asm__ __volatile__("MSR fpcr, %[fpcr]" :
: [fpcr] "r" (fpcr & 0xF6FFFFFFu));
#else
unsigned int fpscr;
__asm__ __volatile__ ("VMRS %[fpscr], fpscr" : [fpscr] "=r" (fpscr));
Expand Down
4 changes: 2 additions & 2 deletions cmake/DownloadGoogleBenchmark.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PROJECT(googlebenchmark-download NONE)

INCLUDE(ExternalProject)
ExternalProject_Add(googlebenchmark
URL https://github.com/google/benchmark/archive/v1.2.0.zip
URL_HASH SHA256=cc463b28cb3701a35c0855fbcefb75b29068443f1952b64dd5f4f669272e95ea
URL https://github.com/google/benchmark/archive/refs/tags/v1.8.4.zip
URL_HASH SHA256=84c49c4c07074f36fbf8b4f182ed7d75191a6fa72756ab4a17848455499f4286
SOURCE_DIR "${CMAKE_BINARY_DIR}/googlebenchmark-source"
BINARY_DIR "${CMAKE_BINARY_DIR}/googlebenchmark"
CONFIGURE_COMMAND ""
Expand Down

0 comments on commit 6de8675

Please sign in to comment.