Skip to content

Commit

Permalink
Extend unit tests to check for optimized, native-arch builds.
Browse files Browse the repository at this point in the history
This is mainly intended to check for correct independence assumptions during
vectorization, but it also doesn't hurt to test all of the code for correct
behavior at more aggressive optimization levels.

Also bumped up the number of cores to speed up compilation on Action runners.
  • Loading branch information
LTLA committed Nov 3, 2024
1 parent ce86da8 commit f77c03f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ jobs:
matrix:
config:
- {
name: "Ubuntu Latest GCC, coverage enabled",
name: "Ubuntu Latest GCC (debug, coverage enabled)",
os: ubuntu-latest,
cov: true
type: coverage
}
- {
name: "macOS Latest Clang",
os: macos-latest
name: "Ubuntu Latest GCC (all optimizations)",
os: ubuntu-latest,
type: optimized
}
- {
name: "macOS Latest Clang (debug)",
os: macos-latest,
type: debug
}
- {
name: "macOS Latest Clang (all optimizations)",
os: macos-latest,
type: optimized
}

steps:
Expand All @@ -30,16 +41,20 @@ jobs:
- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Configure the build for Mac
if: ${{ matrix.config.os == 'macos-latest' }}
- name: Configure the build (debug)
if: ${{ matrix.config.type == 'debug' }}
run: cmake -S . -B build

- name: Configure the build with coverage
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.cov }}
run: cmake -S . -B build -DCODE_COVERAGE=ON
- name: Configure the build (coverage)
if: ${{ matrix.config.type == 'coverage' }}
run: cmake -S . -B build -DCODE_COVERAGE=ON

- name: Configure the build (optimized)
if: ${{ matrix.config.type == 'optimized' }}
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DUSE_MARCH_NATIVE=ON

- name: Run the build
run: cmake --build build
run: cmake --build build -j 2

- name: Run the tests
run: |
Expand Down
7 changes: 7 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(DO_CODE_COVERAGE ON)
endif()

# Test for correct handling of vectorization.
option(USE_MARCH_NATIVE "Build for native architecture." OFF)

macro(decorate_executable target)
target_link_libraries(
${target}
Expand All @@ -38,6 +41,10 @@ macro(decorate_executable target)
target_link_options(${target} PRIVATE --coverage)
endif()

if(USE_MARCH_NATIVE)
target_compile_options(${target} PRIVATE -march=native)
endif()

gtest_discover_tests(${target})
endmacro()

Expand Down

0 comments on commit f77c03f

Please sign in to comment.