Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudhan/ci integration test #8

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
83 changes: 83 additions & 0 deletions .github/actions/set-build-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "Setup Build Environment"
description: ""

inputs:
os:
description: "matrix.cases.os"
required: true
cuda-version:
description: "matrix.cases.cuda-version"
required: true
source:
description: "matrix.cases.source"
required: true
toolchain:
description: "matrix.cases.toolchain"
required: false
toolchain-version:
description: "matrix.cases.toolchain-version"
required: false

runs:
using: "composite"
steps:
- name: Install CUDA (NVIDIA, Linux)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'nvidia' }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]'
method: network
- name: Show bin, include, lib (NVIDIA, Linux)
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'nvidia' }}
shell: bash
run: |
tree ${CUDA_PATH}/bin
tree ${CUDA_PATH}/include
tree ${CUDA_PATH}/lib64
- name: Install LLVM ${{ inputs.toolchain-version }}
if: ${{ !startsWith(inputs.os, 'windows') && inputs.toolchain == 'llvm' }}
shell: bash
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ inputs.toolchain-version }}
sudo ln -sf /usr/bin/clang-${{ inputs.toolchain-version }} /usr/bin/clang
clang --version
- name: Install CURAND For LLVM
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.os, 'windows') && inputs.toolchain == 'llvm' }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]' # avoid full cuda install
non-cuda-sub-packages: '["libcurand-dev"]'
method: network
- name: Install CUDA (Ubuntu)
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'ubuntu' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-dev=${{ inputs.cuda-version }} nvidia-cuda-toolkit=${{ inputs.cuda-version }} gcc-9 g++-9
export CC=gcc-9
export CXX=g++-9
echo "CC=gcc-9" >> $GITHUB_ENV
echo "CXX=g++-9" >> $GITHUB_ENV

- name: Install CUDA (Windows)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ startsWith(inputs.os, 'windows') }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart"]'
method: network
- name: Show bin, include, lib64 (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
shell: pwsh
run: |
tree /F $env:CUDA_PATH/bin
tree /F $env:CUDA_PATH/include
tree /F $env:CUDA_PATH/lib/x64
- name: Set Visual Studio Environment (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
shell: pwsh
run: .github/actions/Set-VSEnv.ps1 2019
64 changes: 10 additions & 54 deletions .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
pull_request:
# pull_request:

jobs:
test:
Expand Down Expand Up @@ -41,65 +41,21 @@ jobs:
path: ~/.cache/bazel
key: bazel-${{ matrix.cases.os }}-cuda-${{ matrix.cases.cuda-version }}-${{ hashFiles('.bazelversion') }}

- name: Install CUDA (NVIDIA, Linux)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'nvidia' }}
- name: Setup build environment
uses: ./.github/actions/set-build-env
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]'
method: network
- name: Show bin, include, lib (NVIDIA, Linux)
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'nvidia' }}
run: |
tree ${CUDA_PATH}/bin
tree ${CUDA_PATH}/include
tree ${CUDA_PATH}/lib64
- name: Install LLVM ${{ matrix.cases.toolchain-version }}
os: ${{ matrix.cases.os }}
cuda-version: ${{ matrix.cases.cuda-version }}
source: ${{ matrix.cases.source }}
toolchain: ${{ matrix.cases.toolchain }}
toolchain-version: ${{ matrix.cases.toolchain-version }}

- name: Bazel build config for LLVM
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.cases.toolchain-version }}
sudo ln -sf /usr/bin/clang-${{ matrix.cases.toolchain-version }} /usr/bin/clang
clang --version

echo "build --config=clang" > $HOME/.bazelrc
echo "build:clang --@rules_cuda//cuda:archs=sm_80" >> $HOME/.bazelrc
echo "build:clang --spawn_strategy=local" >> $HOME/.bazelrc
- name: Install CURAND For LLVM
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]' # avoid full cuda install
non-cuda-sub-packages: '["libcurand-dev"]'
method: network
- name: Install CUDA (Ubuntu)
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'ubuntu' }}
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-dev=${{ matrix.cases.cuda-version }} nvidia-cuda-toolkit=${{ matrix.cases.cuda-version }} gcc-9 g++-9
export CC=gcc-9
export CXX=g++-9
echo "CC=gcc-9" >> $GITHUB_ENV
echo "CXX=g++-9" >> $GITHUB_ENV

- name: Install CUDA (Windows)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ startsWith(matrix.cases.os, 'windows') }}
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart"]'
method: network
- name: Show bin, include, lib64 (Windows)
if: ${{ startsWith(matrix.cases.os, 'windows') }}
run: |
tree /F $env:CUDA_PATH/bin
tree /F $env:CUDA_PATH/include
tree /F $env:CUDA_PATH/lib/x64
- name: Set Visual Studio Environment (Windows)
if: ${{ startsWith(matrix.cases.os, 'windows') }}
run: .github/workflows/Set-VSEnv.ps1 2019

- run: bazelisk build @rules_cuda_examples//basic:all
- run: bazelisk build @rules_cuda_examples//rdc:all
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Generate docs

on:
pull_request:
branches:
- main
# pull_request:
# branches:
# - main
push:
branches:
- main
Expand Down
165 changes: 165 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: Integration Build

on:
workflow_dispatch:
issue_comment:
types: [created]

jobs:
test-manual:
name: "Integration Test Build (Manual)"
if: github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.cases.os }}
timeout-minutes: 60
strategy:
matrix:
cases:
- {
os: "ubuntu-20.04",
cuda-version: "11.6.2",
source: "nvidia",
toolchain: "nvcc",
}
- {
os: "ubuntu-20.04",
cuda-version: "11.6.2",
source: "nvidia",
toolchain: "llvm",
toolchain-version: "16",
}
steps:
- uses: actions/checkout@v3

- uses: bazelbuild/setup-bazelisk@v2
- name: Mount bazel cache
if: ${{ !startsWith(matrix.cases.os, 'windows') }}
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: ${{ matrix.cases.toolchain }}-${{ matrix.cases.toolchain-version }}

- name: Setup build environment
uses: ./.github/actions/set-build-env
with:
os: ${{ matrix.cases.os }}
cuda-version: ${{ matrix.cases.cuda-version }}
source: ${{ matrix.cases.source }}
toolchain: ${{ matrix.cases.toolchain }}
toolchain-version: ${{ matrix.cases.toolchain-version }}

- name: Bazel build config for LLVM
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
run: |
echo "build --config=clang" > $HOME/.bazelrc
echo "build:clang --cxxopt=--cuda-gpu-arch=sm_80 >> $HOME/.bazelrc"

- run: cd examples && bazelisk build --verbose_failures --spawn_strategy=local --cuda_archs='compute_80,sm_80' @rules_cuda_examples//nccl:perf_binaries

- run: bazelisk shutdown

# based on https://dev.to/zirkelc/trigger-github-workflow-for-comment-on-pull-request-45l2
pre-test-comment:
name: "Integration Test Build - Set commit status pending"
if: github.event.issue.pull_request && contains(github.event.comment.body, '/test')
runs-on: ubuntu-latest
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- name: Set commit status as pending
uses: myrotvorets/set-commit-status-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.comment-branch.outputs.head_sha }}
status: pending

test-comment:
name: "Integration Test Build (CUDA ${{ matrix.cases.cuda-version }} on ${{ matrix.cases.os }})"
needs: [pre-test-comment]
runs-on: ${{ matrix.cases.os }}
timeout-minutes: 60
strategy:
matrix:
cases:
- {
os: "ubuntu-20.04",
cuda-version: "11.6.2",
source: "nvidia",
toolchain: "nvcc",
}
- {
os: "ubuntu-20.04",
cuda-version: "11.6.2",
source: "nvidia",
toolchain: "llvm",
toolchain-version: "16",
}
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}

- uses: bazelbuild/setup-bazelisk@v2
- name: Mount bazel cache
if: ${{ !startsWith(matrix.cases.os, 'windows') }}
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: ${{ matrix.cases.toolchain }}-${{ matrix.cases.toolchain-version }}

- name: Setup build environment
uses: ./.github/actions/set-build-env
with:
os: ${{ matrix.cases.os }}
cuda-version: ${{ matrix.cases.cuda-version }}
source: ${{ matrix.cases.source }}
toolchain: ${{ matrix.cases.toolchain }}
toolchain-version: ${{ matrix.cases.toolchain-version }}

- name: Bazel build config for LLVM
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
run: |
echo "build --config=clang" > $HOME/.bazelrc
echo "build:clang --cxxopt=--cuda-gpu-arch=sm_80 >> $HOME/.bazelrc"

- run: cd examples && bazelisk build --verbose_failures --spawn_strategy=local --cuda_archs='compute_80,sm_80' @rules_cuda_examples//nccl:perf_binaries

- run: bazelisk shutdown

post-test-comment:
name: "Integration Test Build - Set commit status as test result"
needs: [test-comment]
runs-on: ubuntu-latest
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch

- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}

- name: Add comment to PR
uses: actions/github-script@v6
if: always()
with:
script: |
const name = '${{ github.workflow }}';
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const success = '${{ job.status }}' === 'success';
const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`;

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
pull_request:
# pull_request:

jobs:
pre-commit:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/utilities-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
pull_request:
# pull_request:

jobs:
test:
Expand Down
6 changes: 3 additions & 3 deletions cuda/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ def rules_cuda_dependencies(toolkit_path = None):
maybe(
name = "bazel_skylib",
repo_rule = http_archive,
sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
],
)

Expand Down
13 changes: 9 additions & 4 deletions cuda/private/rules/cuda_objects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ def _cuda_objects_impl(ctx):
for src in ctx.attr.srcs:
src_files.extend(src[DefaultInfo].files.to_list())

transitive_objects = depset(transitive = [dep[CudaInfo].objects for dep in attr.deps if CudaInfo in dep])
transitive_rdc_objects = depset(transitive = [dep[CudaInfo].rdc_objects for dep in attr.deps if CudaInfo in dep])
transitive_pic_objects = depset(transitive = [dep[CudaInfo].pic_objects for dep in attr.deps if CudaInfo in dep])
transitive_rdc_pic_objects = depset(transitive = [dep[CudaInfo].rdc_pic_objects for dep in attr.deps if CudaInfo in dep])

# outputs
objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = False, rdc = False))
rdc_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = False, rdc = True))
pic_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = True, rdc = False))
rdc_pic_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = True, rdc = True))
objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = False, rdc = False), transitive = [transitive_objects])
rdc_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = False, rdc = True), transitive = [transitive_rdc_objects])
pic_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = True, rdc = False), transitive = [transitive_pic_objects])
rdc_pic_objects = depset(compile(ctx, cuda_toolchain, cc_toolchain, src_files, common, pic = True, rdc = True), transitive = [transitive_rdc_pic_objects])

compilation_ctx = cc_common.create_compilation_context(
headers = common.headers,
Expand Down
Loading
Loading