From 6f81fd4e905b0c243d9a9b730ba4333d2413ab53 Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 11:06:13 -0800 Subject: [PATCH 1/9] Testing new github ci --- .github/workflows/github-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index b84b3be..1d3839c 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -9,19 +9,25 @@ on: branches: - main - development - - "[0-9]+.[0-9]+.[0-9]+" + - ipcl_v"[0-9]+.[0-9]+.[0-9]+" push: branches: - main - development - - "[0-9]+.[0-9]+.[0-9]+" + - ipcl_v"[0-9]+.[0-9]+.[0-9]+" # Manually run this workflow on any specified branch. workflow_dispatch: -############## -# IceLake CI # -############## +################### +# Define env vars # +################### +env: + IPCL_VER: 2.0.0 + IPCL_DIR: ${GITHUB_WORKSPACE}/install + IPCL_HINT_DIR: > + -DIPCL_HINT_DIR=${GITHUB_WORKSPACE}/install/lib/cmake/ipcl-${IPCL_VER} + jobs: format: name: Format check @@ -40,8 +46,6 @@ jobs: name: Build, test and run kernels - shared needs: [format] runs-on: [self-hosted, linux, x64, icx] - # Use environment protection (require review) - environment: intel_workflow defaults: run: shell: bash From 45cdbe1f60cca2e68a966fc5c3a628727b7a4ef0 Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 12:20:22 -0800 Subject: [PATCH 2/9] Updated branches regex --- .github/workflows/github-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 1d3839c..7baf8ee 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -9,12 +9,12 @@ on: branches: - main - development - - ipcl_v"[0-9]+.[0-9]+.[0-9]+" + - "ipcl_v[0-9]+.[0-9]+.[0-9]+" push: branches: - main - development - - ipcl_v"[0-9]+.[0-9]+.[0-9]+" + - "ipcl_v[0-9]+.[0-9]+.[0-9]+" # Manually run this workflow on any specified branch. workflow_dispatch: From 4baae45d6d80bf1a4377c5a1963c752ff7c9b6cd Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:28:26 -0800 Subject: [PATCH 3/9] Refactor CI/CD process --- .github/workflows/github-ci.yml | 160 ++++++++++++++++++++-------- example/CMakeLists.txt | 6 ++ example/example_add_mul.cpp | 6 ++ example/example_encrypt_decrypt.cpp | 5 + example/example_hybridmode.cpp | 5 + 5 files changed, 138 insertions(+), 44 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 7baf8ee..af3d8bc 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -24,9 +24,9 @@ on: ################### env: IPCL_VER: 2.0.0 - IPCL_DIR: ${GITHUB_WORKSPACE}/install + IPCL_DIR: ${GITHUB_WORKSPACE}/ipcl_install IPCL_HINT_DIR: > - -DIPCL_HINT_DIR=${GITHUB_WORKSPACE}/install/lib/cmake/ipcl-${IPCL_VER} + -DIPCL_HINT_DIR=${GITHUB_WORKSPACE}/ipcl_install/lib/cmake/ipcl-${IPCL_VER} jobs: format: @@ -43,67 +43,139 @@ jobs: run: pre-commit run --all-files build-and-test: - name: Build, test and run kernels - shared + name: '${{ matrix.build_type }} qat=${{ matrix.enable_qat }} detect_cpu_runtime=${{ matrix.detect_cpu_runtime }} shared=${{ matrix.shared_lib }}' needs: [format] runs-on: [self-hosted, linux, x64, icx] defaults: run: shell: bash - working-directory: . + strategy: + matrix: + build_type: [Release, Debug] + shared_lib: [ON, OFF] + detect_cpu_runtime: [ON, OFF] + # qat disabled for ICX - to be added with SPR runner + enable_qat: [OFF] + include: + # run minimum for debug mode + - build_type: Debug + benchmark_min_time: "--benchmark_min_time=0.001" + - build_type: Release + benchmark_min_time: "" steps: - uses: actions/checkout@v2 - - name: Validate paths + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.16.x' + - name: Build the library run: | + set -x + export CC=clang-10 + export CXX=clang++-10 + + # Validate paths whoami echo $HOME echo $GITHUB_WORKSPACE echo "Testing from branch:" echo $GITHUB_REF + cmake --version pwd - # Build library - - name: Build the repository - run: | - cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DIPCL_ENABLE_QAT=ON - cmake --build build --target all -j - - # Unit tests and examples - - name: Run the unit tests - run: ./build/test/unittest_ipcl + # Build library + # QAT unavailable in ICX - to be added + cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \ + -DIPCL_DETECT_CPU_RUNTIME=${{ matrix.detect_cpu_runtime }} \ + -DIPCL_ENABLE_QAT=${{ matrix.enable_qat }} \ + -DCMAKE_INSTALL_PREFIX= ./ipcl_install + cmake --build build -j$(nproc) + cmake --build build --target install - - name: Run the benchmarks - run: ./build/benchmark/bench_ipcl + - name: Run unittest + run: | + cmake --build build --target unittest - build-and-test-static: - name: Build, test and run kernels - static - needs: [format] - runs-on: [self-hosted, linux, x64, icx] - # Use environment protection (require review) - environment: intel_workflow - defaults: - run: - shell: bash - working-directory: . - steps: - - uses: actions/checkout@v2 - - name: Validate paths + - name: Run benchmark run: | - whoami - echo $HOME - echo $GITHUB_WORKSPACE - echo "Testing from branch:" - echo $GITHUB_REF - pwd + ./build/benchmark/bench_ipcl \ + --benchmark_out="${GITHUB_WORKFLOW}_${GITHUB_SHA}" \ + --benchmark_out_format=csv ${{ matrix.benchmark_min_time }} - # Build library - - name: Build the repository + - name: Build and run examples run: | - cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DIPCL_ENABLE_QAT=ON -DIPCL_SHARED=OFF - cmake --build build --target all -j + cd $GITHUB_WORKSPACE/example + cmake -S . -B build ${{ env.IPCL_DIR }} + cmake --build build + cmake --build build --target run_all_examples + + - name: Archive benchmark results + uses: actions/upload-artifactory@v2 + with: + name: bench_ipcl_${{ github.sha }}.csv + path: ${{ github.workspace }}/${{ github.workflow }}_${{ github.sha }} + retention-days: 90 + + + # name: Build, test and run kernels - shared + # needs: [format] + # runs-on: [self-hosted, linux, x64, icx] + # defaults: + # run: + # shell: bash + # working-directory: . + # steps: + # - uses: actions/checkout@v2 + # - name: Validate paths + # run: | + # whoami + # echo $HOME + # echo $GITHUB_WORKSPACE + # echo "Testing from branch:" + # echo $GITHUB_REF + # pwd + + # # Build library + # - name: Build the repository + # run: | + # cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DIPCL_ENABLE_QAT=ON + # cmake --build build --target all -j + + # # Unit tests and examples + # - name: Run the unit tests + # run: ./build/test/unittest_ipcl + + # - name: Run the benchmarks + # run: ./build/benchmark/bench_ipcl + + # build-and-test-static: + # name: Build, test and run kernels - static + # needs: [format] + # runs-on: [self-hosted, linux, x64, icx] + # defaults: + # run: + # shell: bash + # working-directory: . + # steps: + # - uses: actions/checkout@v2 + # - name: Validate paths + # run: | + # whoami + # echo $HOME + # echo $GITHUB_WORKSPACE + # echo "Testing from branch:" + # echo $GITHUB_REF + # pwd + + # # Build library + # - name: Build the repository + # run: | + # cmake -S . -B build -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DIPCL_ENABLE_QAT=ON -DIPCL_SHARED=OFF + # cmake --build build --target all -j - # Unit tests and examples - - name: Run the unit tests - run: ./build/test/unittest_ipcl + # # Unit tests and examples + # - name: Run the unit tests + # run: ./build/test/unittest_ipcl - - name: Run the benchmarks - run: ./build/benchmark/bench_ipcl + # - name: Run the benchmarks + # run: ./build/benchmark/bench_ipcl diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 9e2de3a..67fe74a 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -12,7 +12,13 @@ set(CMAKE_CXX_EXTENSIONS OFF) find_package(IPCL 2.0.0 REQUIRED HINTS ${IPCL_HINT_DIR}) set(examples encrypt_decrypt add_mul hybridmode) + +add_custom_target(run_all_examples) + foreach(ex IN LISTS examples) add_executable(example_${ex} example_${ex}.cpp) target_link_libraries(example_${ex} PRIVATE IPCL::ipcl) + add_custom_command(TARGET run_all_examples POST_BUILD + COMMAND $) + add_dependencies(run_all_examples example_${ex}) endforeach() diff --git a/example/example_add_mul.cpp b/example/example_add_mul.cpp index 6d9ec22..d53a61f 100644 --- a/example/example_add_mul.cpp +++ b/example/example_add_mul.cpp @@ -12,6 +12,11 @@ #include "ipcl/ipcl.hpp" int main() { + std::cout << std::endl; + std::cout << "==============================================" << std::endl; + std::cout << "Example: Addition and Multiplication with IPCL" << std::endl; + std::cout << "==============================================" << std::endl; + ipcl::initializeContext("QAT"); const uint32_t num_total = 20; @@ -97,4 +102,5 @@ int main() { delete key.pub_key; delete key.priv_key; ipcl::terminateContext(); + std::cout << "Complete!" << std::endl; } diff --git a/example/example_encrypt_decrypt.cpp b/example/example_encrypt_decrypt.cpp index e8c0c7e..a9e23b8 100644 --- a/example/example_encrypt_decrypt.cpp +++ b/example/example_encrypt_decrypt.cpp @@ -12,6 +12,11 @@ #include "ipcl/ipcl.hpp" int main() { + std::cout << std::endl; + std::cout << "======================================" << std::endl; + std::cout << "Example: Encrypt and Decrypt with IPCL" << std::endl; + std::cout << "======================================" << std::endl; + ipcl::initializeContext("QAT"); const uint32_t num_total = 20; diff --git a/example/example_hybridmode.cpp b/example/example_hybridmode.cpp index 4feaa1e..12973db 100644 --- a/example/example_hybridmode.cpp +++ b/example/example_hybridmode.cpp @@ -19,6 +19,11 @@ typedef std::chrono::high_resolution_clock::time_point tVar; std::chrono::duration_cast(tNow() - t).count() int main() { + std::cout << std::endl; + std::cout << "===================================" << std::endl; + std::cout << "Example: Hybrid Mode usage with QAT" << std::endl; + std::cout << "===================================" << std::endl; + ipcl::initializeContext("QAT"); tVar t; double elapsed(0.); From 17998a0e72420ed34442fbfb3e73d96dcea7f40f Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:30:02 -0800 Subject: [PATCH 4/9] Fix typo - artifact --- .github/workflows/github-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index af3d8bc..6544ba2 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -110,7 +110,7 @@ jobs: cmake --build build --target run_all_examples - name: Archive benchmark results - uses: actions/upload-artifactory@v2 + uses: actions/upload-artifact@v2 with: name: bench_ipcl_${{ github.sha }}.csv path: ${{ github.workspace }}/${{ github.workflow }}_${{ github.sha }} From 7463674ff75f0398b975e2af7d9b0f893b8d7505 Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:31:59 -0800 Subject: [PATCH 5/9] Fix typo --- .github/workflows/github-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 6544ba2..2f1a6fd 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -88,7 +88,7 @@ jobs: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \ -DIPCL_DETECT_CPU_RUNTIME=${{ matrix.detect_cpu_runtime }} \ -DIPCL_ENABLE_QAT=${{ matrix.enable_qat }} \ - -DCMAKE_INSTALL_PREFIX= ./ipcl_install + -DCMAKE_INSTALL_PREFIX=./ipcl_install cmake --build build -j$(nproc) cmake --build build --target install From 919a7f3d33252cd62f025b904827159e67db027a Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:36:40 -0800 Subject: [PATCH 6/9] Added IPCL_DIR hint location --- .github/workflows/github-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index 2f1a6fd..d9b5dfe 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -24,7 +24,8 @@ on: ################### env: IPCL_VER: 2.0.0 - IPCL_DIR: ${GITHUB_WORKSPACE}/ipcl_install + IPCL_DIR: > + -DIPCL_DIR=${GITHUB_WORKSPACE}/ipcl_install IPCL_HINT_DIR: > -DIPCL_HINT_DIR=${GITHUB_WORKSPACE}/ipcl_install/lib/cmake/ipcl-${IPCL_VER} From 354b8d8bb30267ab9185a148ef5b3a01127cc76a Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:41:30 -0800 Subject: [PATCH 7/9] Separate env validation and build --- .github/workflows/github-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index d9b5dfe..b0c5b4a 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -69,7 +69,7 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.16.x' - - name: Build the library + - name: Validate environment run: | set -x export CC=clang-10 @@ -84,7 +84,8 @@ jobs: cmake --version pwd - # Build library + - name: Build library + run: | # QAT unavailable in ICX - to be added cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \ -DIPCL_DETECT_CPU_RUNTIME=${{ matrix.detect_cpu_runtime }} \ From ec3d477beeefdc0cdf22feb412d127605193c689 Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:44:47 -0800 Subject: [PATCH 8/9] Updated cmake build to use IPCL_HINT_DIR --- .github/workflows/github-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index b0c5b4a..ee5e9c0 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -24,8 +24,7 @@ on: ################### env: IPCL_VER: 2.0.0 - IPCL_DIR: > - -DIPCL_DIR=${GITHUB_WORKSPACE}/ipcl_install + IPCL_DIR: ${GITHUB_WORKSPACE}/ipcl_install IPCL_HINT_DIR: > -DIPCL_HINT_DIR=${GITHUB_WORKSPACE}/ipcl_install/lib/cmake/ipcl-${IPCL_VER} @@ -107,7 +106,7 @@ jobs: - name: Build and run examples run: | cd $GITHUB_WORKSPACE/example - cmake -S . -B build ${{ env.IPCL_DIR }} + cmake -S . -B build ${{ env.IPCL_HINT_DIR }} cmake --build build cmake --build build --target run_all_examples From 275ac5d054f59ba10923b868c82ea64c199998c1 Mon Sep 17 00:00:00 2001 From: sejunkim Date: Fri, 18 Nov 2022 14:48:53 -0800 Subject: [PATCH 9/9] Cleanup examples --- example/example_encrypt_decrypt.cpp | 1 + example/example_hybridmode.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/example/example_encrypt_decrypt.cpp b/example/example_encrypt_decrypt.cpp index a9e23b8..50f08c9 100644 --- a/example/example_encrypt_decrypt.cpp +++ b/example/example_encrypt_decrypt.cpp @@ -57,4 +57,5 @@ int main() { delete key.pub_key; delete key.priv_key; ipcl::terminateContext(); + std::cout << "Complete!" << std::endl << std::endl; } diff --git a/example/example_hybridmode.cpp b/example/example_hybridmode.cpp index 12973db..66da0e5 100644 --- a/example/example_hybridmode.cpp +++ b/example/example_hybridmode.cpp @@ -98,4 +98,5 @@ int main() { delete key.pub_key; delete key.priv_key; ipcl::terminateContext(); + std::cout << "Complete!" << std::endl << std::endl; }