diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a401dc5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,9 @@ +{ + "image" : "ghcr.io/uliegecsm/kokkos-utils/kokkos-utils:latest", + "extensions" : [ + "ms-vscode.cmake-tools", + "mhutchie.git-graph", + "ms-azuretools.vscode-docker" + ], + "onCreateCommand": "git config --global --add safe.directory $PWD" +} diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..183721a --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ +## Summary + +(Summarize the content of the PR concisely) + +## Description + +(A longer description of the PR) + +## Related to + +(A list of issues, PRs, links) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0036340 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,124 @@ +name: Build + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +env: + REGISTRY: ghcr.io + +jobs: + + set-vars: + runs-on: [ubuntu-latest] + outputs: + CI_IMAGE : ${{ steps.common.outputs.CI_IMAGE }} + steps: + - name: Export common variables. + id : common + run : | + echo "CI_IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/kokkos-utils:latest" >> $GITHUB_OUTPUT + + build-image: + needs: [set-vars] + runs-on: [ubuntu-latest] + container: + image: docker:latest + permissions: + packages: write + steps: + - name: Checkout code. + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry. + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image. + run : | + apk add jq + + DOXYGEN_VERSION=$(jq .dependencies.doxygen.value version.json -j) + GOOGLETEST_VERSION=$(jq .dependencies.googletest.value version.json -j) + KOKKOS_VERSION=$(jq .dependencies.kokkos.value version.json -j) + + docker buildx build \ + --pull \ + --push \ + --file dockerfile \ + --platform linux/amd64 \ + --tag ${{ needs.set-vars.outputs.CI_IMAGE }} \ + --cache-from ${{ needs.set-vars.outputs.CI_IMAGE }} \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg DOXYGEN_VERSION=${DOXYGEN_VERSION} \ + --build-arg GOOGLETEST_VERSION=${GOOGLETEST_VERSION} \ + --build-arg KOKKOS_VERSION=${KOKKOS_VERSION} \ + --build-arg KOKKOS_PRESET=OpenMP \ + --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ + . + + build-library: + needs: [set-vars, build-image] + runs-on: [ubuntu-latest] + container: + image: ${{ needs.set-vars.outputs.CI_IMAGE }} + steps: + - name: Checkout code. + uses: actions/checkout@v4 + + - name: Configure and build. + run : | + cmake -S . --preset=OpenMP + cmake --build --preset=OpenMP + + build-documentation: + needs: [set-vars, build-image] + runs-on: [ubuntu-latest] + container: + image: ${{ needs.set-vars.outputs.CI_IMAGE }} + steps: + - name: Checkout code. + uses: actions/checkout@v4 + + - name: Build Doxygen documentation. + run : | + cmake -S . --preset=OpenMP + cmake --build --preset=OpenMP --target=docs + + - name: Upload Pages artifacts. + uses: actions/upload-pages-artifact@v3 + with: + path: build-with-OpenMP/docs/html + + # The deploy job is heavily inspired from https://github.com/actions/deploy-pages. + deploy: + # The deployment only happens if the library can be built and the documentation generated. + needs: [build-library, build-documentation] + runs-on: [ubuntu-latest] + + # The deployment only happens for 'main' or 'develop' branch. + if: ${{ contains(fromJSON('["refs/heads/main", "refs/heads/develop"]'), github.ref) }} + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages. + id : deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2d887a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Ignore CMake build directory +build*/* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2457e48 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.12) + +#---- Read the version file. +file(READ version.json VERSION_JSON) + +string(JSON KOKKOS_UTILS_VERSION GET "${VERSION_JSON}" "kokkos-utils" "value") + +string(JSON DOXYGEN_VERSION GET "${VERSION_JSON}" dependencies doxygen value) +string(JSON GOOGLETEST_VERSION GET "${VERSION_JSON}" dependencies googletest value) +string(JSON KOKKOS_VERSION GET "${VERSION_JSON}" dependencies kokkos value) + +#---- Define the project. It uses C++ only. +project( + kokkos-utils + VERSION ${KOKKOS_UTILS_VERSION} + LANGUAGES CXX +) + +#---- C++ standard that we need (at least). +set(CMAKE_CXX_STANDARD 20 CACHE BOOL "" FORCE) +set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "" FORCE) + +#---- Find Kokkos. +find_package( + Kokkos + ${KOKKOS_VERSION} + REQUIRED +) + +#---- Find Google Test. +find_package( + GTest + ${GOOGLETEST_VERSION} + CONFIG + REQUIRED +) + +#---- Documentation. +add_subdirectory(docs) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..a110241 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,23 @@ +{ + "version" : 3, + "configurePresets" : [ + { + "name" : "default", + "binaryDir" : "${sourceDir}/build-with-${presetName}", + "cacheVariables" : { + "CMAKE_BUILD_TYPE" : "Release", + "CMAKE_CXX_EXTENSIONS" : "OFF" + } + }, + { + "name" : "OpenMP", + "inherits" : "default" + } + ], + "buildPresets" : [ + { + "name" : "OpenMP", + "configurePreset" : "OpenMP" + } + ] +} diff --git a/README.md b/README.md index eff7290..66af447 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # kokkos-utils -This repository contains utilities related to `Kokkos`. + +This repository contains utilities related to [`Kokkos`](https://kokkos.org/). + +Our documentation is available [here](https://uliegecsm.github.io/kokkos-utils/). diff --git a/cmake/presets/kokkos.json b/cmake/presets/kokkos.json new file mode 100644 index 0000000..2bff284 --- /dev/null +++ b/cmake/presets/kokkos.json @@ -0,0 +1,28 @@ +{ + "version" : 3, + "configurePresets" : [ + { + "name" : "default", + "binaryDir" : "${sourceDir}/build-with-${presetName}", + "cacheVariables" : { + "CMAKE_BUILD_TYPE" : "Release", + "CMAKE_CXX_STANDARD" : "17", + "CMAKE_CXX_EXTENSIONS" : "OFF", + "BUILD_SHARED_LIBS" : "ON" + } + }, + { + "name" : "OpenMP", + "inherits" : "default", + "cacheVariables" : { + "Kokkos_ENABLE_OPENMP" : "ON" + } + } + ], + "buildPresets" : [ + { + "name" : "OpenMP", + "configurePreset" : "OpenMP" + } + ] +} diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..dc3a949 --- /dev/null +++ b/dockerfile @@ -0,0 +1,100 @@ +FROM ubuntu:24.04 as apt-requirements + +# Install APT requirements. +RUN --mount=target=/requirements,type=bind,source=requirements <