Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/spack_default_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
# Our repo name contains upper case characters, so we can't use ${{ github.repository }}
IMAGE_NAME: gridkit
USERNAME: gridkit-bot
BASE_VERSION: ubuntu-24.04-fortran-v0.2.13
BASE_VERSION: ubuntu-24.04-fortran-v0.3.0

# Until we remove the need to clone submodules to build, this should on be in PRs
on: [pull_request]
Expand Down Expand Up @@ -99,8 +99,8 @@ jobs:
llvm: ["16"]
# Minimal Build(s) - GHCR mirror speeds these up a lot!
spack_spec:
- gridkit@develop ~asan+enzyme+ipopt~ubsan
- gridkit@develop +asan~enzyme+ipopt+ubsan
- gridkit@develop ~asan+enzyme+ipopt+klu+sundials~ubsan
- gridkit@develop +asan~enzyme+ipopt+klu+sundials+ubsan

steps:
- name: Add LLVM
Expand All @@ -118,7 +118,7 @@ jobs:
submodules: true

- name: Setup Spack
run: echo "$PWD/buildsystem/spack/spack/bin" >> "$GITHUB_PATH"
run: echo "$PWD/buildsystem/spack/bin" >> "$GITHUB_PATH"

- name: Create heredoc spack.yaml
run: |
Expand All @@ -135,7 +135,7 @@ jobs:
padded_length: 128
mirrors:
local-buildcache: oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ env.BASE_VERSION }}
spack: https://binaries.spack.io/v0.23.1
spack: https://binaries.spack.io/v1.0.1
packages:
ipopt:
require: ~coinhsl+mumps
Expand All @@ -158,6 +158,9 @@ jobs:
- name: Find external packages
run: spack -e . external find --all --exclude llvm

- name: Spack add repos
run: spack -e . repo add buildsystem/spack_repo/gridkit

- name: Spack develop gridkit
run: spack -e . develop --path=$(pwd) gridkit@develop

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
.vscode/
*.DS_Store
build/
*.DS_Store
*.swp
doxygen-docs/
__pycache__
7 changes: 3 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[submodule "buildsystem/spack/spack"]
path = buildsystem/spack/spack
url = https://github.com/nkoukpaizan/spack.git
branch = Gridkit-package-dev+enzyme
[submodule "third-party/nlohmann-json"]
path = third-party/nlohmann-json
url = https://github.com/nlohmann/json
[submodule "third-party/magic-enum"]
path = third-party/magic-enum
url = https://github.com/Neargye/magic_enum
[submodule "buildsystem/spack"]
path = buildsystem/spack
url = https://github.com/spack/spack.git
21 changes: 21 additions & 0 deletions buildsystem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
One way to build GridKit and its dependencies is by using Spack.
We include Spack as a submodule to the Gridkit repository and use it for our CI builds.
For more information on how to use Spack, please refer to their [documentation](https://spack-tutorial.readthedocs.io/en/latest).

Example steps to build using Spack with an environment created on the fly:
```
git submodule update --init buildsystem/spack
source ./buildsystem/spack/share/spack/setup-env.sh
spack env create gridkit
spack env activate -p gridkit
spack repo add buildsystem/spack_repo/gridkit
spack develop --path=$(pwd) gridkit@develop
spack compiler find
spack add gridkit+enzyme+ipopt+klu+sundials
spack concretize -f
spack install
spack env deactivate
```

As GridKit matures, we plan to expand on this build approach and provide Spack
configurations for different systems of interest.
1 change: 1 addition & 0 deletions buildsystem/spack
Submodule spack added at 17d342
1 change: 0 additions & 1 deletion buildsystem/spack/spack
Submodule spack deleted from ba17e3
59 changes: 59 additions & 0 deletions buildsystem/spack_repo/gridkit/packages/gridkit/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack_repo.builtin.build_systems.cmake import CMakePackage
from spack.package import *

class Gridkit(CMakePackage):
"""Experimental code for prototyping interfaces betwen numerical libraries and network models."""

homepage = "https://github.com/ORNL/GridKit"
git = "https://github.com/ORNL/GridKit.git"

maintainers("nkoukpaizan", "pelesh")

version("develop", submodules=True, branch="develop")

variant("asan", default=False, description="Enable/Disable address sanitizer")
variant("enzyme", default=False, description="Enable/Disable Enzyme")
variant("ipopt", default=False, description="Enable/Disable Ipopt")
variant("klu", default=False, description="Enable/Disable KLU")
variant("sundials", default=False, description="Enable/Disable SUNDIALS")
variant("ubsan", default=False, description="Enable/Disable undefined behavir sanitizer")

conflicts("+klu", when="~sundials")

depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build")

depends_on("enzyme", when="+enzyme")
depends_on("ipopt", when="+ipopt")
depends_on("sundials@7:+klu~mpi", when="+sundials+klu")
depends_on("sundials@7:~klu~mpi", when="+sundials~klu")

def cmake_args(self):
args = []
spec = self.spec

args.extend(
[
self.define_from_variant("GRIDKIT_ENABLE_IPOPT", "ipopt"),
self.define_from_variant("GRIDKIT_ENABLE_SUNDIALS", "sundials"),
self.define_from_variant("GRIDKIT_ENABLE_SUNDIALS_SPARSE", "klu"),
self.define_from_variant("GRIDKIT_ENABLE_ENZYME", "enzyme"),
self.define_from_variant("GRIDKIT_ENABLE_ASAN", "asan"),
self.define_from_variant("GRIDKIT_ENABLE_UBSAN", "ubsan"),
]
)

if self.spec.satisfies("+enzyme"):
args.extend(
[
self.define("CMAKE_C_COMPILER", f"{self.spec['llvm'].prefix}/bin/clang"),
self.define("CMAKE_CXX_COMPILER", f"{self.spec['llvm'].prefix}/bin/clang++"),
]
)

return args
3 changes: 3 additions & 0 deletions buildsystem/spack_repo/gridkit/repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
repo:
namespace: 'gridkit'
api: v2.2
Loading