From aa5055da26d8d1764699e26779f63403b95be981 Mon Sep 17 00:00:00 2001 From: Malmahrouqi3 Date: Tue, 29 Jul 2025 11:08:07 -0400 Subject: [PATCH 1/5] implemented all changes --- .github/.dockerignore | 83 ++++++++++++++++++++++++++++++++++++ .github/Dockerfile | 55 ++++++++++++++++++++++++ .github/workflows/docker.yml | 59 +++++++++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 .github/.dockerignore create mode 100644 .github/Dockerfile create mode 100644 .github/workflows/docker.yml diff --git a/.github/.dockerignore b/.github/.dockerignore new file mode 100644 index 0000000000..dad61a765a --- /dev/null +++ b/.github/.dockerignore @@ -0,0 +1,83 @@ +node_modules/ +package.json +yarn.lock + +.venv/ +.vscode/ +src/*/include/case.fpp +src/*/autogen/ + +*.swo +*.swp + +*:Zone.Identifier + +.nfs* + +__pycache__ + +*.egg-info + +.DS_Store + +# NVIDIA Nsight Compute +*.nsys-rep +*.sqlite + +docs/*/initial* +docs/*/result* +docs/documentation/*-example.png +docs/documentation/examples.md + +examples/*batch/*/ +examples/**/D/* +examples/**/p* +examples/**/D_* +examples/**/*.inf +examples/**/*.inp +examples/**/*.dat +examples/**/*.o* +examples/**/silo* +examples/**/restart_data* +examples/**/*.out +examples/**/binary +examples/**/fort.1 +examples/**/*.sh +examples/**/*.err +examples/**/viz/ +examples/*.jpg +examples/*.png +examples/*/workloads/ +examples/*/run-*/ +examples/*/logs/ +examples/**/*.f90 +!examples/3D_lag_bubbles_shbubcollapse/input/lag_bubbles.dat +!examples/3D_lag_bubbles_bubblescreen/input/lag_bubbles.dat +workloads/ + +benchmarks/*batch/*/ +benchmarks/*/D/* +benchmarks/*/p* +benchmarks/*/D_* +benchmarks/*/*.inf +benchmarks/*/*.inp +benchmarks/*/*.dat +benchmarks/*/*.o* +benchmarks/*/silo* +benchmarks/*/restart_data* +benchmarks/*/*.out +benchmarks/*/binary +benchmarks/*/fort.1 +benchmarks/*/*.sh +benchmarks/*/*.err +benchmarks/*/viz/ +benchmarks/*.jpg +benchmarks/*.png + +*.mod + +# Video Files +*.mp4 +*.mov +*.mkv +*.avi \ No newline at end of file diff --git a/.github/Dockerfile b/.github/Dockerfile new file mode 100644 index 0000000000..eac1a3dc44 --- /dev/null +++ b/.github/Dockerfile @@ -0,0 +1,55 @@ +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ARG TARGET +ARG CC_COMPILER +ARG CXX_COMPILER +ARG FC_COMPILER +ARG COMPILER_PATH +ARG COMPILER_LD_LIBRARY_PATH + +RUN apt-get update -y && \ + if [ "$TARGET" != "gpu" ]; then \ + apt-get install -y \ + build-essential git make cmake gcc g++ gfortran \ + python3 python3-venv python3-pip \ + openmpi-bin libopenmpi-dev libfftw3-dev \ + libatlas-base-dev mpich libmpich-dev; \ + else \ + apt-get install -y \ + build-essential git make cmake \ + python3 python3-venv python3-pip \ + libfftw3-dev libatlas-base-dev \ + openmpi-bin libopenmpi-dev; \ + fi && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 +ENV PATH="/opt/MFC:$PATH" + +COPY ../ /opt/MFC + +ENV CC=${CC_COMPILER} +ENV CXX=${CXX_COMPILER} +ENV FC=${FC_COMPILER} +ENV PATH="${COMPILER_PATH}:$PATH" +ENV LD_LIBRARY_PATH="${COMPILER_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH:-}" + +RUN echo "TARGET=$TARGET CC=$CC_COMPILER FC=$FC_COMPILER" && \ + cd /opt/MFC && \ + if [ "$TARGET" = "gpu" ]; then \ + ./mfc.sh build --gpu -j $(nproc); \ + else \ + ./mfc.sh build -j $(nproc); \ + fi + +RUN cd /opt/MFC && \ + if [ "$TARGET" = "gpu" ]; then \ + ./mfc.sh test --dry-run --gpu -j $(nproc); \ + else \ + ./mfc.sh test --dry-run -j $(nproc); \ + fi + +WORKDIR /opt/MFC +ENTRYPOINT ["bash"] \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..bd7ea8f171 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ +name: Containerization + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + Container: + runs-on: ubuntu-latest + strategy: + matrix: + config: + - { name: 'cpu', base_image: 'ubuntu:22.04'} + - { name: 'gpu', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04'} + + steps: + - name: Clone + uses: actions/checkout@v4 + with: + path: mfc + + - name: Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Setup + uses: docker/setup-buildx-action@v3 + + - name: Stage + run: | + sudo mkdir -p /mnt/share + sudo chmod 777 /mnt/share + cp -r mfc/* /mnt/share/ + cp -r mfc/.git /mnt/share/.git + cp mfc/.github/Dockerfile /mnt/share/ + cp mfc/.github/.dockerignore /mnt/share/ + docker buildx create --name mfcbuilder --driver docker-container --use + + - name: Build and Deploy + uses: docker/build-push-action@v5 + with: + builder: mfcbuilder + context: /mnt/share + file: /mnt/share/Dockerfile + build-args: | + BASE_IMAGE=${{ matrix.config.base_image }} + TARGET=${{ matrix.config.name }} + CC_COMPILER=${{ contains(matrix.config.name, 'gpu') && 'nvc' || 'gcc' }} + CXX_COMPILER=${{ contains(matrix.config.name, 'gpu') && 'nvc++' || 'g++' }} + FC_COMPILER=${{ contains(matrix.config.name, 'gpu') && 'nvfortran' || 'gfortran' }} + COMPILER_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' || '/usr/bin' }} + COMPILER_LD_LIBRARY_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' || '/usr/lib' }} + tags: sbryngelson/mfc:${{ github.ref_name }}-${{ matrix.config.name }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file From f348b7810c6ce8a8b19b0ce930eeeb5e9f1716c0 Mon Sep 17 00:00:00 2001 From: Malmahrouqi3 Date: Tue, 29 Jul 2025 11:34:50 -0400 Subject: [PATCH 2/5] Better handling of manual triggers --- .github/workflows/docker.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bd7ea8f171..b91a29875d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,13 +24,19 @@ jobs: uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Setup uses: docker/setup-buildx-action@v3 - name: Stage run: | + if [ -n "${{ github.event.inputs.tag }}" ]; then + echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV + fi + sudo mkdir -p /mnt/share sudo chmod 777 /mnt/share cp -r mfc/* /mnt/share/ @@ -53,7 +59,7 @@ jobs: FC_COMPILER=${{ contains(matrix.config.name, 'gpu') && 'nvfortran' || 'gfortran' }} COMPILER_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' || '/usr/bin' }} COMPILER_LD_LIBRARY_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' || '/usr/lib' }} - tags: sbryngelson/mfc:${{ github.ref_name }}-${{ matrix.config.name }} + tags: sbryngelson/mfc:${{ env.TAG }}-${{ matrix.config.name }} push: true cache-from: type=gha cache-to: type=gha,mode=max \ No newline at end of file From 0aca803cb6eb881760ab7fb4d55482f072150b2e Mon Sep 17 00:00:00 2001 From: Malmahrouqi3 Date: Tue, 5 Aug 2025 23:17:05 -0400 Subject: [PATCH 3/5] devcontainer & workflow updates --- .devcontainer/devcontainer.json | 9 +++++ .github/.dockerignore | 1 - .github/Dockerfile | 6 +-- .github/workflows/docker.yml | 72 +++++++++++++++++++++++++-------- 4 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..8b0e0fdafb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,9 @@ +{ + "name": "MFC Container", + "image": "sbryngelson/mfc:latest-cpu", + "workspaceFolder": "/opt/MFC", + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "editor.formatOnSave": true + }, +} \ No newline at end of file diff --git a/.github/.dockerignore b/.github/.dockerignore index dad61a765a..452cfea06a 100644 --- a/.github/.dockerignore +++ b/.github/.dockerignore @@ -4,7 +4,6 @@ yarn.lock .venv/ .vscode/ -src/*/include/case.fpp src/*/autogen/ *.swo diff --git a/.github/Dockerfile b/.github/Dockerfile index eac1a3dc44..b9abcb7c7a 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -14,12 +14,12 @@ RUN apt-get update -y && \ build-essential git make cmake gcc g++ gfortran \ python3 python3-venv python3-pip \ openmpi-bin libopenmpi-dev libfftw3-dev \ - libatlas-base-dev mpich libmpich-dev; \ + mpich libmpich-dev; \ else \ apt-get install -y \ build-essential git make cmake \ python3 python3-venv python3-pip \ - libfftw3-dev libatlas-base-dev \ + libfftw3-dev \ openmpi-bin libopenmpi-dev; \ fi && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -52,4 +52,4 @@ RUN cd /opt/MFC && \ fi WORKDIR /opt/MFC -ENTRYPOINT ["bash"] \ No newline at end of file +ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b91a29875d..066b4ddf1c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,32 +4,39 @@ on: release: types: [published] workflow_dispatch: + inputs: + tag: + description: 'tag to containerize' + required: true + +concurrency: + group: Containerization-${{ github.event.inputs.tag || github.ref_name }} + cancel-in-progress: false jobs: Container: - runs-on: ubuntu-latest strategy: matrix: config: - - { name: 'cpu', base_image: 'ubuntu:22.04'} - - { name: 'gpu', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04'} - + - { name: 'cpu', runner: 'ubuntu-22.04', base_image: 'ubuntu:22.04' } + - { name: 'cpu', runner: 'ubuntu-22.04-arm', base_image: 'ubuntu:22.04' } + - { name: 'gpu', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04' } + - { name: 'gpu', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04' } + runs-on: ${{ matrix.config.runner }} steps: - - name: Clone - uses: actions/checkout@v4 - with: - path: mfc - - name: Login uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Setup + - name: Setup Buildx uses: docker/setup-buildx-action@v3 - - name: Stage + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + + - name: Clone run: | if [ -n "${{ github.event.inputs.tag }}" ]; then echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV @@ -37,18 +44,21 @@ jobs: echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV fi + git clone --branch ${{ env.TAG }} --depth 1 https://github.com/MFlowCode/MFC.git mfc + + - name: Stage + run: | sudo mkdir -p /mnt/share sudo chmod 777 /mnt/share cp -r mfc/* /mnt/share/ cp -r mfc/.git /mnt/share/.git cp mfc/.github/Dockerfile /mnt/share/ cp mfc/.github/.dockerignore /mnt/share/ - docker buildx create --name mfcbuilder --driver docker-container --use - name: Build and Deploy uses: docker/build-push-action@v5 with: - builder: mfcbuilder + builder: default context: /mnt/share file: /mnt/share/Dockerfile build-args: | @@ -59,7 +69,37 @@ jobs: FC_COMPILER=${{ contains(matrix.config.name, 'gpu') && 'nvfortran' || 'gfortran' }} COMPILER_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/bin' || '/usr/bin' }} COMPILER_LD_LIBRARY_PATH=${{ contains(matrix.config.name, 'gpu') && '/opt/nvidia/hpc_sdk/Linux_x86_64/compilers/lib' || '/usr/lib' }} - tags: sbryngelson/mfc:${{ env.TAG }}-${{ matrix.config.name }} + tags: ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-${{ matrix.config.name }}-${{ matrix.config.runner}} push: true - cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + + manifests: + runs-on: ubuntu-latest + needs: Container + steps: + - name: Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Create and Push Manifest Lists + run: | + docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04 \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04-arm + docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu + + docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-cpu \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04 \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04-arm + docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-cpu + + docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04 \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04-arm + docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu + + docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-gpu \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04 \ + ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04-arm + docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-gpu \ No newline at end of file From 2ec920985a08eda897e3e26942c0d43723bad935 Mon Sep 17 00:00:00 2001 From: Malmahrouqi3 Date: Tue, 5 Aug 2025 23:54:23 -0400 Subject: [PATCH 4/5] trying to fix the issue with TAG --- .github/workflows/docker.yml | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 066b4ddf1c..a36db5bb24 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,6 +23,8 @@ jobs: - { name: 'gpu', runner: 'ubuntu-22.04', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04' } - { name: 'gpu', runner: 'ubuntu-22.04-arm', base_image: 'nvcr.io/nvidia/nvhpc:23.11-devel-cuda12.3-ubuntu22.04' } runs-on: ${{ matrix.config.runner }} + outputs: + tag: ${{ steps.clone.outputs.tag }} steps: - name: Login uses: docker/login-action@v3 @@ -37,14 +39,12 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Clone + id: clone run: | - if [ -n "${{ github.event.inputs.tag }}" ]; then - echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV - fi - - git clone --branch ${{ env.TAG }} --depth 1 https://github.com/MFlowCode/MFC.git mfc + TAG="${{ github.event.inputs.tag || github.ref_name }}" + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "TAG=$TAG" >> $GITHUB_ENV + git clone --branch "$TAG" --depth 1 https://github.com/MFlowCode/MFC.git mfc - name: Stage run: | @@ -56,7 +56,7 @@ jobs: cp mfc/.github/.dockerignore /mnt/share/ - name: Build and Deploy - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: builder: default context: /mnt/share @@ -83,23 +83,16 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Create and Push Manifest Lists + env: + TAG: ${{ needs.Container.outputs.tag }} + REGISTRY: ${{ secrets.DOCKERHUB_USERNAME }}/mfc run: | - docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04 \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04-arm - docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu - - docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-cpu \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04 \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-cpu-ubuntu-22.04-arm - docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-cpu - - docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04 \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04-arm - docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu - - docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-gpu \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04 \ - ${{ secrets.DOCKERHUB_USERNAME }}/mfc:${{ env.TAG }}-gpu-ubuntu-22.04-arm - docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/mfc:latest-gpu \ No newline at end of file + docker manifest create $REGISTRY:$TAG-cpu $REGISTRY:$TAG-cpu-ubuntu-22.04 $REGISTRY:$TAG-cpu-ubuntu-22.04-arm + docker manifest create $REGISTRY:$TAG-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm + docker manifest create $REGISTRY:latest-cpu $REGISTRY:$TAG-cpu-ubuntu-22.04 $REGISTRY:$TAG-cpu-ubuntu-22.04-arm + docker manifest create $REGISTRY:latest-gpu $REGISTRY:$TAG-gpu-ubuntu-22.04 $REGISTRY:$TAG-gpu-ubuntu-22.04-arm + + docker manifest push $REGISTRY:$TAG-cpu + docker manifest push $REGISTRY:$TAG-gpu + docker manifest push $REGISTRY:latest-cpu + docker manifest push $REGISTRY:latest-gpu \ No newline at end of file From 3297583fc89e3acb743307d1252e9eb79db79763 Mon Sep 17 00:00:00 2001 From: Malmahrouqi3 Date: Wed, 6 Aug 2025 22:21:19 -0400 Subject: [PATCH 5/5] updated workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a36db5bb24..1a6d44a8cb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,7 +10,7 @@ on: required: true concurrency: - group: Containerization-${{ github.event.inputs.tag || github.ref_name }} + group: Containerization cancel-in-progress: false jobs: