Skip to content

Commit 7804346

Browse files
authored
Merge pull request #366 from awslabs/cameronrutherford/spack-cpu-build-fix
Spack CPU Build Fix. Add spack built libCEED support.
2 parents cd4d7b7 + 8f114a7 commit 7804346

File tree

12 files changed

+390
-206
lines changed

12 files changed

+390
-206
lines changed

.github/workflows/spack.yml

Lines changed: 117 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,50 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
# Note that each spack version needs it's own registry
15+
SPACK_VERSION: develop
16+
REGISTRY: ghcr.io/awslabs/palace
17+
GITHUB_USER: ${{ github.actor }}
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
1320
jobs:
1421
build-and-test-spack:
1522
strategy:
16-
fail-fast: false
23+
fail-fast: false # don't have one build stop others from finishing
1724
matrix:
18-
include: # Include GPU build tests
19-
- compiler: gcc
20-
mpi: openmpi
21-
gpu: none
22-
23-
# - compiler: gcc
24-
# mpi: mpich
25-
# gpu: cuda
26-
27-
# - compiler: gcc
28-
# mpi: mpich
29-
# gpu: rocm
25+
compiler: [gcc] #, clang, intel]
26+
gpu: [none] #, cuda, rocm]
27+
blas: [openblas] # ,intel-oneapi-mkl]
28+
spack_version: [develop] # ,v0.23.1]
29+
mpi: [openmpi] #, mpich, mvapich]
3030

3131
runs-on: palace_ubuntu-latest_16-core
3232
steps:
3333
- uses: actions/checkout@v4
3434

35-
- name: Configure Open MPI
36-
if: matrix.mpi == 'openmpi'
37-
run: |
38-
sudo apt-get install -y openmpi-bin libopenmpi-dev
39-
40-
- name: Configure MPICH
41-
if: matrix.mpi == 'mpich'
42-
run: |
43-
sudo apt-get install -y mpich libmpich-dev
44-
45-
- name: Configure Intel MPI
46-
if: matrix.mpi == 'intelmpi'
47-
uses: mpi4py/setup-mpi@v1
48-
with:
49-
mpi: ${{ matrix.mpi }}
50-
5135
- name: Configure Clang compiler
5236
if: matrix.compiler == 'clang'
53-
run: |
54-
sudo apt-get install -y clang lld
37+
run: sudo apt-get install -y clang lld
5538

5639
- name: Configure Intel oneAPI compiler
5740
if: matrix.compiler == 'intel'
58-
run: |
41+
run:
5942
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp=2024.2.1-1079 \
60-
intel-oneapi-compiler-fortran=2024.2.1-1079
61-
62-
- uses: vsoch/spack-package-action/install@main
43+
intel-oneapi-compiler-fortran=2024.2.1-1079
6344

64-
- name: Build Palace
45+
- name: Setup Spack
46+
uses: spack/setup-spack@v2
47+
with:
48+
ref: develop
49+
buildcache: true
50+
color: true
51+
# This seems unecessary, but otherwise we clone into ./spack
52+
# This then would override the spack local repo dir, and break CI
53+
path: spack-path
54+
55+
- name: Setup Environment
6556
run: |
66-
# Clean up Android SDK install (confuses Spack MKL link line?)
67-
sudo rm -rf $ANDROID_HOME
68-
69-
# Set up Spack to use external packages (MPI, etc.) and local Palace package
70-
# recipe
71-
. /opt/spack/share/spack/setup-env.sh
72-
spack external find --all
73-
spack repo add spack/local
74-
7557
# Configure GPU variant
7658
if [[ "${{ matrix.gpu }}" == 'cuda' ]]; then
7759
GPU_VARIANT="+cuda cuda_arch=70"
@@ -81,25 +63,99 @@ jobs:
8163
GPU_VARIANT=""
8264
fi
8365
84-
# Build and install
85-
PALACE_SPEC="local.palace@develop%${{ matrix.compiler }}$GPU_VARIANT ^${{ matrix.mpi }}"
86-
PALACE_SPEC="$PALACE_SPEC ^petsc~hdf5 ^intel-oneapi-mkl"
87-
spack spec $PALACE_SPEC
88-
spack dev-build $PALACE_SPEC
66+
# Develop requires ^compiler, not %compiler
67+
if [[ "${{ matrix.spack_version }}" == 'v0.23.1' ]]; then
68+
PALACE_SPEC="local.palace@develop %${{ matrix.compiler }} ${GPU_VARIANT} ^${{ matrix.mpi }} ^${{ matrix.blas }}"
69+
else
70+
PALACE_SPEC="local.palace@develop${GPU_VARIANT} ^${{ matrix.mpi }} ^${{ matrix.blas }} ^${{ matrix.compiler }}"
71+
fi
8972
90-
- name: Run tests
91-
if: matrix.gpu == 'none' # Skip tests for GPU builds
92-
env:
93-
NUM_PROC_TEST_MAX: '8'
73+
# Spack.yaml with most / all settings configured
74+
cat << EOF > spack.yaml
75+
spack:
76+
specs:
77+
- ${PALACE_SPEC}
78+
view: false
79+
config:
80+
install_tree:
81+
root: /opt/spack
82+
padded_length: False
83+
concretizer:
84+
reuse: false
85+
unify: true
86+
targets:
87+
granularity: generic
88+
packages:
89+
petsc:
90+
require: ~hdf5
91+
rocblas:
92+
require: ~tensile
93+
repos:
94+
- spack/local
95+
mirrors:
96+
spack:
97+
binary: true
98+
url: https://binaries.spack.io/${SPACK_VERSION}
99+
local-buildcache:
100+
binary: true
101+
autopush: true
102+
url: oci://${{ env.REGISTRY }}-${SPACK_VERSION}
103+
signed: false
104+
access_pair:
105+
id_variable: GITHUB_USER
106+
secret_variable: GITHUB_TOKEN
107+
EOF
108+
109+
- name: Configure External Packages
94110
run: |
95-
# Configure environment
96-
export NUM_PROC_TEST=$(nproc 2> /dev/null || sysctl -n hw.ncpu)
97-
if [[ "$NUM_PROC_TEST" -gt "$NUM_PROC_TEST_MAX" ]]; then
98-
NUM_PROC_TEST=$NUM_PROC_TEST_MAX
99-
fi
100-
. /opt/spack/share/spack/setup-env.sh
101-
spack load palace
111+
# These cause build issues if built as externals
112+
# - python : often distributed python isn't feature complete / not all dependencies get detected
113+
# - OpenSSL / OpenSSH : since they are in /usr, spack struggles. It's common to rebuild these
114+
# - ncurses / bzip2 / xz / curl : caused build issues. We pull these from GHCR cache after first build
115+
spack -e . external find --all \
116+
--exclude openssl \
117+
--exclude openssh \
118+
--exclude python \
119+
--exclude ncurses \
120+
--exclude bzip2 \
121+
--exclude xz \
122+
--exclude curl
123+
124+
- name: Configure Compilers
125+
run: spack -e . compiler find && spack -e . compiler list
126+
127+
- name: Configure Binary Mirror Keys
128+
run: |
129+
# If we cached these, that would be faster and safer
130+
spack -e . buildcache keys --install --trust
102131
132+
- name: Bootstrap
133+
run: spack -e . bootstrap now
134+
135+
- name: Concretize
136+
# In theory we can re-use a concretization and pin a spack to speed this up.
137+
# Unfortunately it then becomes difficult to know when to re-concretize.
138+
run: |
139+
# Using `spack develop` in order to have an in-source build
140+
spack -e . develop --path=$(pwd) local.palace@git."${{ github.head_ref || github.ref_name }}"=develop
141+
spack -e . concretize -f
142+
143+
- name: Build Dependencies
144+
run: |
145+
spack -e . install --only-concrete --no-check-signature --fail-fast --show-log-on-error --only dependencies
146+
147+
- name: Build Palace
148+
# Build palace from source using this current directory
149+
# We use `--no-cache` in order to force a rebuild
150+
run: spack -e . install --only-concrete --keep-stage --show-log-on-error --only package --no-cache
151+
152+
# Should we run unit tests as well here?
153+
- name: Run Integration Tests
154+
if: matrix.gpu == 'none' # Skip tests for GPU builds
155+
env:
156+
NUM_PROC_TEST_MAX: "8"
157+
run: |
158+
eval $(spack -e . load --sh palace)
103159
# Run tests
104160
julia --project=test/examples -e 'using Pkg; Pkg.instantiate()'
105161
julia --project=test/examples --color=yes test/examples/runtests.jl

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ The format of this changelog is based on
8484
`MinimalRationalInterpolation` class to support multiple excitations. The MRI is unique to each
8585
excitation, but the PROM is shared between excitations.
8686
- Added `PortExcitations` to manage excitation pattern and print it to json metadata.
87+
- Update spack configuration to address `0.12` API breakage between libxsmm and libCEED.
88+
- Support spack vended libCEED and GSLIB builds.
8789

8890
## [0.13.0] - 2024-05-20
8991

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,6 @@ if(PALACE_BUILD_EXTERNAL_DEPS)
191191
add_subdirectory("extern")
192192
endif()
193193

194-
# Add GSLIB (always built as part of Palace)
195-
if(PALACE_WITH_GSLIB)
196-
message(STATUS "===================== Configuring GSLIB dependency =====================")
197-
include(ExternalGSLIB)
198-
endif()
199-
200-
# Add libCEED (always built as part of Palace)
201-
message(STATUS "==================== Configuring libCEED dependency ====================")
202-
include(ExternalLibCEED)
203-
204194
# Add MFEM (always built as part of Palace)
205195
message(STATUS "====================== Configuring MFEM dependency =====================")
206196
include(ExternalMFEM)

cmake/ExternalBLASLAPACK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ if(DEFINED ENV{ARMPL_DIR} OR DEFINED ENV{ARMPLROOT} OR DEFINED ENV{ARMPL_ROOT})
5050
set(BLA_VENDOR "Arm${ARMPL_LIB_SUFFIX}")
5151
find_package(BLAS REQUIRED)
5252
find_package(LAPACK REQUIRED)
53-
set(LAPACK_LIBRARIES "${LAPACK_LIBRARIES};-lm")
5453

5554
# Locate include directory
5655
find_path(_BLAS_LAPACK_INCLUDE_DIRS
@@ -186,10 +185,11 @@ else()
186185
find_path(_BLAS_LAPACK_INCLUDE_DIRS
187186
NAMES cblas.h
188187
HINTS ${_BLAS_LAPACK_DIRS}
189-
PATH_SUFFIXES include include/openblas
188+
PATH_SUFFIXES include include/openblas include/blis
190189
REQUIRED
191190
)
192191
endif()
192+
set(LAPACK_LIBRARIES "${LAPACK_LIBRARIES};-lm")
193193

194194
# Save variables to cache
195195
set(_BLAS_LAPACK_LIBRARIES ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})

cmake/ExternalLibCEED.cmake

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
# Force build order
99
set(LIBCEED_DEPENDENCIES)
10-
if(PALACE_BUILD_EXTERNAL_DEPS)
11-
if(PALACE_WITH_LIBXSMM)
12-
list(APPEND LIBCEED_DEPENDENCIES libxsmm)
13-
endif()
14-
if(PALACE_WITH_MAGMA)
15-
list(APPEND LIBCEED_DEPENDENCIES magma)
16-
endif()
10+
if(PALACE_WITH_LIBXSMM)
11+
list(APPEND LIBCEED_DEPENDENCIES libxsmm)
12+
endif()
13+
if(PALACE_WITH_MAGMA)
14+
list(APPEND LIBCEED_DEPENDENCIES magma)
1715
endif()
1816

1917
# Note on recommended flags for libCEED (from Makefile, Spack):
@@ -67,15 +65,9 @@ endif()
6765

6866
# Configure libCEED backends (nvcc, hipcc flags are configured by libCEED)
6967
if(PALACE_WITH_LIBXSMM)
70-
if(PALACE_BUILD_EXTERNAL_DEPS)
71-
list(APPEND LIBCEED_OPTIONS
72-
"XSMM_DIR=${CMAKE_INSTALL_PREFIX}"
73-
)
74-
else()
75-
list(APPEND LIBCEED_OPTIONS
76-
"XSMM_DIR=${LIBXSMM_DIR}"
77-
)
78-
endif()
68+
list(APPEND LIBCEED_OPTIONS
69+
"XSMM_DIR=${CMAKE_INSTALL_PREFIX}"
70+
)
7971
# LIBXSMM can require linkage with BLAS for fallback
8072
if(NOT "${BLAS_LAPACK_LIBRARIES}" STREQUAL "")
8173
string(REPLACE "$<SEMICOLON>" " " LIBCEED_BLAS_LAPACK_LIBRARIES "${BLAS_LAPACK_LIBRARIES}")
@@ -107,15 +99,9 @@ if(PALACE_WITH_HIP)
10799
endif()
108100
endif()
109101
if(PALACE_WITH_MAGMA)
110-
if(PALACE_BUILD_EXTERNAL_DEPS)
111-
list(APPEND LIBCEED_OPTIONS
112-
"MAGMA_DIR=${CMAKE_INSTALL_PREFIX}"
113-
)
114-
else()
115-
list(APPEND LIBCEED_OPTIONS
116-
"MAGMA_DIR=${MAGMA_DIR}"
117-
)
118-
endif()
102+
list(APPEND LIBCEED_OPTIONS
103+
"MAGMA_DIR=${CMAKE_INSTALL_PREFIX}"
104+
)
119105
endif()
120106

121107
string(REPLACE ";" "; " LIBCEED_OPTIONS_PRINT "${LIBCEED_OPTIONS}")

cmake/ExternalMFEM.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ if(PALACE_BUILD_EXTERNAL_DEPS)
2020
if(PALACE_WITH_SUNDIALS)
2121
list(APPEND MFEM_DEPENDENCIES sundials)
2222
endif()
23+
if(PALACE_WITH_GSLIB)
24+
list(APPEND MFEM_DEPENDENCIES gslib)
25+
endif()
2326
else()
2427
set(MFEM_DEPENDENCIES)
2528
endif()
26-
if(PALACE_WITH_GSLIB)
27-
list(APPEND MFEM_DEPENDENCIES gslib)
28-
endif()
2929

3030
# Silence #pragma omp warnings when not building with OpenMP
3131
set(MFEM_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@@ -151,10 +151,12 @@ endif()
151151

152152
# MFEM with GSLIB is always built internally
153153
if(PALACE_WITH_GSLIB)
154-
list(APPEND MFEM_OPTIONS
155-
"-DMFEM_USE_GSLIB=YES"
156-
"-DGSLIB_DIR=${CMAKE_INSTALL_PREFIX}"
157-
)
154+
list(APPEND MFEM_OPTIONS "-DMFEM_USE_GSLIB=YES")
155+
if(PALACE_BUILD_EXTERNAL_DEPS)
156+
list(APPEND MFEM_OPTIONS "-DGSLIB_DIR=${CMAKE_INSTALL_PREFIX}")
157+
else()
158+
list(APPEND MFEM_OPTIONS "-DGSLIB_DIR=${GSLIB_DIR}")
159+
endif()
158160
endif()
159161

160162
# Configure the rest of MFEM's dependencies

cmake/ExternalPalace.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77

88
# Force build order
9-
set(PALACE_DEPENDENCIES mfem libCEED)
9+
set(PALACE_DEPENDENCIES mfem)
1010
if(PALACE_BUILD_EXTERNAL_DEPS)
11-
list(APPEND PALACE_DEPENDENCIES json fmt eigen)
11+
list(APPEND PALACE_DEPENDENCIES libCEED json fmt eigen)
1212
if(PALACE_WITH_SLEPC)
1313
list(APPEND PALACE_DEPENDENCIES slepc)
1414
endif()

extern/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ if(PALACE_WITH_SUNDIALS)
7878
message(STATUS "===================== Configuring SUNDIALS dependency =====================")
7979
include(ExternalSUNDIALS)
8080
endif()
81+
82+
# Add GSLIB
83+
if(PALACE_WITH_GSLIB)
84+
message(STATUS "===================== Configuring GSLIB dependency =====================")
85+
include(ExternalGSLIB)
86+
endif()
87+
88+
# Add libCEED
89+
message(STATUS "==================== Configuring libCEED dependency ====================")
90+
include(ExternalLibCEED)
91+

0 commit comments

Comments
 (0)