Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI updates: IntelLLVM & Spack #28

Merged
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
78 changes: 78 additions & 0 deletions .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Intel
on:
push:
branches:
- develop
pull_request:
branches:
- develop

# Use custom shell with -l so .bash_profile is sourced which loads intel/oneapi/setvars.sh
# without having to do it in manually every step
defaults:
run:
shell: bash -leo pipefail {0}

jobs:
Intel:
runs-on: ubuntu-latest
strategy:
matrix:
compilers: ["CC=icc FC=ifort", "CC=icx FC=ifx"]

steps:

# See https://software.intel.com/content/www/us/en/develop/articles/oneapi-repo-instructions.html
- name: install-intel
run: |
cd /tmp
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
sudo apt-get install intel-oneapi-dev-utilities intel-oneapi-mpi-devel intel-oneapi-openmp intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile

- name: checkout-pfunit
uses: actions/checkout@v2
with:
repository: Goddard-Fortran-Ecosystem/pFUnit
path: pfunit

- name: cache-pfunit
id: cache-pfunit
uses: actions/cache@v2
with:
path: ~/pfunit
key: pfunit-${{ runner.os }}-${{ matrix.compilers }}

- name: build-pfunit
if: steps.cache-pfunit.outputs.cache-hit != 'true'
run: |
cd pfunit
mkdir build
cd build
${{ matrix.compilers }} cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit -DCMAKE_BUILD_TYPE=Release
make -j2 VERBOSE=1
make install

- name: checkout
uses: actions/checkout@v4
with:
path: gfsio
submodules: true

- name: build
run: |
cd gfsio
mkdir build
cd build
${{ matrix.compilers }} cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit"
make -j2 VERBOSE=1

- name: test
run: |
cd $GITHUB_WORKSPACE/gfsio/build
make test VERBOSE=1

68 changes: 68 additions & 0 deletions .github/workflows/Spack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This is a CI workflow for the NCEPLIBS-gfsio project.
#
# This workflow builds gfsio with Spack, including installing with the "--test
# root" option to run the pFunit test. It also has a one-off job that validates
# the recipe by ensuring that every CMake option that should be set in the
# Spack recipe is so set.
#
# Alex Richert, Sep 2023
name: Spack
on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
Spack:
strategy:
matrix:
os: ["ubuntu-latest"]

runs-on: ${{ matrix.os }}

steps:

- name: checkout-gfsio
uses: actions/checkout@v4
with:
path: gfsio

- name: spack-build-and-test
run: |
git clone -c feature.manyFiles=true https://github.com/jcsda/spack
. spack/share/spack/setup-env.sh
spack env create gfsio-env
spack env activate gfsio-env
cp $GITHUB_WORKSPACE/gfsio/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/gfsio/package.py
spack develop --no-clone --path $GITHUB_WORKSPACE/gfsio gfsio@develop
spack add gfsio@develop%gcc@11 +pfunit
spack external find cmake gmake m4 python
spack concretize
# Run installation and run pFunit testing
spack install --verbose --fail-fast --test root
# Run 'spack load' to check for obvious errors in setup_run_environment
spack load gfsio
ls $GFSIO_LIB
ls $GFSIO_LIB4

# This job validates the Spack recipe by making sure each cmake build option is represented
recipe-check:
runs-on: ubuntu-latest

steps:

- name: checkout-gfsio
uses: actions/checkout@v4
with:
path: gfsio

- name: recipe-check
run: |
echo "If this jobs fails, look at the most recently output CMake option below and make sure that option appears in spack/package.py"
for opt in $(grep -ioP '^option\(\K(?!(DUMMY_ENTRY))[^ ]+' $GITHUB_WORKSPACE/gfsio/CMakeLists.txt) ; do
echo "Checking for presence of '$opt' CMake option in package.py"
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/gfsio/spack/package.py
done
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/pfunit
key: pfunit-${{ runner.os }}-${{ hashFiles('pfunit/VERSION') }}
key: pfunit-${{ runner.os }}-gcc

- name: build-pfunit
if: steps.cache-pfunit.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
"MinSizeRel" "RelWithDebInfo")
endif()

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM|GNU|Clang|AppleClang)$")
message(
WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
endif()
Expand Down
3 changes: 3 additions & 0 deletions spack/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains an authoritative, up-to-date Spack recipe for NCEPLIBS-gfsio, which is found under Spack as "gfsio".

Before each release of NCEPLIBS-gfsio, this file should be updated to accommodate changes in build options, etc., and .github/workflows/spack.yml should be updated to exercise all variants. Only the version entry should need to be updated after the release prior to incorporation into the Spack repository and the JCSDA Spack fork.
49 changes: 49 additions & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class Gfsio(CMakePackage):
"""The GFSIO library provides an API to convert GFS Gaussian output into
grib output.

This is part of the NOAA NCEPLIBS project."""

homepage = "https://github.com/NOAA-EMC/NCEPLIBS-gfsio"
url = "https://github.com/NOAA-EMC/NCEPLIBS-gfsio/archive/refs/tags/v1.4.1.tar.gz"
git = "https://github.com/NOAA-EMC/NCEPLIBS-gfsio"

maintainers("AlexanderRichert-NOAA", "Hang-Lei-NOAA", "edwardhartnett")

version("develop", branch="develop")
version("1.4.1", sha256="eab106302f520600decc4f9665d7c6a55e7b4901fab6d9ef40f29702b89b69b1")

variant("pfunit", default=False, description="Enable pFunit testing")

depends_on("pfunit", when="+pfunit")

def cmake_args(self):
args = [
self.define("ENABLE_TESTS", self.run_tests),
]
return args

def setup_run_environment(self, env):
lib = find_libraries("libgfsio", root=self.prefix, shared=False, recursive=True)
# Only one library version, but still need to set _4 to make NCO happy
for suffix in ("4", ""):
env.set("GFSIO_LIB" + suffix, lib[0])
env.set("GFSIO_INC" + suffix, join_path(self.prefix, "include"))

def flag_handler(self, name, flags):
if self.spec.satisfies("%fj"):
if name == "fflags":
flags.append("-Free")
return (None, None, flags)

def check(self):
with working_dir(self.builder.build_directory):
make("test")
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$")
set(CMAKE_Fortran_FLAGS
"-g -traceback -free -convert big_endian -assume byterecl ${CMAKE_Fortran_FLAGS}")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
Expand Down
Loading