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 14, 2024
1 parent 6b38969 commit de39291
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"image" : "ghcr.io/uliegecsm/kokkos-utils/kokkos-utils:latest",
"extensions" : [
"ms-vscode.cmake-tools",
"mhutchie.git-graph"
],
"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)
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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 : |
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-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 . -B build
cmake --build build
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*/*
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0)

project(
kokkos-utils
VERSION 0.0.1
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)
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/).
45 changes: 45 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu:24.04 as requirements

# Install 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 Kokkos.
FROM requirements as compile-kokkos

ARG KOKKOS_VERSION=4.3.00
ARG KOKKOS_PRESET=OpenMP

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

# Get the installed Kokkos files.
FROM compile-kokkos

COPY --from=compile-kokkos /opt/kokkos-${KOKKOS_VERSION}-${KOKKOS_PRESET} /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"
}
]
}
10 changes: 10 additions & 0 deletions requirements/requirements.system.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Source control
ca-certificates
git

# Builders
cmake
make

# Compilers
g++

0 comments on commit de39291

Please sign in to comment.