diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..7097c913 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,51 @@ +# These tests benchmark the current code against the previous release +# using both the GCC and Clang compilers. If the new code runs slower +# than the previous release then the tests fail. This helps to detect +# performance regressions. + +name: benchmark + +on: + push: + branches-ignore: + - backup3 + - gh-pages + pull_request: + branches-ignore: + - backup3 + - gh-pages + +jobs: + linux_gcc_performance_test: + runs-on: ubuntu-latest + env: + CC: gcc + CXX: g++ + steps: + - uses: actions/checkout@v3 + with: + # Fetch all commits & tags + fetch-depth: 0 + - name: Install dependencies + run: | + sudo apt update + sudo apt install bc + - name: Benchmark latest code vs. previous release + run: scripts/./benchmark-vs-prev-release.sh + + linux_clang_performance_test: + runs-on: ubuntu-latest + env: + CC: clang + CXX: clang++ + steps: + - uses: actions/checkout@v3 + with: + # Fetch all commits & tags + fetch-depth: 0 + - name: Install dependencies + run: | + sudo apt update + sudo apt install bc libomp-dev + - name: Benchmark latest code vs. previous release + run: scripts/./benchmark-vs-prev-release.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9d50c8b..8532dff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,11 @@ on: jobs: # See documentation: https://www.msys2.org/docs/ci/ windows_mingw64: - runs-on: windows-latest + strategy: + matrix: + platform: ['windows-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} defaults: run: shell: msys2 {0} @@ -25,7 +29,7 @@ jobs: install: base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake - name: Build primecount run: | - cmake . -G "Unix Makefiles" -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + cmake . -G "Unix Makefiles" -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" grep "^OpenMP:INTERNAL=1$" CMakeCache.txt grep "^int128.*:INTERNAL=1$" CMakeCache.txt grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt @@ -34,64 +38,217 @@ jobs: run: ctest -j2 - name: primecount --test option run: ./primecount --test + - name: primecount --test + run: ./primecount --test + - name: primecount 1e11 --legendre + run: ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: ./primecount 1e14 --gourdon + + windows_msvc2022: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v3 + - name: Build primecount + run: | + cmake . -G "Visual Studio 17 2022" -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="/W3 /WX /MP /EHsc" + cmake --build . --config Release --target install + - name: CTest (unit tests) + run: ctest -j2 -C Release --output-on-failure + - name: primecount --test + run: Release\primecount.exe --test + - name: primecount 1e11 --legendre + run: Release\primecount.exe 1e11 --legendre + - name: primecount 1e12 --meissel + run: Release\primecount.exe 1e12 --meissel + - name: primecount 1e11 --lehmer + run: Release\primecount.exe 1e11 --lehmer + - name: primecount 1e12 --lmo + run: Release\primecount.exe 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: Release\primecount.exe 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: Release\primecount.exe 1e14 --gourdon linux_gcc: + strategy: + matrix: + platform: ['ubuntu-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} + env: + CC: gcc + CXX: g++ + steps: + - uses: actions/checkout@v3 + - name: Build primecount + # POPCNT disabled + Debug + run: | + cmake . -DWITH_POPCNT=OFF -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + grep "^OpenMP:INTERNAL=1$" CMakeCache.txt + grep "^int128.*:INTERNAL=1$" CMakeCache.txt + grep "^WITH_POPCNT:BOOL=OFF$" CMakeCache.txt + make -j8 VERBOSE=1 + - name: CTest (unit tests) + run: ctest -j2 + - name: primecount --test + run: ./primecount --test + - name: primecount 1e11 --legendre + run: ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: ./primecount 1e14 --gourdon + + linux_gcc_sanitizers: runs-on: ubuntu-latest env: CC: gcc CXX: g++ steps: - uses: actions/checkout@v3 - - name: Install valgrind + - name: Build primecount + run: | + cmake . -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -Wno-long-long -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" + make -j2 VERBOSE=1 + - name: CTest (unit tests) + run: ctest -j2 + - name: primecount --test + run: ./primecount --test + - name: primecount 1e11 --legendre + run: ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: ./primecount 1e14 --gourdon + + linux_gcc_valgrind: + runs-on: ubuntu-latest + env: + CC: gcc + CXX: g++ + steps: + - uses: actions/checkout@v3 + - name: Install dependencies run: | sudo apt update sudo apt install valgrind - name: Build primecount run: | - cmake . -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" - grep "^OpenMP:INTERNAL=1$" CMakeCache.txt + cmake . -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -g" + make -j2 VERBOSE=1 + - name: primecount 1e11 --legendre + run: valgrind ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: valgrind ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: valgrind ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: valgrind ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: valgrind ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: valgrind ./primecount 1e14 --gourdon + - name: primecount 1e14 --status + run: valgrind ./primecount 1e14 --status + + linux_clang: + strategy: + matrix: + platform: ['ubuntu-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} + env: + CC: clang + CXX: clang++ + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt update + sudo apt install libomp-dev asciidoc libxml2-utils xmlto + - name: Build primecount + # POPCNT disabled + Debug + run: | + cmake . -DBUILD_TESTS=ON -DBUILD_MANPAGE=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + grep "^OpenMP.*:INTERNAL=1$" CMakeCache.txt grep "^int128.*:INTERNAL=1$" CMakeCache.txt grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt make -j2 VERBOSE=1 - name: CTest (unit tests) run: ctest -j2 - - name: primecount --test option + - name: primecount --test run: ./primecount --test - - name: Valgrind legendre test - run: valgrind --error-exitcode=1 ./primecount 1e11 --legendre - - name: Valgrind meissel test - run: valgrind --error-exitcode=1 ./primecount 1e12 --meissel - - name: Valgrind lehmer test - run: valgrind --error-exitcode=1 ./primecount 1e11 --lehmer - - name: Valgrind lmo test - run: valgrind --error-exitcode=1 ./primecount 1e12 --lmo - - name: Valgrind deleglise-rivat test - run: valgrind --error-exitcode=1 ./primecount 1e13 --deleglise-rivat - - name: Valgrind gourdon test - run: valgrind --error-exitcode=1 ./primecount 1e14 --gourdon + - name: primecount 1e11 --legendre + run: ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: ./primecount 1e14 --gourdon - linux_clang: - runs-on: ubuntu-latest + macos_clang: + strategy: + matrix: + platform: ['macos-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} env: CC: clang CXX: clang++ steps: - uses: actions/checkout@v3 - name: Install dependencies - run: | - sudo apt update - sudo apt install libomp-dev + run: brew install libomp - name: Build primecount + # POPCNT disabled + Debug run: | - cmake . -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + LDFLAGS="-L$(brew --prefix libomp)/lib" cmake . -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_CXX_FLAGS="-I$(brew --prefix libomp)/include -Wall -Wextra -pedantic -Werror" grep "^OpenMP.*:INTERNAL=1$" CMakeCache.txt grep "^int128.*:INTERNAL=1$" CMakeCache.txt grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt make -j2 VERBOSE=1 - name: CTest (unit tests) run: ctest -j2 - - name: primecount --test option + - name: primecount --test run: ./primecount --test + - name: primecount 1e11 --legendre + run: ./primecount 1e11 --legendre + - name: primecount 1e12 --meissel + run: ./primecount 1e12 --meissel + - name: primecount 1e11 --lehmer + run: ./primecount 1e11 --lehmer + - name: primecount 1e12 --lmo + run: ./primecount 1e12 --lmo + - name: primecount 1e13 --deleglise-rivat + run: ./primecount 1e13 --deleglise-rivat + - name: primecount 1e14 --gourdon + run: ./primecount 1e14 --gourdon linux_128bit: runs-on: ubuntu-latest @@ -110,37 +267,3 @@ jobs: run: | ./primecount 1e20 -s | tee primecount-1e20.log grep 2220819602560918840 primecount-1e20.log - - linux_gcc_performance_test: - runs-on: ubuntu-latest - env: - CC: gcc - CXX: g++ - steps: - - uses: actions/checkout@v3 - with: - # Fetch all commits & tags - fetch-depth: 0 - - name: Install dependencies - run: | - sudo apt update - sudo apt install bc - - name: Benchmark latest code vs. previous release - run: scripts/./benchmark-vs-prev-release.sh - - linux_clang_performance_test: - runs-on: ubuntu-latest - env: - CC: clang - CXX: clang++ - steps: - - uses: actions/checkout@v3 - with: - # Fetch all commits & tags - fetch-depth: 0 - - name: Install dependencies - run: | - sudo apt update - sudo apt install bc libomp-dev - - name: Benchmark latest code vs. previous release - run: scripts/./benchmark-vs-prev-release.sh diff --git a/README.md b/README.md index ad8f1d1c..8881c954 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # primecount -[![Build status](https://github.com/kimwalisch/primecount/actions/workflows/ci.yml/badge.svg)](https://github.com/kimwalisch/primecount/actions/workflows/ci.yml) [![Build Status](https://ci.appveyor.com/api/projects/status/github/kimwalisch/primecount?branch=master&svg=true)](https://ci.appveyor.com/project/kimwalisch/primecount) +[![Build status](https://github.com/kimwalisch/primecount/actions/workflows/ci.yml/badge.svg)](https://github.com/kimwalisch/primecount/actions/workflows/ci.yml) [![Build status](https://github.com/kimwalisch/primecount/actions/workflows/benchmark.yml/badge.svg)](https://github.com/kimwalisch/primecount/actions/workflows/benchmark.yml) [![Github Releases](https://img.shields.io/github/release/kimwalisch/primecount.svg)](https://github.com/kimwalisch/primecount/releases) primecount is a command-line program and [C/C++ library](doc/libprimecount.md) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index f3de3d42..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,187 +0,0 @@ -# Automated testing using appveyor.com -# https://ci.appveyor.com/projects - -version: 1.0.{build} - -image: -- Ubuntu -- Ubuntu2004 -- macos-bigsur -- Visual Studio 2019 - -branches: - except: - - gh-pages - -platform: - - x64 - -configuration: - - Debug - - Release - -for: - - matrix: - only: - - image: Ubuntu - platform: x64 - configuration: Debug - environment: - CFLAGS: "-Wall -Wextra -pedantic -Werror -O1" - CXXFLAGS: "-Wall -Wextra -pedantic -Werror -O1" - build_script: - # POPCNT disabled + Debug - - CXX=g++-7 cmake . -DWITH_POPCNT=OFF -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION - - grep "^OpenMP:INTERNAL=1$" CMakeCache.txt - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^WITH_POPCNT:BOOL=OFF$" CMakeCache.txt - - make -j8 VERBOSE=1 - test_script: - - ctest -j2 - - ./primecount --test - - ./primecount 1e14 --gourdon - - ./primecount 1e12 --nth-prime - - ./primecount 1e12 --meissel - - - matrix: - only: - - image: Ubuntu - platform: x64 - configuration: Release - environment: - CFLAGS: "-Wall -Wextra -pedantic -Werror" - CXXFLAGS: "-Wall -Wextra -pedantic -Werror" - build_script: - # libdivide disabled + Release - - CXX=g++-8 cmake . -DWITH_LIBDIVIDE=OFF -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION -DCMAKE_INSTALL_PREFIX=$(pwd) - - grep "^OpenMP:INTERNAL=1$" CMakeCache.txt - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt - - grep "^WITH_LIBDIVIDE:BOOL=OFF$" CMakeCache.txt - - make -j8 VERBOSE=1 - - make install - test_script: - - ctest -j2 - - ./primecount --test - - - matrix: - only: - - image: Ubuntu2004 - platform: x64 - configuration: Debug - environment: - CFLAGS: "-Wall -Wextra -pedantic -Werror -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" - CXXFLAGS: "-Wall -Wextra -pedantic -Werror -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" - build_script: - # Test with GCC sanitizers - - cmake . -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION - - grep "^OpenMP:INTERNAL=1$" CMakeCache.txt - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt - - make -j8 VERBOSE=1 - test_script: - - ctest -j2 - - ./primecount --test - - ./primecount 1e14 --gourdon - - ./primecount 1e12 --nth-prime - - ./primecount 1e12 --meissel - - - matrix: - only: - - image: Ubuntu2004 - platform: x64 - configuration: Release - environment: - CFLAGS: "-Wall -Wextra -pedantic -Werror" - CXXFLAGS: "-Wall -Wextra -pedantic -Werror" - install: - - sudo dpkg --force-architecture --remove-architecture i386 - - sudo apt-get --allow-releaseinfo-change update - - sudo apt install --fix-broken -y asciidoc libxml2-utils xmlto - build_script: - # Test using old clang-9 & build man page - - CXX=clang++-9 cmake . -DBUILD_TESTS=ON -DBUILD_MANPAGE=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION -DCMAKE_INSTALL_PREFIX=$(pwd) - - grep "^OpenMP.*:INTERNAL=1$" CMakeCache.txt - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt - - make -j8 VERBOSE=1 - - make install - test_script: - - ctest -j2 - - ./primecount --test - - - matrix: - only: - - image: macos-bigsur - platform: x64 - configuration: Debug - environment: - CFLAGS: "-Wall -Wextra -pedantic -Werror -O1 -Wno-long-long" - CXXFLAGS: "-Wall -Wextra -pedantic -Werror -O1 -Wno-long-long" - build_script: - # This test should be without OpenMP - - cmake . -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION -DCMAKE_INSTALL_PREFIX=$(pwd) - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt - - make -j8 VERBOSE=1 - - make install - test_script: - - ctest -j2 - - ./primecount --test - - - matrix: - only: - - image: macos-bigsur - platform: x64 - configuration: Release - environment: - CFLAGS: "-I/usr/local/opt/libomp/include -Wall -Wextra -pedantic -Werror -Wno-long-long" - CXXFLAGS: "-I/usr/local/opt/libomp/include -Wall -Wextra -pedantic -Werror -Wno-long-long" - LDFLAGS: "-L/usr/local/opt/libomp/lib" - install: - - brew install libomp - build_script: - # Test macOS + OpenMP - - cmake . -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$CONFIGURATION -DCMAKE_INSTALL_PREFIX=$(pwd) - - grep "^OpenMP:INTERNAL=1$" CMakeCache.txt - - grep "^int128.*:INTERNAL=1$" CMakeCache.txt - - grep "^cpu_supports_popcnt:INTERNAL=1$" CMakeCache.txt - - make -j8 VERBOSE=1 - - make install - test_script: - - ctest -j2 - - ./primecount --test - - - matrix: - only: - - image: Visual Studio 2019 - platform: x64 - configuration: Debug - environment: - CFLAGS: "/W3 /WX /MP /EHsc /O1" - CXXFLAGS: "/W3 /WX /MP /EHsc /O1" - build_script: - - cmake . -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="/W3 /WX /MP /EHsc /O1" -DCMAKE_BUILD_TYPE=%Configuration% - - findstr /b /e OpenMP:INTERNAL=1 CMakeCache.txt - - cmake --build . --config %Configuration% --target install - test_script: - - ctest -j 2 -C %Configuration% - - cd %Configuration% - - primecount.exe --test - - - matrix: - only: - - image: Visual Studio 2019 - platform: x64 - configuration: Release - environment: - CFLAGS: "/W3 /WX /MP /EHsc" - CXXFLAGS: "/W3 /WX /MP /EHsc" - build_script: - - cmake . -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="/W3 /WX /MP /EHsc" -DCMAKE_BUILD_TYPE=%Configuration% - - findstr /b /e OpenMP:INTERNAL=1 CMakeCache.txt - - cmake --build . --config %Configuration% --target install - test_script: - - ctest -j 2 -C %Configuration% - - cd %Configuration% - - primecount.exe --test diff --git a/lib/primesieve/.github/workflows/ci.yml b/lib/primesieve/.github/workflows/ci.yml index e1c36bed..82c445c9 100644 --- a/lib/primesieve/.github/workflows/ci.yml +++ b/lib/primesieve/.github/workflows/ci.yml @@ -9,79 +9,29 @@ on: - gh-pages jobs: - linux_gcc_sanitizers: - runs-on: ubuntu-latest - env: - CC: gcc - CXX: g++ - steps: - - uses: actions/checkout@v3 - - name: Build primesieve - run: | - cmake . -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror -Wno-long-long -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -Wno-long-long -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" - make -j2 VERBOSE=1 - - name: CTest (unit tests) - run: ctest -j2 - - name: primesieve --test option - run: ./primesieve --test - # Run primesieve binary - - name: primesieve --cpu-info - run: ./primesieve --cpu-info - - name: primesieve 1e10 - run: ./primesieve 1e10 - - name: primesieve 1e9 --nth-prime - run: ./primesieve 1e9 --nth-prime - - name: primesieve --dist=1e9 --size=32 --print=6 - run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 - #Test printing primes and prime k-tuplets - - name: primesieve 1e8 -p | md5sum - run: if [ "$(./primesieve 1e8 -p | md5sum | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi - - name: primesieve 1e8 -p2 | md5sum - run: if [ "$(./primesieve 1e8 -p2 | md5sum | cut -f1 -d' ')" != "5076d235d5b03389034ec107227eab98" ]; then exit 1; fi - - name: primesieve 1e8 -p3 | md5sum - run: if [ "$(./primesieve 1e8 -p3 | md5sum | cut -f1 -d' ')" != "1b40d7e67868ccc857df11c3e0f7e0f5" ]; then exit 1; fi - - name: primesieve 1e8 -p4 | md5sum - run: if [ "$(./primesieve 1e8 -p4 | md5sum | cut -f1 -d' ')" != "b998d7cdbeae6623cdecba1b921cb2e1" ]; then exit 1; fi - - name: primesieve 1e8 -p5 | md5sum - run: if [ "$(./primesieve 1e8 -p5 | md5sum | cut -f1 -d' ')" != "1ec7d5704d7399caf43667090b5bf836" ]; then exit 1; fi - - name: primesieve 1e8 -p6 | md5sum - run: if [ "$(./primesieve 1e8 -p6 | md5sum | cut -f1 -d' ')" != "0fb813d345c94cf2012588d1f71328b5" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p | md5sum | cut -f1 -d' ')" != "5fbe254a97ad3bbc07c224908c9d59b2" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p2 | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p2 | md5sum | cut -f1 -d' ')" != "7a7a770c1841a17a9a63b92b7b6532b9" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p3 | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p3 | md5sum | cut -f1 -d' ')" != "72323b08c62ad8342f7331e3d6d45a64" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p4 | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p4 | md5sum | cut -f1 -d' ')" != "c2b0818499f77aa35681db3826caf3f6" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p5 | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p5 | md5sum | cut -f1 -d' ')" != "11b50e4f75899891a62465f6d68fb76e" ]; then exit 1; fi - - name: primesieve 1e10 -d1e8 -p6 | md5sum - run: if [ "$(./primesieve 1e10 -d1e8 -p6 | md5sum | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi - - linux_gcc_valgrind: - runs-on: ubuntu-latest + linux_gcc: + strategy: + matrix: + platform: ['ubuntu-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} env: CC: gcc CXX: g++ steps: - uses: actions/checkout@v3 - - name: Install valgrind + - name: Install dependencies run: | sudo apt update - sudo apt install valgrind asciidoc libxml2-utils xmlto + sudo apt install asciidoc libxml2-utils xmlto - name: Build primesieve run: | - cmake . -DBUILD_TESTS=ON -DBUILD_MANPAGE=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -g" + cmake . -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBUILD_MANPAGE=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" make -j2 VERBOSE=1 - name: CTest (unit tests) run: ctest -j2 - - name: primesieve --test option + - name: primesieve --test run: ./primesieve --test - - name: Valgrind primesieve count test - run: valgrind --error-exitcode=1 ./primesieve 1e9 - - name: Valgrind primesieve print test - run: valgrind --error-exitcode=1 ./primesieve 10000 --print # Run primesieve binary - name: primesieve --cpu-info run: ./primesieve --cpu-info @@ -91,7 +41,7 @@ jobs: run: ./primesieve 1e9 --nth-prime - name: primesieve --dist=1e9 --size=32 --print=6 run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 - #Test printing primes and prime k-tuplets + # Test printing primes and prime k-tuplets - name: primesieve 1e8 -p | md5sum run: if [ "$(./primesieve 1e8 -p | md5sum | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi - name: primesieve 1e8 -p2 | md5sum @@ -118,7 +68,11 @@ jobs: run: if [ "$(./primesieve 1e10 -d1e8 -p6 | md5sum | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi linux_clang: - runs-on: ubuntu-latest + strategy: + matrix: + platform: ['ubuntu-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} env: CC: clang CXX: clang++ @@ -130,11 +84,11 @@ jobs: sudo apt install libomp-dev - name: Build primesieve run: | - cmake . -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + cmake . -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" make -j2 VERBOSE=1 - name: CTest (unit tests) run: ctest -j2 - - name: primesieve --test option + - name: primesieve --test run: ./primesieve --test # Run primesieve binary - name: primesieve --cpu-info @@ -145,7 +99,7 @@ jobs: run: ./primesieve 1e9 --nth-prime - name: primesieve --dist=1e9 --size=32 --print=6 run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 - #Test printing primes and prime k-tuplets + # Test printing primes and prime k-tuplets - name: primesieve 1e8 -p | md5sum run: if [ "$(./primesieve 1e8 -p | md5sum | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi - name: primesieve 1e8 -p2 | md5sum @@ -172,7 +126,11 @@ jobs: run: if [ "$(./primesieve 1e10 -d1e8 -p6 | md5sum | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi macos_clang: - runs-on: macos-latest + strategy: + matrix: + platform: ['macos-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} env: CC: clang CXX: clang++ @@ -180,12 +138,12 @@ jobs: - uses: actions/checkout@v3 - name: Build primesieve run: | - cmake . -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(pwd) + cmake . -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_INSTALL_PREFIX=$(pwd) -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" make -j2 VERBOSE=1 make install - name: CTest (unit tests) run: ctest -j2 - - name: primesieve --test option + - name: primesieve --test run: ./primesieve --test # Run primesieve binary - name: primesieve --cpu-info @@ -196,7 +154,7 @@ jobs: run: ./primesieve 1e9 --nth-prime - name: primesieve --dist=1e9 --size=32 --print=6 run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 - #Test printing primes and prime k-tuplets + # Test printing primes and prime k-tuplets - name: primesieve 1e8 -p | md5 run: if [ "$(./primesieve 1e8 -p | md5 | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi - name: primesieve 1e8 -p2 | md5 @@ -224,7 +182,11 @@ jobs: # See documentation: https://www.msys2.org/docs/ci/ windows_mingw64: - runs-on: windows-latest + strategy: + matrix: + platform: ['windows-latest'] + config: ['Debug', 'Release'] + runs-on: ${{ matrix.platform }} defaults: run: shell: msys2 {0} @@ -236,16 +198,21 @@ jobs: install: base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake - name: Build primesieve run: | - cmake . -G "Unix Makefiles" -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + cmake . -G "Unix Makefiles" -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=${{matrix.config}} -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" make -j2 VERBOSE=1 - name: CTest (unit tests) run: ctest -j2 - - name: primesieve --test option + - name: primesieve --test run: ./primesieve --test + # Run primesieve binary - name: primesieve --cpu-info run: ./primesieve --cpu-info - - name: primesieve --print - run: ./primesieve 1000 --print + - name: primesieve 1e10 + run: ./primesieve 1e10 + - name: primesieve 1e9 --nth-prime + run: ./primesieve 1e9 --nth-prime + - name: primesieve --dist=1e9 --size=32 --print=6 + run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 windows_msvc2022: runs-on: windows-2022 @@ -253,13 +220,89 @@ jobs: - uses: actions/checkout@v3 - name: Build primesieve run: | - cmake . -G "Visual Studio 17 2022" -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON + cmake . -G "Visual Studio 17 2022" -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="/W3 /WX /MP /EHsc" cmake --build . --config Release --target install - name: CTest (unit tests) run: ctest -j2 -C Release --output-on-failure - - name: primesieve --test option + - name: primesieve --test run: Release\primesieve.exe --test - name: primesieve --cpu-info run: Release\primesieve.exe --cpu-info - name: primesieve --print run: Release\primesieve.exe 1000 --print + + linux_gcc_sanitizers: + runs-on: ubuntu-latest + env: + CC: gcc + CXX: g++ + steps: + - uses: actions/checkout@v3 + - name: Build primesieve + run: | + cmake . -DBUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror -Wno-long-long -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -Wno-long-long -O1 -g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" + make -j2 VERBOSE=1 + - name: CTest (unit tests) + run: ctest -j2 + - name: primesieve --test + run: ./primesieve --test + # Run primesieve binary + - name: primesieve --cpu-info + run: ./primesieve --cpu-info + - name: primesieve 1e10 + run: ./primesieve 1e10 + - name: primesieve 1e9 --nth-prime + run: ./primesieve 1e9 --nth-prime + - name: primesieve --dist=1e9 --size=32 --print=6 + run: ./primesieve 1e13 --dist=1e9 --size=32 --print=6 + # Test printing primes and prime k-tuplets + - name: primesieve 1e8 -p | md5sum + run: if [ "$(./primesieve 1e8 -p | md5sum | cut -f1 -d' ')" != "4e2b0027288a27e9c99699364877c9db" ]; then exit 1; fi + - name: primesieve 1e8 -p2 | md5sum + run: if [ "$(./primesieve 1e8 -p2 | md5sum | cut -f1 -d' ')" != "5076d235d5b03389034ec107227eab98" ]; then exit 1; fi + - name: primesieve 1e8 -p3 | md5sum + run: if [ "$(./primesieve 1e8 -p3 | md5sum | cut -f1 -d' ')" != "1b40d7e67868ccc857df11c3e0f7e0f5" ]; then exit 1; fi + - name: primesieve 1e8 -p4 | md5sum + run: if [ "$(./primesieve 1e8 -p4 | md5sum | cut -f1 -d' ')" != "b998d7cdbeae6623cdecba1b921cb2e1" ]; then exit 1; fi + - name: primesieve 1e8 -p5 | md5sum + run: if [ "$(./primesieve 1e8 -p5 | md5sum | cut -f1 -d' ')" != "1ec7d5704d7399caf43667090b5bf836" ]; then exit 1; fi + - name: primesieve 1e8 -p6 | md5sum + run: if [ "$(./primesieve 1e8 -p6 | md5sum | cut -f1 -d' ')" != "0fb813d345c94cf2012588d1f71328b5" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p | md5sum | cut -f1 -d' ')" != "5fbe254a97ad3bbc07c224908c9d59b2" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p2 | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p2 | md5sum | cut -f1 -d' ')" != "7a7a770c1841a17a9a63b92b7b6532b9" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p3 | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p3 | md5sum | cut -f1 -d' ')" != "72323b08c62ad8342f7331e3d6d45a64" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p4 | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p4 | md5sum | cut -f1 -d' ')" != "c2b0818499f77aa35681db3826caf3f6" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p5 | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p5 | md5sum | cut -f1 -d' ')" != "11b50e4f75899891a62465f6d68fb76e" ]; then exit 1; fi + - name: primesieve 1e10 -d1e8 -p6 | md5sum + run: if [ "$(./primesieve 1e10 -d1e8 -p6 | md5sum | cut -f1 -d' ')" != "5a0bc83fdef0bb116d60f356adfde52f" ]; then exit 1; fi + + linux_gcc_valgrind: + runs-on: ubuntu-latest + env: + CC: gcc + CXX: g++ + steps: + - uses: actions/checkout@v3 + - name: Install valgrind + run: | + sudo apt update + sudo apt install valgrind + - name: Build primesieve + run: | + cmake . -DBUILD_TESTS=ON -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror -g" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -g" + make -j2 VERBOSE=1 + - name: CTest (unit tests) + run: ctest -j2 + - name: primesieve --test + run: ./primesieve --test + - name: Valgrind primesieve --count + run: valgrind --error-exitcode=1 ./primesieve 1e9 + - name: Valgrind primesieve --nth-prime + run: valgrind --error-exitcode=1 ./primesieve 1e7 --nth-prime + - name: Valgrind primesieve --print + run: valgrind --error-exitcode=1 ./primesieve 10000 --print