Skip to content

Commit 6657bb1

Browse files
authored
Merge branch 'master' into master
2 parents 4c047d4 + f1fd862 commit 6657bb1

13 files changed

Lines changed: 277 additions & 70 deletions

File tree

.github/Dockerfile

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,82 @@ ARG CXX_COMPILER
77
ARG FC_COMPILER
88
ARG COMPILER_PATH
99
ARG COMPILER_LD_LIBRARY_PATH
10+
ARG AFAR_VERSION
11+
ARG OLCF_AFAR_ROOT=""
12+
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
ENV TZ=UTC
1015

1116
RUN apt-get update -y && \
12-
apt-get install -y software-properties-common ca-certificates gnupg && \
17+
apt-get install -y software-properties-common ca-certificates gnupg wget && \
1318
add-apt-repository ppa:deadsnakes/ppa && \
1419
apt-get update -y && \
15-
if [ "$TARGET" != "gpu" ]; then \
20+
if [ "$TARGET" = "cpu" ]; then \
1621
apt-get install -y \
1722
build-essential git make cmake gcc g++ gfortran bc \
1823
python3.12 python3.12-venv python3-pip \
1924
openmpi-bin libopenmpi-dev libfftw3-dev \
2025
mpich libmpich-dev; \
21-
else \
26+
elif [ "$TARGET" = "gpu" ]; then \
2227
apt-get install -y \
2328
build-essential git make cmake bc \
2429
python3.12 python3.12-venv python3-pip \
2530
libfftw3-dev \
2631
openmpi-bin libopenmpi-dev; \
32+
elif [ "$TARGET" = "amd" ]; then \
33+
apt-get install -y \
34+
build-essential git make gcc g++ gfortran bc \
35+
python3.12 python3.12-venv python3-pip \
36+
libfftw3-dev libnuma1 libdrm2 libdrm-amdgpu1; \
2737
fi && \
2838
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 && \
2939
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3040

41+
# AMD: download AFAR, install cmake 3.28 (Ubuntu 22.04 ships 3.22 which doesn't
42+
# recognize amdflang as LLVMFlang), then build MPICH with amdflang so the
43+
# generated mpi.mod is compiler-compatible.
44+
RUN if [ "$TARGET" = "amd" ] && [ -n "$AFAR_VERSION" ]; then \
45+
OLCF_AFAR_ROOT="/opt/${AFAR_VERSION}" && \
46+
wget -q "https://repo.radeon.com/rocm/misc/flang/${AFAR_VERSION}-ubuntu.tar.bz2" -O /tmp/afar.tar.bz2 && \
47+
tar -xjf /tmp/afar.tar.bz2 -C /opt/ && \
48+
rm /tmp/afar.tar.bz2 && \
49+
CMAKE_VER=3.28.6 && \
50+
wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-x86_64.sh" \
51+
-O /tmp/cmake-install.sh && \
52+
chmod +x /tmp/cmake-install.sh && \
53+
/tmp/cmake-install.sh --prefix=/usr/local --skip-license --exclude-subdir && \
54+
rm /tmp/cmake-install.sh && \
55+
printf '#!/bin/bash\nargs=()\nwhile [ "$#" -gt 0 ]; do\n if [ "$1" = "-soname" ]; then\n args+=("-Wl,-soname,$2"); shift 2\n else\n args+=("$1"); shift\n fi\ndone\nexec '"${OLCF_AFAR_ROOT}"'/bin/amdflang "${args[@]}"\n' \
56+
> /usr/local/bin/amdflang-ld-wrap && \
57+
chmod +x /usr/local/bin/amdflang-ld-wrap && \
58+
MPICH_VER=3.4.3 && \
59+
wget -q "https://www.mpich.org/static/downloads/${MPICH_VER}/mpich-${MPICH_VER}.tar.gz" \
60+
-O /tmp/mpich.tar.gz && \
61+
mkdir -p /tmp/mpich-src && \
62+
tar -xzf /tmp/mpich.tar.gz -C /tmp/mpich-src --strip-components=1 && \
63+
cd /tmp/mpich-src && \
64+
FC=/usr/local/bin/amdflang-ld-wrap CC=gcc CXX=g++ \
65+
./configure --prefix=/opt/mpich --enable-shared --disable-static \
66+
--with-device=ch3 2>&1 && \
67+
make -j$(nproc) 2>&1 && \
68+
make install 2>&1 && \
69+
cd / && \
70+
rm -rf /tmp/mpich-src /tmp/mpich.tar.gz; \
71+
fi
72+
3173
ENV OMPI_ALLOW_RUN_AS_ROOT=1
3274
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
75+
ENV HYDRA_LAUNCHER=fork
3376
ENV PATH="/opt/MFC:$PATH"
3477

3578
COPY ../ /opt/MFC
3679

3780
ENV CC=${CC_COMPILER}
3881
ENV CXX=${CXX_COMPILER}
3982
ENV FC=${FC_COMPILER}
40-
ENV PATH="${COMPILER_PATH}:$PATH"
41-
ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH:-}"
83+
ENV OLCF_AFAR_ROOT=${OLCF_AFAR_ROOT}
84+
ENV PATH="${COMPILER_PATH}:/opt/mpich/bin:$PATH"
85+
ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:/opt/mpich/lib:${LD_LIBRARY_PATH:-}"
4286

4387
# Pre-install numpy into the venv before mfc.sh runs, as it's required at
4488
# build time by several dependencies (pandas, cantera, matplotlib, etc.) that
@@ -50,14 +94,18 @@ RUN python3.12 -m venv /opt/MFC/build/venv && \
5094
RUN echo "TARGET=$TARGET CC=$CC_COMPILER FC=$FC_COMPILER" && \
5195
cd /opt/MFC && \
5296
if [ "$TARGET" = "gpu" ]; then \
53-
./mfc.sh build --gpu -j $(nproc); \
97+
./mfc.sh build --gpu acc -j $(nproc); \
98+
elif [ "$TARGET" = "amd" ]; then \
99+
./mfc.sh build --gpu mp -j $(nproc); \
54100
else \
55101
./mfc.sh build -j $(nproc); \
56102
fi
57103

58104
RUN cd /opt/MFC && \
59105
if [ "$TARGET" = "gpu" ]; then \
60-
./mfc.sh test -a --dry-run --gpu -j $(nproc); \
106+
./mfc.sh test -a --dry-run --gpu acc -j $(nproc); \
107+
elif [ "$TARGET" = "amd" ]; then \
108+
./mfc.sh test -a --dry-run --gpu mp -j $(nproc); \
61109
else \
62110
./mfc.sh test -a --dry-run -j $(nproc); \
63111
fi

.github/file-filter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ yml: &yml
3030
- '.github/workflows/bench.yml'
3131
- '.github/workflows/test.yml'
3232
- '.github/workflows/formatting.yml'
33+
- '.github/workflows/fp-stability.yml'
34+
- '.github/workflows/convergence.yml'
3335

3436
checkall: &checkall
3537
- *fortran_src

.github/workflows/convergence.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,36 @@ on:
44
push:
55
branches: [master]
66
pull_request:
7+
types: [opened, synchronize, reopened, ready_for_review]
78
workflow_dispatch:
89

910
env:
1011
OMPI_MCA_rmaps_base_oversubscribe: 1
1112

1213
jobs:
14+
file-changes:
15+
name: Detect File Changes
16+
runs-on: ubuntu-latest
17+
outputs:
18+
checkall: ${{ steps.changes.outputs.checkall }}
19+
steps:
20+
- name: Clone
21+
uses: actions/checkout@v4
22+
23+
- name: Detect Changes
24+
uses: dorny/paths-filter@v3
25+
id: changes
26+
with:
27+
filters: ".github/file-filter.yml"
28+
1329
convergence:
1430
name: "Convergence"
1531
runs-on: ubuntu-latest
32+
needs: [file-changes]
33+
if: >-
34+
!cancelled() &&
35+
needs.file-changes.result == 'success' &&
36+
(needs.file-changes.outputs.checkall == 'true' || github.event_name == 'workflow_dispatch')
1637
timeout-minutes: 240
1738

1839
steps:

.github/workflows/deploy-tap.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
permissions:
2929
contents: write
3030
pull-requests: write
31+
environment:
32+
name: homebrew
33+
url: https://github.com/MFlowCode/homebrew-mfc
3134
steps:
3235
- name: Checkout MFC repository
3336
uses: actions/checkout@v4

.github/workflows/docker.yml

Lines changed: 112 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ name: Containerization
33
on:
44
release:
55
types: [published]
6+
schedule:
7+
- cron: '0 0 * * 0'
68
workflow_dispatch:
79
inputs:
810
tag:
911
description: 'tag to containerize'
10-
required: true
12+
required: false
13+
14+
permissions:
15+
contents: read
16+
packages: write
1117

1218
concurrency:
1319
group: Containerization
@@ -18,9 +24,11 @@ jobs:
1824
strategy:
1925
matrix:
2026
config:
21-
- { name: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
22-
- { name: 'gpu', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
23-
- { name: 'gpu', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda_multi-ubuntu22.04' }
27+
- { name: 'cpu', tag: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
28+
- { name: 'cpu', tag: 'cpu', runner: 'ubuntu-22.04-arm', base_image: 'ubuntu:22.04' }
29+
- { name: 'gpu', tag: 'gpu-nvidia', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:24.5-devel-cuda_multi-ubuntu22.04', compiler_arch: 'Linux_x86_64' }
30+
- { name: 'gpu', tag: 'gpu-nvidia', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:24.5-devel-cuda_multi-ubuntu22.04', compiler_arch: 'Linux_aarch64' }
31+
- { name: 'amd', tag: 'gpu-amd', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' }
2432
runs-on: ${{ matrix.config.runner }}
2533
outputs:
2634
tag: ${{ steps.clone.outputs.tag }}
@@ -36,25 +44,37 @@ jobs:
3644
docker-images: true
3745
swap-storage: true
3846

39-
- name: Login
47+
- name: Login to Docker Hub
4048
uses: docker/login-action@v3
4149
with:
4250
username: ${{ secrets.DOCKERHUB_USERNAME }}
4351
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4452

53+
- name: Login to GHCR
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
4560
- name: Setup Buildx
4661
uses: docker/setup-buildx-action@v3
4762

48-
- name: Setup QEMU
49-
uses: docker/setup-qemu-action@v3
50-
5163
- name: Clone
5264
id: clone
5365
run: |
54-
TAG="${{ github.event.inputs.tag || github.ref_name }}"
66+
if [ "${{ github.event_name }}" = "schedule" ]; then
67+
BRANCH="master"
68+
TAG="nightly"
69+
else
70+
BRANCH="${{ github.event.inputs.tag || github.ref_name }}"
71+
TAG=$(echo "$BRANCH" | tr '/' '-')
72+
fi
5573
echo "tag=$TAG" >> $GITHUB_OUTPUT
5674
echo "TAG=$TAG" >> $GITHUB_ENV
57-
git clone --branch "$TAG" --depth 1 ${{ github.server_url }}/${{ github.repository }}.git mfc
75+
OWNER="${{ github.repository_owner }}"
76+
echo "GH_REGISTRY=ghcr.io/${OWNER,,}/mfc" >> $GITHUB_ENV
77+
git clone --branch "$BRANCH" --depth 1 ${{ github.server_url }}/${{ github.repository }}.git mfc
5878
5979
- name: Stage
6080
run: |
@@ -71,16 +91,13 @@ jobs:
7191
cp -r mfc/.git /mnt/share/.git
7292
cp mfc/.github/Dockerfile /mnt/share/
7393
cp mfc/.github/.dockerignore /mnt/share/
74-
docker buildx create --name mfcbuilder --driver docker-container --use
7594
7695
- name: Build and push image (cpu)
7796
if: ${{ matrix.config.name == 'cpu' }}
7897
uses: docker/build-push-action@v6
7998
with:
80-
builder: mfcbuilder
8199
context: /mnt/share
82100
file: /mnt/share/Dockerfile
83-
platforms: linux/amd64,linux/arm64
84101
build-args: |
85102
BASE_IMAGE=${{ matrix.config.base_image }}
86103
TARGET=${{ matrix.config.name }}
@@ -89,7 +106,11 @@ jobs:
89106
FC_COMPILER=${{ 'gfortran' }}
90107
COMPILER_PATH=${{ '/usr/bin' }}
91108
COMPILER_LD_LIBRARY_PATH=${{ '/usr/lib' }}
92-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}
109+
labels: |
110+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
111+
tags: |
112+
${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
113+
${{ env.GH_REGISTRY }}:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
93114
push: true
94115

95116
- name: Build and push image (gpu)
@@ -105,28 +126,95 @@ jobs:
105126
CC_COMPILER=${{ 'nvc' }}
106127
CXX_COMPILER=${{ 'nvc++' }}
107128
FC_COMPILER=${{ 'nvfortran' }}
108-
COMPILER_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' }}
109-
COMPILER_LD_LIBRARY_PATH=${{ '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' }}
110-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}}
129+
COMPILER_PATH=/opt/nvidia/hpc_sdk/${{ matrix.config.compiler_arch }}/compilers/bin
130+
COMPILER_LD_LIBRARY_PATH=/opt/nvidia/hpc_sdk/${{ matrix.config.compiler_arch }}/compilers/lib
131+
labels: |
132+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
133+
tags: |
134+
${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
135+
${{ env.GH_REGISTRY }}:${{ env.TAG }}-${{ matrix.config.tag }}-${{ matrix.config.runner }}
136+
push: true
137+
138+
- name: Set AMD AFAR vars
139+
if: ${{ matrix.config.name == 'amd' }}
140+
run: |
141+
AFAR=rocm-afar-8873-drop-22.2.0
142+
ROOT="/opt/${AFAR}"
143+
echo "AFAR_VERSION=${AFAR}" >> $GITHUB_ENV
144+
echo "AFAR_ROOT=${ROOT}" >> $GITHUB_ENV
145+
146+
- name: Build and push image (amd)
147+
if: ${{ matrix.config.name == 'amd' }}
148+
uses: docker/build-push-action@v6
149+
with:
150+
context: /mnt/share
151+
file: /mnt/share/Dockerfile
152+
build-args: |
153+
BASE_IMAGE=${{ matrix.config.base_image }}
154+
TARGET=amd
155+
AFAR_VERSION=${{ env.AFAR_VERSION }}
156+
OLCF_AFAR_ROOT=${{ env.AFAR_ROOT }}
157+
CC_COMPILER=gcc
158+
CXX_COMPILER=g++
159+
FC_COMPILER=${{ env.AFAR_ROOT }}/bin/amdflang
160+
COMPILER_PATH=${{ env.AFAR_ROOT }}/lib/llvm/bin:${{ env.AFAR_ROOT }}/bin
161+
COMPILER_LD_LIBRARY_PATH=${{ env.AFAR_ROOT }}/lib:${{ env.AFAR_ROOT }}/lib/llvm/lib
162+
labels: |
163+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
164+
tags: |
165+
${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-amd-ubuntu-22.04
166+
${{ env.GH_REGISTRY }}:${{ env.TAG }}-gpu-amd-ubuntu-22.04
111167
push: true
112168

113169
manifests:
114170
runs-on: ubuntu-latest
115171
needs: Container
172+
environment:
173+
name: containers
174+
url: https://hub.docker.com/r/sbryngelson/mfc
116175
steps:
117-
- name: Login
176+
- name: Login to Docker Hub
118177
uses: docker/login-action@v3
119178
with:
120179
username: ${{ secrets.DOCKERHUB_USERNAME }}
121180
password: ${{ secrets.DOCKERHUB_PASSWORD }}
122181

182+
- name: Login to GHCR
183+
uses: docker/login-action@v3
184+
with:
185+
registry: ghcr.io
186+
username: ${{ github.actor }}
187+
password: ${{ secrets.GITHUB_TOKEN }}
188+
189+
- name: Setup Buildx
190+
uses: docker/setup-buildx-action@v3
191+
192+
- name: Set GHCR registry (lowercase)
193+
run: |
194+
OWNER="${{ github.repository_owner }}"
195+
echo "GH_REGISTRY=ghcr.io/${OWNER,,}/mfc" >> $GITHUB_ENV
196+
123197
- name: Create and Push Manifest Lists
124198
env:
125199
TAG: ${{ needs.Container.outputs.tag }}
126-
REGISTRY: ${{ secrets.DOCKERHUB_USERNAME }}/mfc
200+
DH: ${{ secrets.DOCKERHUB_USERNAME }}/mfc
201+
run: |
202+
GH="${{ env.GH_REGISTRY }}"
203+
for R in "$DH" "$GH"; do
204+
docker buildx imagetools create -t $R:$TAG-cpu $R:$TAG-cpu-ubuntu-22.04 $R:$TAG-cpu-ubuntu-22.04-arm
205+
docker buildx imagetools create -t $R:$TAG-gpu-nvidia $R:$TAG-gpu-nvidia-ubuntu-22.04 $R:$TAG-gpu-nvidia-ubuntu-22.04-arm
206+
docker buildx imagetools create -t $R:$TAG-gpu-amd $R:$TAG-gpu-amd-ubuntu-22.04
207+
done
208+
209+
- name: Update latest tags
210+
if: github.event_name == 'release'
211+
env:
212+
TAG: ${{ needs.Container.outputs.tag }}
213+
DH: ${{ secrets.DOCKERHUB_USERNAME }}/mfc
127214
run: |
128-
docker buildx imagetools create -t $REGISTRY:latest-cpu $REGISTRY:$TAG-cpu
129-
docker manifest create $REGISTRY:$TAG-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
130-
docker manifest create $REGISTRY:latest-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm
131-
docker manifest push $REGISTRY:$TAG-gpu
132-
docker manifest push $REGISTRY:latest-gpu
215+
GH="${{ env.GH_REGISTRY }}"
216+
for R in "$DH" "$GH"; do
217+
docker buildx imagetools create -t $R:latest-cpu $R:$TAG-cpu-ubuntu-22.04 $R:$TAG-cpu-ubuntu-22.04-arm
218+
docker buildx imagetools create -t $R:latest-gpu-nvidia $R:$TAG-gpu-nvidia-ubuntu-22.04 $R:$TAG-gpu-nvidia-ubuntu-22.04-arm
219+
docker buildx imagetools create -t $R:latest-gpu-amd $R:$TAG-gpu-amd-ubuntu-22.04
220+
done

0 commit comments

Comments
 (0)