From 0400187f05d9b9cd3198b68eb72780cb2e983e83 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Sat, 20 Jun 2020 19:46:30 +0200 Subject: [PATCH] Use GMP and GNU parallel in GIthub Actions (#63) * Use GMP and GNU parallel in GIthub Actions * try gmp:i386 * Don't do GMP tests on i386 --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++----------- constantine.nimble | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eaec97..6122022 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,11 +60,11 @@ jobs: with: path: constantine - # - name: Install dependencies (Linux amd64) - # if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' - # run: | - # sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ - # --no-install-recommends -yq + - name: Install dependencies (Linux amd64) + if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' + run: | + sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ + --no-install-recommends -yq libgmp-dev - name: Install dependencies (Linux i386) if: runner.os == 'Linux' && matrix.target.cpu == 'i386' @@ -73,7 +73,7 @@ jobs: sudo apt-fast update -qq sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ --no-install-recommends -yq gcc-multilib g++-multilib \ - libssl-dev:i386 + libssl-dev:i386 libgmp-dev:i386 mkdir -p external/bin cat << EOF > external/bin/gcc #!/bin/bash @@ -85,9 +85,10 @@ jobs: EOF chmod 755 external/bin/gcc external/bin/g++ echo '::add-path::${{ github.workspace }}/external/bin' - # - name: Install dependencies (macOS) - # if: runner.os == 'macOS' - # run: brew install + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: brew install gmp - name: Install dependencies (Windows) if: runner.os == 'Windows' @@ -105,6 +106,10 @@ jobs: 7z x external/windeps.zip -oexternal/dlls echo '::add-path::${{ github.workspace }}'"/external/mingw$arch/bin" echo '::add-path::${{ github.workspace }}'"/external/dlls" + + choco install msys2 + pacman -S mingw-w64-x86_64-gmp + - name: Setup environment shell: bash run: echo '::add-path::${{ github.workspace }}/nim/bin' @@ -192,8 +197,17 @@ jobs: run: | nimble refresh nimble install -y gmp stew - - name: Run constantine tests (without GMP) + - name: Run Constantine tests (with GMP) + if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.target.cpu == 'amd64' shell: bash run: | + export UCPU="$cpu" cd constantine - nimble test_no_gmp + nimble test_parallel + - name: Run Constantine tests (without GMP) + if: runner.os == 'Linux' && matrix.target.cpu == 'i386' + shell: bash + run: | + export UCPU="$cpu" + cd constantine + nimble test_parallel_no_gmp diff --git a/constantine.nimble b/constantine.nimble index 79da9b0..be1147a 100644 --- a/constantine.nimble +++ b/constantine.nimble @@ -206,6 +206,47 @@ task test_parallel, "Run all tests in parallel (via GNU parallel)": runBench("bench_ec_g1") runBench("bench_ec_g2") +task test_parallel_no_gmp, "Run all tests in parallel (via GNU parallel)": + # -d:testingCurves is configured in a *.nim.cfg for convenience + let cmdFile = true # open(buildParallel, mode = fmWrite) # Nimscript doesn't support IO :/ + exec "> " & buildParallel + + for td in testDesc: + if not td.useGMP: + if td.path in useDebug: + test "-d:debugConstantine", td.path, cmdFile + else: + test "", td.path, cmdFile + + # cmdFile.close() + # Execute everything in parallel with GNU parallel + exec "parallel --keep-order --group < " & buildParallel + + exec "> " & buildParallel + if sizeof(int) == 8: # 32-bit tests on 64-bit arch + for td in testDesc: + if not td.useGMP: + if td.path in useDebug: + test "-d:Constantine32 -d:debugConstantine", td.path, cmdFile + else: + test "-d:Constantine32", td.path, cmdFile + # cmdFile.close() + # Execute everything in parallel with GNU parallel + exec "parallel --keep-order --group < " & buildParallel + + # Now run the benchmarks + # + # Benchmarks compile and run + # ignore Windows 32-bit for the moment + # Ensure benchmarks stay relevant. Ignore Windows 32-bit at the moment + if not defined(windows) or not (existsEnv"UCPU" or getEnv"UCPU" == "i686"): + runBench("bench_fp") + runBench("bench_fp2") + runBench("bench_fp6") + runBench("bench_fp12") + runBench("bench_ec_g1") + runBench("bench_ec_g2") + task bench_fp, "Run benchmark 𝔽p with your default compiler": runBench("bench_fp")