Skip to content

Commit

Permalink
Merge pull request #11 from CExA-project/refactor_exercises
Browse files Browse the repository at this point in the history
Refactor exercises
  • Loading branch information
pzehner authored Jan 13, 2025
2 parents 9fc4590 + c2319d4 commit eba2f9a
Show file tree
Hide file tree
Showing 62 changed files with 1,140 additions and 676 deletions.
110 changes: 22 additions & 88 deletions .github/workflows/exercises.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,104 +5,38 @@

name: Test exercises

run-name: Test exercises

on:
push:
paths:
- 'exercises/**'
pull_request:
branches:
- '**'
- main
paths:
- 'exercises/**'

jobs:

# changes:
# runs-on: ubuntu-latest
# outputs:
# exercises_changed: ${{ steps.filter.outputs.exercises }}
# steps:
# - uses: actions/checkout@v4
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# exercises:
# - 'exercises/02_first_program/**'
# - 'exercises/03_basic_view/**'
# - 'exercises/04_deep_copy/**'
# - 'exercises/05_parallel_loop/**'
# - 'exercises/06_parallel_reduce/**'

build_kokkos:
runs-on: ubuntu-latest
# needs: [changes]
# if: ${{ github.event_name == 'pull_request' || needs.changes.outputs.exercises_changed == 'true' }}
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Install Kokkos
run: |
git clone https://github.com/kokkos/kokkos.git
cd kokkos
git checkout develop
mkdir build_openmp
mkdir install_openmp
cmake -B build_openmp -DCMAKE_INSTALL_PREFIX=${PWD}/install_openmp -DKokkos_ENABLE_OPENMP=ON ./
make install -C build_openmp
- name: Upload Kokkos artifact
uses: actions/upload-artifact@v4
with:
name: kokkos
path: kokkos/install_openmp

build_exercises:
build_test_exercises:
runs-on: ubuntu-latest
needs: [build_kokkos]
# if: ${{ github.event_name == 'pull_request' || needs.changes.outputs.exercises == 'true' }}
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: Download Kokkos artifact
uses: actions/download-artifact@v4
with:
name: kokkos
path: kokkos/install_openmp
- name: Compile 02_first_program
run: |
cd exercises/02_first_program/solution/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/kokkos/install_openmp/ ./
make
bash execute.sh
cd ${GITHUB_WORKSPACE}
- name: Compile 03_basic_view
run: |
cd exercises/03_basic_view/solution/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/kokkos/install_openmp/ ./
make
bash execute.sh
cd ${GITHUB_WORKSPACE}
- name: Compile 04_deep_copy
- name: Prepare all exercices and solutions with the OpenMP backend
run: |
cd exercises/04_deep_copy/solution/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/kokkos/install_openmp/ ./
make
bash execute.sh
cd ${GITHUB_WORKSPACE}
- name: Compile 05_parallel_loop
cmake \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DKokkos_ENABLE_OPENMP=ON \
exercises
- name: Build all exercises and solutions
run: |
cd exercises/05_parallel_loop/solution/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/kokkos/install_openmp/ ./
make
bash execute.sh
cd ${GITHUB_WORKSPACE}
- name: Compile 06_parallel_reduce
cmake \
--build build \
--parallel $(($(nproc) * 2 + 1))
- name: Test all solutions
env:
OMP_PROC_BIND: spread
OMP_PLACES: threads
OMP_NUM_THREADS: 2
run: |
cd exercises/06_parallel_reduce/solution/
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/kokkos/install_openmp/ ./
make
bash execute.sh
cd ${GITHUB_WORKSPACE}


ctest \
--test-dir build \
--output-on-failure
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "exercises/vendor/kokkos"]
path = exercises/vendor/kokkos
url = https://github.com/kokkos/kokkos
branch = master
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing to the tutorials

## Add a new exercise

### Exercise structure

```
new_exercise/
+-- exercise/
| +-- CMakeLists.txt
| +-- main.cpp
+-- solution/
| +-- CMakeLists.txt
| +-- main.cpp
+-- CMakeLists.txt
+-- README.md
```

### Testing

Exercises should be tested in the CI.
To do so, edit `exercises/CMakeLists.txt` to append your exercise directory with `add_subdirectory`:

```cmake
add_subdirectory(my_exercise)
```

In your `solution/CMakeLists.txt`, add your solution target as a test.

```cmake
add_test(
NAME my_exercise
COMMAND my_exercise
)
```

The new exercise will be automatically built and tested by the CI.
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
# Kokkos-cexa-tutorial
# CExA Kokkos Tutorials

![CI](https://github.com/CExA-project/cexa-kokkos-tutorials/actions/workflows/courses.yml/badge.svg)
![CI](https://github.com/CExA-project/cexa-kokkos-tutorials/actions/workflows/exercises.yml/badge.svg)
![CI](https://github.com/CExA-project/cexa-kokkos-tutorials/actions/workflows/projects.yml/badge.svg)

This repository contains tutorials, exercises, and projects to learn Kokkos.
This course is intended for beginners and intermediate users not experts in C++ and GPU programming.
This course is intended for beginners and intermediate users who are not expert in C++ and GPU programming.
This course is part of the [CExA project](https://cexa-project.github.io/).

<p align="center">
<img src="./images/kokkos.png" alt="Kokkos" width="100"/>
<img src="./images/cexa_logo.png" alt="CExA" width="100"/>
</p>

## Courses
## Content

- [Introduction to Kokkos](courses/01_beginners/README.md)
### Courses

> **Important:** You can get the slides from the [releases](https://github.com/CExA-project/cexa-kokkos-tutorials/releases) page.
- [Course 1: Introduction to Kokkos](courses/01_beginners/README.md)

## Exercises
> [!NOTE]
> You can get the slides from the [releases](https://github.com/CExA-project/cexa-kokkos-tutorials/releases) page.
- [Exercise 1: Compiling Kokkos](exercises/01_compiling_kokkos/README.md)
- [Exercise 2: First Kokkos Program](exercises/02_first_program/README.md)
- [Exercise 3: Learn how to use and manage basic Kokkos View](exercises/03_basic_view/README.md)
- [Exercise 4: Mirror view and deep copy](exercises/04_deep_copy/README.md)
- [Exercise 5: Parallel Loop](exercises/05_parallel_loop/README.md)
- [Exercise 6: Parallel Reduce](exercises/06_parallel_reduce/README.md)
### Exercises

## Projects
- [Exercise 1: First Kokkos Program](exercises/02_first_program/README.md)
- [Exercise 2: Learn how to use and manage basic Kokkos View](exercises/03_basic_view/README.md)
- [Exercise 3: Mirror view and deep copy](exercises/04_deep_copy/README.md)
- [Exercise 4: Parallel Loop](exercises/05_parallel_loop/README.md)
- [Exercise 5: Parallel Reduce](exercises/06_parallel_reduce/README.md)

### Projects

- [Project 1: Wave Propagation](projects/wave/README.md)

## Get the repository

To get the repository, clone it recursively:

```sh
git clone --recurse-submodules https://github.com/CExA-project/cexa-kokkos-tutorials.git
```
5 changes: 5 additions & 0 deletions courses/01_beginners/beamerthemecexa-kokkos.sty
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
\awesomelink{github}{#1}%
}

% Documentation links
\newcommand{\doclink}[1]{%
\awesomelink{book}{#1}%
}

% Highlight
\newcommand{\highlight}[1]{\structure{\textbf{#1}}}

Expand Down
Loading

0 comments on commit eba2f9a

Please sign in to comment.