Skip to content

Commit

Permalink
Add limited PR testing (#101)
Browse files Browse the repository at this point in the history
* Add CPU-only PR tests

* ci: modify script to add exercise 04 for CUDA

* ci: add windows build

* ci: CUDA

* ci: Enable more exercises for Linux/macOS builds

* ci: Add kokkos-kernels builds for Linux/macOs

* ci: unix: install OpenMPI

* ci: cuda: disable tasking

* ci: unix: mpi

* mpi_exch, mpi_heat_conduction: link MPI target

* ci: remove windows-specific thing from unix build

* ci: condution -> conduction

* ci: mpi_heat_conduction requires cuda

* ci: mpi_exch/Begin does not exist

* ci: heat3d -> mpi_exch

* ci: cuda don't build virtualfunction

* Remove `-DKokkos_ENABLE_COMPILER_WARNINGS=ON`

Co-authored-by: Damien L-G <[email protected]>

---------

Co-authored-by: Damien L-G <[email protected]>
  • Loading branch information
cwpearson and dalg24 authored Dec 17, 2024
1 parent fb2fe4c commit 6a2d511
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/github-pr-linux-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Hosted Runners (linux, CUDA)

on:
push:
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container: nvidia/cuda:12.6.2-devel-ubuntu22.04
steps:
- name: Install Packages
run: >
apt-get update && apt-get install
-y --no-install-suggests --no-install-recommends
cmake openmpi-bin libopenmpi-dev
- name: Checkout Kokkos Tutorials
uses: actions/checkout@v4
with:
path: kokkos-tutorials

- name: Checkout Kokkos
uses: actions/checkout@v4
with:
repository: 'kokkos/kokkos'
ref: master
path: kokkos

- name: Checkout Kokkos Kernels
uses: actions/checkout@v4
with:
repository: 'kokkos/kokkos-kernels'
ref: master
path: kokkos-kernels

- name: Configure Kokkos
run: >
cmake -S "${GITHUB_WORKSPACE}"/kokkos -B "${GITHUB_WORKSPACE}"/build-kokkos
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}"/install-kokkos
-DCMAKE_CXX_COMPILER="${GITHUB_WORKSPACE}"/kokkos/bin/nvcc_wrapper
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DKokkos_ENABLE_CUDA=ON
-DKokkos_ARCH_AMPERE80=ON
- name: Build & Install Kokkos
run: cmake --build "${GITHUB_WORKSPACE}"/build-kokkos --config RelWithDebInfo --parallel 2 --target install

- name: Configure Kokkos Kernels
run: >
cmake -S "${GITHUB_WORKSPACE}"/kokkos-kernels -B "${GITHUB_WORKSPACE}"/build-kokkos-kernels
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}"/install-kokkos-kernels
-DCMAKE_CXX_COMPILER="${GITHUB_WORKSPACE}"/kokkos/bin/nvcc_wrapper
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DKokkos_ROOT="${GITHUB_WORKSPACE}"/install-kokkos
- name: Build & Install Kokkos Kernels
run: cmake --build "${GITHUB_WORKSPACE}"/build-kokkos-kernels --config RelWithDebInfo --parallel 2 --target install

- name: Configure and Build Exercises
run: |
bash "${GITHUB_WORKSPACE}"/kokkos-tutorials/Scripts/ci-configure-build-test.sh \
"${GITHUB_WORKSPACE}"/install-kokkos/lib/cmake/Kokkos \
"${GITHUB_WORKSPACE}"/install-kokkos-kernels \
"${GITHUB_WORKSPACE}"/kokkos-tutorials \
"${GITHUB_WORKSPACE}"/kokkos/bin/nvcc_wrapper \
RelWithDebInfo \
CUDA
86 changes: 86 additions & 0 deletions .github/workflows/github-pr-unix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Hosted Runners (unix)

on:
push:
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
cpp_compiler: g++
build_type: RelWithDebInfo
backend: OPENMP
- os: macos-latest
cpp_compiler: clang++
build_type: Debug
backend: THREADS

steps:
- name: Install Packages
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y --no-install-suggests --no-install-recommends openmpi-bin libopenmpi-dev
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install open-mpi
fi
shell: bash

- name: Checkout Kokkos Tutorials
uses: actions/checkout@v4
with:
path: kokkos-tutorials

- name: Checkout Kokkos
uses: actions/checkout@v4
with:
repository: 'kokkos/kokkos'
ref: master
path: kokkos

- name: Checkout Kokkos Kernels
uses: actions/checkout@v4
with:
repository: 'kokkos/kokkos-kernels'
ref: master
path: kokkos-kernels

- name: Configure Kokkos
run: >
cmake -S "${GITHUB_WORKSPACE}"/kokkos -B "${GITHUB_WORKSPACE}"/build-kokkos
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}"/install-kokkos
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DKokkos_ENABLE_COMPILER_WARNINGS=ON
- name: Build & Install Kokkos
run: cmake --build "${GITHUB_WORKSPACE}"/build-kokkos --config ${{ matrix.build_type }} --parallel 2 --target install

- name: Configure Kokkos Kernels
run: >
cmake -S "${GITHUB_WORKSPACE}"/kokkos-kernels -B "${GITHUB_WORKSPACE}"/build-kokkos-kernels
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}"/install-kokkos-kernels
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DKokkos_ROOT="${GITHUB_WORKSPACE}"/install-kokkos
- name: Build & Install Kokkos Kernels
run: cmake --build "${GITHUB_WORKSPACE}"/build-kokkos-kernels --config ${{ matrix.build_type }} --parallel 2 --target install

- name: Configure and Build Exercises
run: |
bash "${GITHUB_WORKSPACE}"/kokkos-tutorials/Scripts/ci-configure-build-test.sh \
"${GITHUB_WORKSPACE}"/install-kokkos/lib/cmake/Kokkos \
"${GITHUB_WORKSPACE}"/install-kokkos-kernels \
"${GITHUB_WORKSPACE}"/kokkos-tutorials \
${{ matrix.cpp_compiler}} \
${{ matrix.build_type}} \
${{ matrix.backend }}
54 changes: 54 additions & 0 deletions .github/workflows/github-pr-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Hosted Runners (windows)

on:
push:
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
cpp_compiler: cl
build_type: Release
backend: SERIAL

steps:
- name: Checkout Kokkos Tutorials
uses: actions/checkout@v4
with:
path: kokkos-tutorials

- name: Checkout Kokkos
uses: actions/checkout@v4
with:
repository: 'kokkos/kokkos'
ref: master
path: kokkos

- name: Configure Kokkos
run: >
cmake -S ${{ github.workspace}}\kokkos -B ${{ github.workspace}}\build-kokkos
-DCMAKE_INSTALL_PREFIX=${{ github.workspace}}\install-kokkos
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build & Install Kokkos
run: cmake --build ${{ github.workspace}}\build-kokkos --config ${{ matrix.build_type }} --parallel 2 --target install

- name: Configure and Build Exercises
run: |
${{ github.workspace}}\kokkos-tutorials\Scripts\ci-configure-build-test.bat ^
${{ github.workspace}}\install-kokkos\lib\cmake\Kokkos ^
${{ github.workspace}}\kokkos-tutorials ^
${{ matrix.cpp_compiler}} ^
${{ matrix.build_type}} ^
${{ matrix.backend }}
shell: cmd

1 change: 1 addition & 0 deletions Exercises/mpi_exch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ find_package(MPI REQUIRED)

add_executable(mpi_exch mpi_exch.cpp)
target_link_libraries(mpi_exch Kokkos::kokkos)
target_link_libraries(mpi_exch MPI::MPI_CXX)
1 change: 1 addition & 0 deletions Exercises/mpi_heat_conduction/Solution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ find_package(MPI REQUIRED)

add_executable(heat3d mpi_heat_conduction_solution.cpp)
target_link_libraries(heat3d Kokkos::kokkos)
target_link_libraries(heat3d MPI::MPI_CXX)
32 changes: 32 additions & 0 deletions Scripts/ci-configure-build-test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
setlocal EnableDelayedExpansion

if "%~5"=="" (
echo Usage: build.bat kokkos_root tutorials_src cpp_compiler build_type backend
exit /b 1
)

set kokkos_root=%~1
set tutorials_src=%~2
set cpp_compiler=%~3
set build_type=%~4
set backend=%~5

set "EXERCISES=01 02 03"
if "%backend%"=="CUDA" set "EXERCISES=%EXERCISES% 04"

set Kokkos_ROOT=%kokkos_root%
mkdir build 2>nul

for %%e in (%EXERCISES%) do (
for %%k in (Begin Solution) do (
set "source_dir=%tutorials_src%\Exercises\%%e\%%k"
set "build_dir=build\Exercises\%%e\%%k"
echo building !source_dir!
cmake -S "!source_dir!" -B "!build_dir!" ^
-DCMAKE_CXX_COMPILER="%cpp_compiler%" ^
-DCMAKE_BUILD_TYPE="%build_type%"

cmake --build "!build_dir!" --config "%build_type%"
)
)
95 changes: 95 additions & 0 deletions Scripts/ci-configure-build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#! /bin/bash

set -eou pipefail

kokkos_root="$1"
kernels_root="$2"
tutorials_src="$3"
cpp_compiler="$4"
build_type="$5"
backend="$6"

# These are exercises with CMakeLists.txt in Begin and Solution subdirectories
# TODO: advanced_reductions seems broken
# TODO: hpcbind does not use cmake
# TODO: instances does not use cmake
# TODO: parallel_scan seems broken
# TODO: simd_warp seems broken
# TODO: subview seems broken
# TODO: vectorshift needs Kokkos Remote Spaces
# TODO: kokkoskernels/CGSolve_SpILUKprecond needs to know where Kokkos Kernels source directory is
# TODO: kokkoskernels/SpILUK needs to know where Kokkos Kernels source directory is
# TODO: kokkoskernels/TeamGemm seems broken
# TODO: mpi_heat_conduction/no-mpi does not use cmake
BEGIN_SOLUTION_EXERCISES=(
01
02
03
dualview
kokkoskernels/BlockJacobi
kokkoskernels/GaussSeidel
kokkoskernels/GraphColoring
kokkoskernels/InnerProduct
mdrange
mpi_pack_unpack
random_number
scatter_view
simd
team_policy
team_scratch_memory
team_vector_loop
unordered_map
)

if [ "$backend" == CUDA ]; then
BEGIN_SOLUTION_EXERCISES+=(04)
BEGIN_SOLUTION_EXERCISES+=(multi_gpu_cuda)
fi


if [ ! "$backend" == CUDA ]; then
BEGIN_SOLUTION_EXERCISES+=(tasking) # tasking doesn't seem to work on CUDA
BEGIN_SOLUTION_EXERCISES+=(virtualfunction) # TODO: virtualfunction needs Kokkos with CUDA RDC
fi

if [ "$backend" == OPENMP ]; then
BEGIN_SOLUTIONS_EXERCISES+=(unique_token)
fi

# no fortran on macOs
if [[ ! "$OSTYPE" == "darwin"* ]]; then
BEGIN_SOLUTIONS_EXERCISES+=(fortran-kokkosinterface)
fi

# These are exercises with CMakeLists.txt in the root directory
EXERCISES=(
kokkoskernels/CGSolve/Solution # Begin does not include the proper headers (on purpose) so it can't be compiled
kokkoskernels/SpGEMM/Solution # Begin does not include the proper headers (on purpose) so it can't be compiled
mpi_exch
tools_minimd
)

# TODO: explicitly specifies CUDA
if [ "$backend" == CUDA ]; then
EXERCISES+=(mpi_heat_conduction/Solution) # TODO: mpi_heat_conduction/Begin does not use cmake
fi

# Add Begin and Solution subdirectory from BEGIN_SOLUTION_EXCERCISES to EXERCISES
for e in "${BEGIN_SOLUTION_EXERCISES[@]}"; do
EXERCISES+=("$e"/Begin)
EXERCISES+=("$e"/Solution)
done

export Kokkos_ROOT="$kokkos_root"
mkdir -p build
for e in "${EXERCISES[@]}"; do
source_dir="$tutorials_src"/Exercises/"$e"
build_dir=build/Exercises/"$e"
echo building "$source_dir"
cmake -S "$source_dir" -B "$build_dir" \
-DCMAKE_CXX_COMPILER="$cpp_compiler" \
-DCMAKE_BUILD_TYPE="$build_type" \
-DKokkosKernels_ROOT="$kernels_root"

cmake --build "$build_dir"
done

0 comments on commit 6a2d511

Please sign in to comment.