Skip to content

Commit

Permalink
hello(world): initial action and CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
romintomasetti committed May 15, 2024
1 parent 6b38969 commit 57365e6
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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)
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io

jobs:

set-env:
runs-on: [ubuntu-22.04]
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-env]
runs-on: [ubuntu-22.04]
container:
image: docker:latest
permissions:
packages: write
steps:
- name: Checkout code.
uses: actions/checkout@v4

- name: Log in to Docker registry.
run : |
docker login -u ${{ github.actor}} -p ${{ secrets.GITHUB_TOKEN }} ${{ env.REGISTRY }}
- name: Build Docker image.
run : |
apk add jq
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-env.outputs.CI_IMAGE }} \
--cache-from ${{ needs.set-env.outputs.CI_IMAGE }} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg GOOGLETEST_VERSION=${GOOGLETEST_VERSION} \
--build-arg KOKKOS_VERSION=${KOKKOS_VERSION} \
--build-arg KOKKOS_PRESET=OpenMP \
.
build-library:
needs: [set-env, build-image]
runs-on: [ubuntu-22.04]
container:
image: ${{ needs.set-env.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: [build-library]
runs-on: [ubuntu-22.04]
steps:
- name: Checkout code.
uses: actions/checkout@v4

- name: Upload Pages artifacts.
uses: actions/upload-pages-artifact@v3
path: README.md

- name: Deploy to GitHub Pages.
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore CMake build directory
build*/*
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 KOKKOS_VERSION GET "${VERSION_JSON}" "dependencies" "kokkos" "value")
string(JSON GOOGLETEST_VERSION GET "${VERSION_JSON}" "dependencies" "googletest" "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
REQUIRED
${KOKKOS_VERSION}
)

#---- Find google Test.
find_package(
GTest
CONFIG
REQUIRED
${GOOGLETEST_VERSION}
)
23 changes: 23 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# kokkos-utils
This repository contains utilities related to `Kokkos`.

This repository contains utilities related to [`Kokkos`](https://kokkos.org/).
74 changes: 74 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM ubuntu:24.04 as apt-requirements

# Install APT requirements.
RUN --mount=target=/requirements,type=bind,source=requirements <<EOF

set -ex

apt update

apt --yes --no-install-recommends install $(grep -vE "^\s*#" /requirements/requirements.system.txt | tr "\n" " ")

apt clean && rm -rf /var/lib/apt/lists/*

EOF

# Compile Google Test.
FROM apt-requirements as compile-google-test

ARG GOOGLETEST_VERSION

RUN <<EOF

set -ex

git clone --depth=1 --branch=v${GOOGLETEST_VERSION} https://github.com/google/googletest googletest

cd googletest

cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/opt/google-test-${GOOGLETEST_VERSION}

cmake --build build

cmake --build build --target install

EOF

# Compile Kokkos.
FROM apt-requirements as compile-kokkos

ARG KOKKOS_VERSION
ARG KOKKOS_PRESET

COPY kokkos.cmake.presets.json /kokkos.cmake.presets.json

RUN <<EOF

set -ex

git clone --depth=1 --branch=${KOKKOS_VERSION} https://github.com/kokkos/kokkos kokkos

cd kokkos

cp /kokkos.cmake.presets.json CMakePresets.json

cmake -S . --preset=${KOKKOS_PRESET} -DCMAKE_INSTALL_PREFIX=/opt/kokkos-${KOKKOS_VERSION}/${KOKKOS_PRESET}

cmake --build --preset=${KOKKOS_PRESET}

cmake --build --preset=${KOKKOS_PRESET} --target=install

EOF

# Build the final image from previous stages.
FROM apt-requirements as final

ARG GOOGLETEST_VERSION
ARG KOKKOS_VERSION
ARG KOKKOS_PRESET

COPY --from=compile-google-test /opt/google-test-${GOOGLETEST_VERSION} /opt/google-test-${GOOGLETEST_VERSION}
COPY --from=compile-kokkos /opt/kokkos-${KOKKOS_VERSION}/${KOKKOS_PRESET} /opt/kokkos-${KOKKOS_VERSION}/${KOKKOS_PRESET}

ENV GTest_ROOT=/opt/google-test-${GOOGLETEST_VERSION}
ENV Kokkos_ROOT=/opt/kokkos-${KOKKOS_VERSION}/${KOKKOS_PRESET}
28 changes: 28 additions & 0 deletions kokkos.cmake.presets.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
13 changes: 13 additions & 0 deletions requirements/requirements.system.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Utilities
wget

# Source control
ca-certificates
git

# Builders
cmake
make

# Compilers
g++
13 changes: 13 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"kokkos-utils" : {
"value" : "0.0.1"
},
"dependencies" : {
"kokkos" : {
"value" : "4.3.00"
},
"googletest" : {
"value" : "1.14.0"
}
}
}

0 comments on commit 57365e6

Please sign in to comment.