From dc7754348dc9ce06aad1513581f863c6652308df Mon Sep 17 00:00:00 2001 From: Agnes Leroy Date: Mon, 13 Mar 2023 10:20:03 +0100 Subject: [PATCH] concrete-cuda(ci): first setup for the concrete-cuda ci --- .github/workflows/concrete_cuda_test.yml | 130 +++++++++++++++++++++++ .github/workflows/main.yml | 17 ++- backends/concrete-cuda/clang-format.sh | 8 ++ 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/concrete_cuda_test.yml create mode 100755 backends/concrete-cuda/clang-format.sh diff --git a/.github/workflows/concrete_cuda_test.yml b/.github/workflows/concrete_cuda_test.yml new file mode 100644 index 000000000..9e62b1873 --- /dev/null +++ b/.github/workflows/concrete_cuda_test.yml @@ -0,0 +1,130 @@ +# Compile and test Concrete-cuda on an AWS instance +name: AWS Cuda tests + +on: + workflow_call: + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Set up Clang + run: | + sudo apt-get install clang-format-11 + - name: Format Concrete-cuda + run: | + cd backends/concrete-cuda + ./clang-format.sh + - name: Check diff + run: git diff --exit-code + + start-runner: + name: Start EC2 runner + runs-on: ubuntu-20.04 + outputs: + label: ${{ steps.start-ec2-runner.outputs.label }} + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_IAM_ID }} + aws-secret-access-key: ${{ secrets.AWS_IAM_KEY }} + aws-region: us-east-1 + - name: Start EC2 runner + id: start-ec2-runner + uses: machulav/ec2-github-runner@v2.2.0 + with: + mode: start + github-token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }} + ec2-image-id: ami-0c4d39cb3dba0fcff + ec2-instance-type: p3.2xlarge + subnet-id: subnet-8123c9e7 + security-group-id: sg-0466d33ced960ba35 + + run-cuda-tests-linux: + concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + name: Test code in EC2 + needs: start-runner + runs-on: ${{ needs.start-runner.outputs.label }} + strategy: + fail-fast: false + # explicit include-based build matrix, of known valid options + matrix: + include: + # 20.04 supports CUDA 11.0+ (gcc >= 5 && gcc <= 10). SM < 52 deprecated since 11.0 + - os: ubuntu-20.04 + cuda: "11.3" + cuda_arch: "70" + gcc: 8 + env: + CUDA_PATH: /usr/local/cuda-${{ matrix.cuda }} + + steps: + - uses: actions/checkout@v2 + - name: Export CUDA variables + if: ${{ !cancelled() }} + run: | + echo "CUDA_PATH=$CUDA_PATH" >> "${GITHUB_ENV}" + echo "$CUDA_PATH/bin" >> "${GITHUB_PATH}" + echo "LD_LIBRARY_PATH=$CUDA_PATH/lib:$LD_LIBRARY_PATH" >> "${GITHUB_ENV}" + # Specify the correct host compilers + - name: Export gcc and g++ variables + if: ${{ !cancelled() }} + run: | + echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> "${GITHUB_ENV}" + echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> "${GITHUB_ENV}" + echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> "${GITHUB_ENV}" + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> "${GITHUB_ENV}" + echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}" + - name: Build concrete-cuda + if: ${{ !cancelled() }} + run: | + cd backends/concrete-cuda/implementation + mkdir build + cd build + cmake .. + make -j8 + - name: Test concrete-cuda + if: ${{ !cancelled() }} + run: | + cd backends/concrete-cuda/implementation/build + ./test/test_concrete_cuda + + - name: Slack Notification + if: ${{ always() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_COLOR: ${{ job.status }} + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png + SLACK_MESSAGE: "Cuda AWS tests finished with status ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + stop-runner: + name: Stop EC2 runner + needs: + - start-runner + - run-cuda-tests-linux + runs-on: ubuntu-20.04 + if: ${{ always() && (needs.start-runner.result != 'skipped') }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_IAM_ID }} + aws-secret-access-key: ${{ secrets.AWS_IAM_KEY }} + aws-region: us-east-1 + - name: Stop EC2 runner + uses: machulav/ec2-github-runner@v2.2.0 + with: + mode: stop + github-token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }} + label: ${{ needs.start-runner.outputs.label }} + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0e2f8ccf..d20663ebf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,7 @@ jobs: compiler: ${{ steps.compiler.outputs.any_changed }} optimizer: ${{ steps.optimizer.outputs.any_changed }} concrete-cpu: ${{ steps.concrete-cpu.outputs.any_changed }} + concrete-cuda: ${{ steps.concrete-cuda.outputs.any_changed }} test-all: ${{ steps.test-all.outputs.test-all }} steps: - name: Checkout the repository @@ -51,6 +52,12 @@ jobs: with: files: backends/concrete-cpu + - name: Get changed files in the concrete-cuda directory + id: concrete-cpu + uses: tj-actions/changed-files@7a453ffa2eb31a7e84f3281f88ef6d774c4d807d + with: + files: backends/concrete-cuda + - name: Set the test-all id: test-all if: github.event_name == 'push' && github.ref == 'refs/heads/main' @@ -104,4 +111,12 @@ jobs: needs: file-change if: needs.file-change.outputs.concrete-cpu == 'true' || needs.file-change.outputs.test-all uses: ./.github/workflows/concrete_cpu_test.yml - secrets: inherit \ No newline at end of file + secrets: inherit + +################################################# +# Concrete-cuda jobs ############################ + concrete-cuda: + needs: file-change + if: needs.file-change.outputs.concrete-cuda == 'true' || needs.file-change.outputs.test-all + uses: ./.github/workflows/concrete_cuda_test.yml + secrets: inherit diff --git a/backends/concrete-cuda/clang-format.sh b/backends/concrete-cuda/clang-format.sh new file mode 100755 index 000000000..f1b96db6a --- /dev/null +++ b/backends/concrete-cuda/clang-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +clang-format-11 -i implementation/include/* && + clang-format-11 -i implementation/src/*.cu && + clang-format-11 -i implementation/src/*.cuh && + clang-format-11 -i implementation/src/*/*.* && + clang-format-11 -i implementation/test/*.h && + clang-format-11 -i implementation/test/*.cpp