From 2d1de77b5cf1e8b0977e4937eb1222803d8286e2 Mon Sep 17 00:00:00 2001 From: Henry Le Berre Date: Fri, 13 Sep 2024 08:24:30 -0400 Subject: [PATCH] Remove deprecated build hacks. Includes move to CCE18 (Frontier) (#620) --- .github/workflows/docker.yml | 29 ----- .github/workflows/frontier/build.sh | 2 +- .github/workflows/frontier/test.sh | 2 +- .github/workflows/test.yml | 36 ++----- .gitignore | 1 - CMakeLists.txt | 14 +-- README.md | 7 +- docs/documentation/getting-started.md | 94 ++-------------- mfc.bat | 37 ------- mfc.sh | 2 - src/simulation/m_start_up.fpp | 12 --- toolchain/Dockerfile | 24 ----- toolchain/bootstrap/docker.sh | 33 ------ toolchain/cce_simulation_workgroup_256.sh | 48 --------- toolchain/cmake/FindcuTENSOR.cmake | 37 ------- toolchain/cmake/{ => cce}/FindHDF5.cmake | 0 toolchain/cmake/{ => regular}/FindFFTW.cmake | 0 toolchain/cmake/{ => regular}/FindSILO.cmake | 0 toolchain/dependencies/CMakeLists.txt | 107 +++++++++++-------- toolchain/dependencies/Silo-GNU-13.patch | 31 ------ toolchain/mfc/args.py | 6 +- toolchain/mfc/build.py | 33 ++---- toolchain/templates/include/helpers.mako | 6 -- 23 files changed, 95 insertions(+), 466 deletions(-) delete mode 100644 .github/workflows/docker.yml delete mode 100644 toolchain/Dockerfile delete mode 100644 toolchain/bootstrap/docker.sh delete mode 100755 toolchain/cce_simulation_workgroup_256.sh delete mode 100644 toolchain/cmake/FindcuTENSOR.cmake rename toolchain/cmake/{ => cce}/FindHDF5.cmake (100%) rename toolchain/cmake/{ => regular}/FindFFTW.cmake (100%) rename toolchain/cmake/{ => regular}/FindSILO.cmake (100%) delete mode 100644 toolchain/dependencies/Silo-GNU-13.patch diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index a6c019f427..0000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Docker Publisher - -on: - push: - branches: [ "master" ] - paths: - - toolchain/Dockerfile - - workflow_dispatch: - -jobs: - push_to_registry: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build & Publish thereto - uses: docker/build-push-action@v4 - with: - file: toolchain/Dockerfile - push: true - tags: ${{ secrets.DOCKER_USERNAME }}/mfc:latest diff --git a/.github/workflows/frontier/build.sh b/.github/workflows/frontier/build.sh index e04f321e15..a6a51b65f0 100644 --- a/.github/workflows/frontier/build.sh +++ b/.github/workflows/frontier/build.sh @@ -1,4 +1,4 @@ #!/bin/bash . ./mfc.sh load -c f -m g -./mfc.sh build -j 8 --gpu --sys-hdf5 --sys-fftw +./mfc.sh build -j 8 --gpu diff --git a/.github/workflows/frontier/test.sh b/.github/workflows/frontier/test.sh index 5725cf4e76..12a81d2c13 100644 --- a/.github/workflows/frontier/test.sh +++ b/.github/workflows/frontier/test.sh @@ -3,5 +3,5 @@ gpus=`rocm-smi --showid | awk '{print $1}' | grep -Eo '[0-9]+' | uniq | tr '\n' ' '` ngpus=`echo "$gpus" | tr -d '[:space:]' | wc -c` -./mfc.sh test --max-attempts 3 -j $ngpus --sys-hdf5 --sys-fftw -- -c frontier +./mfc.sh test --max-attempts 3 -j $ngpus -- -c frontier diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65515d3a59..248c072112 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,23 +48,17 @@ jobs: - name: Setup MacOS if: matrix.os == 'macos' - run: | - brew install wget make python make cmake coreutils gcc@14 - echo "CC=gcc-14" >> $GITHUB_ENV - echo "CXX=g++-14" >> $GITHUB_ENV + run: | + brew install coreutils python cmake fftw hdf5 gcc@14 open-mpi echo "FC=gfortran-14" >> $GITHUB_ENV - - - name: (MacOS) Build OpenMPI - if: matrix.os == 'macos' && matrix.mpi == 'mpi' - run: | - brew install mpich - name: Setup Ubuntu if: matrix.os == 'ubuntu' && matrix.intel == false run: | sudo apt update -y - sudo apt install -y tar wget make cmake gcc g++ python3 python3-dev "openmpi-*" libopenmpi-dev - + sudo apt install -y cmake gcc g++ python3 python3-dev hdf5-tools \ + libfftw3-dev libhdf5-dev openmpi-bin libopenmpi-dev + - name: Setup Ubuntu (Intel) if: matrix.os == 'ubuntu' && matrix.intel == true run: | @@ -83,34 +77,22 @@ jobs: echo "OMPI_FC=$(which ifort)" >> $GITHUB_ENV echo "OMPI_CXX=$(which icpc)" >> $GITHUB_ENV echo "OMPI_MPICC=$(which icc)" >> $GITHUB_ENV - echo "MPI_HOME=/opt/intel/oneapi/mpi/2021.7.1/" >> $GITHUB_ENV - echo "I_MPI_ROOT=/opt/intel/oneapi/mpi/2021.7.1/" >> $GITHUB_ENV + echo "MPI_HOME=/opt/intel/oneapi/mpi/2021.7.1/" >> $GITHUB_ENV + echo "I_MPI_ROOT=/opt/intel/oneapi/mpi/2021.7.1/" >> $GITHUB_ENV - name: Build run: | - if [ '${{ matrix.intel }}' == 'true' ]; then source /opt/intel/oneapi/setvars.sh; fi + if [ '${{ matrix.intel }}' == 'true' ]; then . /opt/intel/oneapi/setvars.sh; fi /bin/bash mfc.sh build -j $(nproc) --${{ matrix.debug }} --${{ matrix.mpi }} - name: Test run: | - if [ '${{ matrix.intel }}' == 'true' ]; then source /opt/intel/oneapi/setvars.sh; fi + if [ '${{ matrix.intel }}' == 'true' ]; then . /opt/intel/oneapi/setvars.sh; fi /bin/bash mfc.sh test --max-attempts 3 -j $(nproc) $OPT1 $OPT2 env: OPT1: ${{ matrix.mpi == 'mpi' && '--test-all' || '' }} OPT2: ${{ matrix.debug == 'debug' && '-% 20' || '' }} - docker: - name: Github | Docker - if: needs.file-changes.outputs.checkall == 'true' - needs: file-changes - runs-on: ubuntu-latest - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: Test - run: sudo ./mfc.sh docker ./mfc.sh test --max-attempts 3 -j $(nproc) -a - self: name: Self Hosted if: github.repository == 'MFlowCode/MFC' && needs.file-changes.outputs.checkall == 'true' diff --git a/.gitignore b/.gitignore index 4d85ff4422..cbd181b9fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules/ package.json yarn.lock -docker-compose.yml .venv/ /build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e9a0bbd4df..7d05c9c19a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,10 @@ find_program(FYPP_EXE fypp REQUIRED) link_libraries("${CMAKE_DL_LIBS}") set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) -list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cmake") +list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cmake/regular") +if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") + list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cmake/cce") +endif() # Compiler Flags: Here, we specify our own compiler flags for both release and @@ -526,15 +529,6 @@ if (MFC_SIMULATION) MFC_SETUP_TARGET(TARGET simulation SOURCES "${simulation_SRCs}" MPI OpenACC FFTW) - - if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray" AND MFC_OpenACC) - add_custom_command(TARGET simulation POST_BUILD - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cce_simulation_workgroup_256.sh" - "${CMAKE_CURRENT_BINARY_DIR}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Patching & Rebuilding with Cray hacks" - ) - endif() endif() if (MFC_POST_PROCESS) diff --git a/README.md b/README.md index f4783eb695..f816174f78 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ It's rather straightforward. We'll give a brief intro. here for MacOS. Using [brew](https://brew.sh), install MFC's dependencies: ```shell -brew install wget python cmake gcc@14 mpich +brew install coreutils python cmake fftw hdf5 gcc open-mpi ``` You're now ready to build and test MFC! Put it to a convenient directory via @@ -66,11 +66,6 @@ Put it to a convenient directory via git clone https://github.com/MFlowCode/MFC cd MFC ``` -and be sure MFC knows what compilers to use by appending and sourcing your `~/.profile` file via this command -```shell -echo -e "export CC=gcc-14 \nexport CXX=g++-14 \nexport FC=gfortran-14" >> ~/.profile -source ~/.profile -``` then you can build MFC and run the test suite! ```shell ./mfc.sh build -j $(nproc) diff --git a/docs/documentation/getting-started.md b/docs/documentation/getting-started.md index a99f8dd051..a68ebe9274 100644 --- a/docs/documentation/getting-started.md +++ b/docs/documentation/getting-started.md @@ -28,22 +28,10 @@ Please select your desired configuration from the list bellow: ```shell sudo apt update sudo apt upgrade -sudo apt install tar wget make cmake gcc g++ \ - python3 python3-dev \ - "openmpi-*" libopenmpi-dev \ - python3-venv -``` - -- **Via Pacman (Arch):** - -```shell -sudo pacman -Syu -sudo pacman -S base-devel coreutils \ - git ninja gcc-fortran \ - cmake openmpi python3 \ - python-pip openssh \ - python-virtualenv vim \ - wget tree +sudo apt install tar wget make cmake gcc g++ \ + python3 python3-dev python3-venv \ + openmpi-bin libopenmpi-dev \ + libhdf5-dev libfftw3-dev ``` If you wish to build MFC using [NVidia's NVHPC SDK](https://developer.nvidia.com/hpc-sdk), @@ -55,8 +43,8 @@ first follow the instructions [here](https://developer.nvidia.com/nvidia-hpc-sdk

Windows

On Windows, you can either use Intel Compilers with the standard Microsoft toolchain, -[Docker](https://docs.docker.com/get-docker/) or the -[Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) for a Linux experience. +or the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) +for a Linux experience.
@@ -113,82 +101,16 @@ You will also have access to the `.sln` Microsoft Visual Studio solution files f

MacOS

- - **If you use [ZSH]** (Verify with `echo $SHELL`) +Using [Homebrew](https://brew.sh/) you can install the necessary dependencies: ```shell -touch ~/.zshrc -open ~/.zshrc -``` - - - **If you use [BASH]** (Verify with `echo $SHELL`) - -```shell -touch ~/.bash_profile -open ~/.bash_profile -``` - -An editor should open. -Please paste the following lines into it before saving the file. -Modify the first assignment if you wish to use a different version of GNU's GCC. -These lines ensure that LLVM's Clang and Apple's modified version of GCC are not used to compile MFC. -Further reading on `open-mpi` incompatibility with `clang`-based `gcc` on macOS: [here](https://stackoverflow.com/questions/27930481/how-to-build-openmpi-with-homebrew-and-gcc-4-9). -We do *not* support `clang` due to conflicts with the Silo dependency. - -```shell -export MFC_GCC_VER=13 -export CC=gcc-$MFC_GCC_VER -export CXX=g++-$MFC_GCC_VER -export FC=gfortran-$MFC_GCC_VER -``` - -**Close the open editor and terminal window**. Open a **new terminal** window before executing the commands below. - -```shell -brew install wget python cmake gcc@$MFC_GCC_VER mpich +brew install coreutils python cmake fftw hdf5 gcc open-mpi ``` They will download the dependencies MFC requires to build itself.
-
-

Docker

- -Docker is a lightweight, cross-platform, and performant alternative to Virtual Machines (VMs). -We build a Docker Image that contains the packages required to build and run MFC on your local machine. - -First, install Docker and Git: -- Windows: [Docker](https://docs.docker.com/get-docker/) + [Git](https://git-scm.com/downloads). -- macOS: `brew install git docker` (requires [Homebrew](https://brew.sh/)). -- Other systems: -```shell -sudo apt install git docker # Debian / Ubuntu via Aptitude -sudo pacman -S git docker # Arch Linux via Pacman -``` - -Once Docker and Git are installed on your system, clone MFC with - -```shell -git clone https://github.com/MFlowCode/MFC -cd MFC -``` - -To fetch the prebuilt Docker image and enter an interactive bash session with the -recommended settings applied, run - -```shell - ./mfc.sh docker # If on \*nix/macOS - .\mfc.bat docker # If on Windows -``` - -We automatically mount and configure the proper permissions for you to access your local copy of MFC, available at `~/MFC`. -You will be logged in as the `me` user with root permissions. - -:warning: The state of your container is entirely transient, except for the MFC mount. -Thus, any modification outside of `~/MFC` should be considered permanently lost upon session exit. - -
- ## Building MFC MFC can be built with support for various (compile-time) features: diff --git a/mfc.bat b/mfc.bat index 1cb8433caf..bb0dedef1e 100644 --- a/mfc.bat +++ b/mfc.bat @@ -1,7 +1,5 @@ @echo off -if "%1" == "docker" goto label_docker - goto label_windows :label_windows @@ -54,38 +52,3 @@ if %main_py_err% neq 0 ( exit /b %main_py_err% :label_windows_after - - -:label_docker -where docker >nul 2>nul -if %errorlevel% neq 0 ( - echo. - echo ^[mfc.bat^] You must have Docker installed. - echo Please install Docker and try again. - exit /b 1 -) - - -echo ^[mfc.bat^] Fetching image... -docker pull henryleberre/mfc -if %errorlevel% neq 0 ( - echo. - echo ^[mfc.bat^] Docker: Failed to fetch image. - echo Pleasure ensure docker is running. - exit /b 1 -) - -echo ^[mfc.bat^] Starting container... -docker run --interactive --tty --rm ^ - --mount type=bind,source="%cd%",target=/home/me/MFC ^ - henryleberre/mfc - -if %errorlevel% neq 0 ( - echo. - echo Docker: Fatal container runtime error. - exit /b 1 -) - - -exit /b 0 -:label_docker_after diff --git a/mfc.sh b/mfc.sh index 5ebae5023f..027f22d940 100755 --- a/mfc.sh +++ b/mfc.sh @@ -32,8 +32,6 @@ elif [ "$1" '==' "format" ]; then . "$(pwd)/toolchain/bootstrap/python.sh" shift; . "$(pwd)/toolchain/bootstrap/format.sh" $@; exit 0 -elif [ "$1" '==' "docker" ]; then - shift; . "$(pwd)/toolchain/bootstrap/docker.sh" $@; exit 0 elif [ "$1" '==' "venv" ]; then shift; . "$(pwd)/toolchain/bootstrap/python.sh" $@; return elif [ "$1" '==' "clean" ]; then diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index 4feb49a42a..5414bed23d 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -127,8 +127,6 @@ contains integer :: iostatus !! Integer to check iostat of file read - CHARACTER(len=511) :: CRAY_ACC_MODULE - character(len=1000) :: line ! Namelist of the global parameters which may be specified by user @@ -200,16 +198,6 @@ contains call s_mpi_abort(trim(file_path)//' is missing. Exiting ...') end if -#ifdef _CRAYFTN -#ifdef MFC_OpenACC - call get_environment_variable("CRAY_ACC_MODULE", CRAY_ACC_MODULE) - - if (CRAY_ACC_MODULE == "") then - call s_mpi_abort("CRAY_ACC_MODULE is not set. Exiting...") - end if -#endif -#endif - end subroutine s_read_input_file !> The goal of this procedure is to verify that each of the diff --git a/toolchain/Dockerfile b/toolchain/Dockerfile deleted file mode 100644 index 4d16f0e5d8..0000000000 --- a/toolchain/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM ubuntu:jammy -MAINTAINER Henry Le Berre - -ENV PS1='[\u@mfc] \e[1;32m\w\e[0m \$ ' -ENV CMAKE_GENERATOR=Ninja - -RUN apt update && apt upgrade -y - -RUN apt install -y git tar wget make cmake ninja-build gcc g++ \ - python3 python3-dev python3-pip python3-venv \ - 'openmpi-*' libopenmpi-dev sudo vim nano \ - hdf5-tools - -RUN groupadd --gid 1000 me && \ - useradd --uid 1000 --gid 1000 -m me - -RUN echo me ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/me && \ - chmod 0440 /etc/sudoers.d/me - -USER me - -RUN pip3 install fypp rich pyyaml - -CMD ["/bin/bash"] diff --git a/toolchain/bootstrap/docker.sh b/toolchain/bootstrap/docker.sh deleted file mode 100644 index 73e61372df..0000000000 --- a/toolchain/bootstrap/docker.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -if ! command -v docker > /dev/null 2>&1; then - error "$MAGENTA""Docker$COLOR_RESET is not installed." - - exit 1 -fi - -log "Running in$MAGENTA Docker$COLOR_RESET mode." - -if [ -t 1 ]; then - dockerintopts='--interactive --tty' -fi - -__docker_run() { - docker run $dockerintopts --rm --workdir /home/me/MFC \ - --mount type=bind,source="$(pwd)",target=/home/me/MFC \ - sbryngelson/mfc:latest $@ -} - -__docker_run sudo chown -R me:me /home/me/MFC -if (($?)); then - error "Docker: Failed to set directory permissions on MFC mount.." - - exit 1 -fi - -__docker_run $@ -if (($?)); then - error "Error running Docker container with $@." - - exit 1 -fi \ No newline at end of file diff --git a/toolchain/cce_simulation_workgroup_256.sh b/toolchain/cce_simulation_workgroup_256.sh deleted file mode 100755 index 9137871d54..0000000000 --- a/toolchain/cce_simulation_workgroup_256.sh +++ /dev/null @@ -1,48 +0,0 @@ -#! /bin/bash - -# On Frontier, after building simulation run the script -# ./cce_simulation_workgroup_256.sh to edit the workgroup -# size in the generated code and recompile, then set the recommended -# environment variable to use the new code. - -# Using the script requires `-hkeepfiles` at link! - -# This script needs to be run after every time simulation -# is built to generate a correct offload binary. -# This include case-optimization builds! - -CCE_LLVM_PATH=${CRAY_CCE_CLANGSHARE}/../ - -## This was errantly 1024 by default in the generated binary -WGSIZE=256 - -## Turning bitcode into human-readable IR -echo "Disassembling" -${CCE_LLVM_PATH}/bin/llvm-dis "$1/simulation-cce-openmp-pre-llc.bc" - -## Find/replace the workgroup size to what it _should be_ in the (human readable) IR -echo "Globally setting amdgpu-flat-work-group-size size to 1,$WGSIZE" -sed "s/\"amdgpu-flat-work-group-size\"\=\"1,1024\"/\"amdgpu-flat-work-group-size\"\=\"1,${WGSIZE}\"/g" "$1/simulation-cce-openmp-pre-llc.ll" > "$1/simulation-cce-openmp-pre-llc-wg${WGSIZE}.ll" - -## This is building to an AMD GPU code object, using internal copy/pasted Cray Fortran flags. -## The flags may need to be adjusted for future compiler versions -echo "Invoking LLC to compile" -${CCE_LLVM_PATH}/bin/llc -mtriple=amdgcn-amd-amdhsa -disable-promote-alloca-to-lds -mcpu=gfx90a -amdgpu-dump-hsa-metadata "$1/simulation-cce-openmp-pre-llc-wg${WGSIZE}.ll" -filetype=obj -o "$1/simulation-cce-openmp__llc_wg${WGSIZE}.amdgpu" - -## Wrapping AMD GPU code object in an object that CCE OpenACC runtime understands -echo "Linking to a CCE Offload module" -${CCE_LLVM_PATH}/bin/lld -flavor gnu --no-undefined -shared -o "$1/simulation-wg${WGSIZE}.lld.exe" "$1/simulation-cce-openmp__llc_wg${WGSIZE}.amdgpu" - -## Backend/hidden env var that tells the runtime where to find the offload object -echo "Now " -echo "export CRAY_ACC_MODULE=${PWD}/build/simulation/simulation-wg${WGSIZE}.lld.exe" -echo "to use the new GPU offload code." -echo "To use the original build" -echo "unset CRAY_ACC_MODULE" - -# # This goes inside an sbatch script for multi-node submissions (> 1000 nodes important) -# # Requet an nvme via -# #SBATCH -C nvme -# # Put this in the sbatch script before execution via srun -# sbcast -pf ${PWD}/build/simulation/simulation-wg${WGSIZE}.lld.exe /mnt/bb/$USER/simulation-wg${WGSIZE}.lld.exe -# export CRAY_ACC_MODULE=/mnt/bb/$USER/simulation-wg${WGSIZE}.lld.exe" diff --git a/toolchain/cmake/FindcuTENSOR.cmake b/toolchain/cmake/FindcuTENSOR.cmake deleted file mode 100644 index 827d07fe81..0000000000 --- a/toolchain/cmake/FindcuTENSOR.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# Attempt to find NVIDIA cuTENSOR -# URL: https://developer.nvidia.com/cutensor -# DOCS: https://cmake.org/cmake/help/latest/command/find_library.html -# https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html - -cmake_minimum_required(VERSION 3.18) - -INCLUDE(FindPackageHandleStandardArgs) - -FIND_PACKAGE(CUDAToolkit) - -MESSAGE(STATUS "CUDAToolkit_LIBRARY_ROOT=${CUDAToolkit_LIBRARY_ROOT}") - -FIND_LIBRARY(cuTENSOR_LIBRARY - NAMES cutensor - HINTS "${CUDAToolkit_LIBRARY_ROOT}/../../math_libs" - NAMES_PER_DIR -) - - -FIND_PACKAGE_HANDLE_STANDARD_ARGS( - cuTENSOR - REQUIRED_VARS - cuTENSOR_LIBRARY -) - -IF (cuTENSOR_FOUND AND NOT TARGET cuTENSOR::cuTENSOR) - SET(cuTENSOR_LIBRARIES "${cuTENSOR_LIBRARY}") - SET(cuTENSOR_INCLUDE_DIRS "${cuTENSOR_INCLUDE_DIR}") - - ADD_LIBRARY(cuTENSOR::cuTENSOR UNKNOWN IMPORTED) - - SET_TARGET_PROPERTIES(cuTENSOR::cuTENSOR PROPERTIES - IMPORTED_LOCATION "${cuTENSOR_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${cuTENSOR_INCLUDE_DIRS}" - ) -ENDIF() diff --git a/toolchain/cmake/FindHDF5.cmake b/toolchain/cmake/cce/FindHDF5.cmake similarity index 100% rename from toolchain/cmake/FindHDF5.cmake rename to toolchain/cmake/cce/FindHDF5.cmake diff --git a/toolchain/cmake/FindFFTW.cmake b/toolchain/cmake/regular/FindFFTW.cmake similarity index 100% rename from toolchain/cmake/FindFFTW.cmake rename to toolchain/cmake/regular/FindFFTW.cmake diff --git a/toolchain/cmake/FindSILO.cmake b/toolchain/cmake/regular/FindSILO.cmake similarity index 100% rename from toolchain/cmake/FindSILO.cmake rename to toolchain/cmake/regular/FindSILO.cmake diff --git a/toolchain/dependencies/CMakeLists.txt b/toolchain/dependencies/CMakeLists.txt index baa3f3991e..116e288711 100644 --- a/toolchain/dependencies/CMakeLists.txt +++ b/toolchain/dependencies/CMakeLists.txt @@ -3,10 +3,11 @@ cmake_minimum_required(VERSION 3.12) -project(MFC-Dependencies LANGUAGES Fortran) +project(MFC-Dependencies LANGUAGES C CXX Fortran) -if (MFC_SILO OR NOT CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") - enable_language(C CXX) +list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/regular") +if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") + list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cce") endif() set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) @@ -25,63 +26,75 @@ option(MFC_HIPFORT "Build the HIPFORT dependency" OFF) # FFTW3 if (MFC_FFTW) - if (NOT CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") - ExternalProject_Add(fftw - URL "http://www.fftw.org/fftw-3.3.10.tar.gz" - CMAKE_ARGS -DBUILD_TESTS=OFF - -DBUILD_SHARED_LIBS=OFF - "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" - ) - else() - message(WARNING "The Fortran compiler vendor is Cray so FFTW3 will not be built. We will use cray-fftw instead.") + find_package(FFTW QUIET) + if (FFTW_FOUND) + message(STATUS "FFTW found.") add_custom_target(fftw) + else() + if (NOT CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") + ExternalProject_Add(fftw + URL "http://www.fftw.org/fftw-3.3.10.tar.gz" + CMAKE_ARGS -DBUILD_TESTS=OFF + -DBUILD_SHARED_LIBS=OFF + "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + ) + else() + message(WARNING "The Fortran compiler vendor is Cray so FFTW3 will not be built. We will use cray-fftw instead.") + add_custom_target(fftw) + endif() endif() endif() # HDF5 if (MFC_HDF5) - ExternalProject_Add(hdf5 - GIT_REPOSITORY "https://github.com/HDFGroup/hdf5" - GIT_TAG hdf5-1_12_2 - GIT_SHALLOW ON - GIT_PROGRESS ON - CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" - -DBUILD_SHARED_LIBS=OFF - -DFORTRAN_LIBRARIES=ON - -DBUILD_TESTING=OFF - -DHDF5_BUILD_UTILS=OFF - -DHDF5_BUILD_TOOLS=ON - -DHDF5_BUILD_EXAMPLES=OFF - ) + find_package(HDF5) + if (HDF5_FOUND) + message(STATUS "HDF5 found.") + add_custom_target(hdf5) + else() + ExternalProject_Add(hdf5 + GIT_REPOSITORY "https://github.com/HDFGroup/hdf5" + GIT_TAG hdf5-1_12_2 + GIT_SHALLOW ON + GIT_PROGRESS ON + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + -DBUILD_SHARED_LIBS=OFF + -DFORTRAN_LIBRARIES=ON + -DBUILD_TESTING=OFF + -DHDF5_BUILD_UTILS=OFF + -DHDF5_BUILD_TOOLS=ON + -DHDF5_BUILD_EXAMPLES=OFF + ) + endif() endif() # SILO if (MFC_SILO) - find_package(Git REQUIRED) - - # If we are using the CCE, HDF5 is not built, and we wish to find - # the system's cray-hdf5. Otherwise, we point SILO to find HDF5 in - # our common install directory using SILO_HDF5_DIR. - ExternalProject_Add(silo - GIT_REPOSITORY "https://github.com/LLNL/Silo" - GIT_TAG 438477c80d32a3e1757d4584b993f382cace1535 - GIT_PROGRESS ON - PATCH_COMMAND "${GIT_EXECUTABLE}" stash - && "${GIT_EXECUTABLE}" apply "${CMAKE_SOURCE_DIR}/Silo.patch" - && "${GIT_EXECUTABLE}" apply "${CMAKE_SOURCE_DIR}/Silo-GNU-13.patch" - CMAKE_ARGS -DSILO_ENABLE_SHARED=OFF - -DSILO_ENABLE_SILOCK=OFF - -DSILO_ENABLE_BROWSER=OFF - -DHDF5_USE_STATIC_LIBRARIES=ON - "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" - "-DSILO_HDF5_DIR=${CMAKE_INSTALL_PREFIX}" - "$<$:-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/../cmake>" - ) + find_package(SILO) + if (SILO_FOUND) + message(STATUS "SILO found.") + add_custom_target(silo) + else() + find_package(Git REQUIRED) - if (MFC_HDF5) - add_dependencies(silo hdf5) + ExternalProject_Add(silo + GIT_REPOSITORY "https://github.com/LLNL/Silo" + GIT_TAG 9af504ef4fb79153e1fbf3bdb75421b6b65f6dc4 + GIT_PROGRESS ON + PATCH_COMMAND "${GIT_EXECUTABLE}" stash + && "${GIT_EXECUTABLE}" apply "${CMAKE_SOURCE_DIR}/Silo.patch" + CMAKE_ARGS -DSILO_ENABLE_SHARED=OFF + -DSILO_ENABLE_SILOCK=OFF + -DSILO_ENABLE_BROWSER=OFF + -DFIND_LIBRARY_USE_LIB64_PATHS=ON + "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" + "-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}" + "-DCMAKE_FIND_PACKAGE_REDIRECTS_DIR=${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}" + "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + "$<$:-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/../cmake/cce>" + ) endif() endif() diff --git a/toolchain/dependencies/Silo-GNU-13.patch b/toolchain/dependencies/Silo-GNU-13.patch deleted file mode 100644 index fd692c3b2a..0000000000 --- a/toolchain/dependencies/Silo-GNU-13.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 51f0a23e72b366358146bb272d6d5c297929b0b0 Mon Sep 17 00:00:00 2001 -From: Henry LE BERRE -Date: Thu, 30 May 2024 19:15:23 +0200 -Subject: [PATCH] Temporary GNU 13 Silo Build Fix - ---- - src/hdf5_drv/silo_hdf5.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/hdf5_drv/silo_hdf5.c b/src/hdf5_drv/silo_hdf5.c -index 9a00194..cc23fbf 100644 ---- a/src/hdf5_drv/silo_hdf5.c -+++ b/src/hdf5_drv/silo_hdf5.c -@@ -1810,8 +1810,12 @@ db_hdf5_cwg(DBfile *_dbfile) - else \ - *dscount = m.MEMCNT; \ - *dsnames = (char **) calloc(*dscount, sizeof(char**)); \ -- for (i = 0; i < *dscount; i++) \ -- (*dsnames)[i] = strdup(m.MEMNAME[i]); \ -+ if (sizeof(m.MEMNAME[0]) >= sizeof(char)) { \ -+ for (i = 0; i < *dscount; i++) \ -+ (*dsnames)[i] = strdup((char*)m.MEMNAME[i]); \ -+ } else { \ -+ (*dsnames)[0] = strdup((char*)m.MEMNAME); \ -+ } \ - break; \ - } - --- -2.45.1 - diff --git a/toolchain/mfc/args.py b/toolchain/mfc/args.py index a9c07fd59c..cad27120a0 100644 --- a/toolchain/mfc/args.py +++ b/toolchain/mfc/args.py @@ -1,7 +1,7 @@ import re, sys, os.path, argparse, dataclasses from .run.run import get_baked_templates -from .build import TARGETS, DEFAULT_TARGETS, DEPENDENCY_TARGETS +from .build import TARGETS, DEFAULT_TARGETS from .common import MFCException, format_list_to_string from .test.cases import list_cases @@ -61,10 +61,6 @@ def add_common_arguments(p, mask = None): if "v" not in mask: p.add_argument("-v", "--verbose", action="store_true", help="Enables verbose compiler & linker output.") - if "n" not in mask: - for target in DEPENDENCY_TARGETS: - p.add_argument(f"--sys-{target.name}", action="store_true", help=f"Do not build the {target.name} dependency. Use the system's instead.") - if "g" not in mask: p.add_argument("-g", "--gpus", nargs="+", type=int, default=None, help="(Optional GPU override) List of GPU #s to use (environment default if unspecified).") diff --git a/toolchain/mfc/build.py b/toolchain/mfc/build.py index 1658c0b220..bdcaf32ef5 100644 --- a/toolchain/mfc/build.py +++ b/toolchain/mfc/build.py @@ -57,15 +57,8 @@ def get_cmake_dirpath(self) -> str: ]) def get_install_dirpath(self, case: input.MFCInputFile) -> str: - # The install directory is located: - # Regular: /build/install/ - # Dependency: /build/install/dependencies (shared) - return os.sep.join([ - os.getcwd(), - "build", - "install", - 'dependencies' if self.isDependency else self.get_slug(case), - ]) + # The install directory is located /build/install/ + return os.sep.join([os.getcwd(), "build", "install", self.get_slug(case)]) def get_install_binpath(self, case: input.MFCInputFile) -> str: # /install//bin/ @@ -103,9 +96,10 @@ def configure(self, case: input.MFCInputFile): cmake_dirpath = self.get_cmake_dirpath() install_dirpath = self.get_install_dirpath(case) - install_prefixes = ';'.join([install_dirpath, get_dependency_install_dirpath(case)]) - - mod_dirs = ';'.join(['build/install/dependencies/include/hipfort/amdgcn']) + install_prefixes = ';'.join([ + t.get_install_dirpath(case) for t in self.requires.compute() + ]) + mod_dirs = f"{HIPFORT.get_install_dirpath(case)}/include/hipfort/amdgcn" flags: list = self.flags.copy() + [ # Disable CMake warnings intended for developers (us). @@ -130,6 +124,9 @@ def configure(self, case: input.MFCInputFile): # First directory that FIND_LIBRARY searches. # See: https://cmake.org/cmake/help/latest/command/find_library.html. f"-DCMAKE_FIND_ROOT_PATH={install_prefixes}", + # First directory that FIND_PACKAGE searches. + # See: https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_PACKAGE_REDIRECTS_DIR.html. + f"-DCMAKE_FIND_PACKAGE_REDIRECTS_DIR={install_prefixes}", # Location prefix to install bin/, lib/, include/, etc. # See: https://cmake.org/cmake/help/latest/command/install.html. f"-DCMAKE_INSTALL_PREFIX={install_dirpath}", @@ -189,7 +186,7 @@ def install(self, case: input.MFCInputFile): HIPFORT = MFCTarget('hipfort', ['-DMFC_HIPFORT=ON'], True, False, False, MFCTarget.Dependencies([], [], []), -1) PRE_PROCESS = MFCTarget('pre_process', ['-DMFC_PRE_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([], [], []), 0) SIMULATION = MFCTarget('simulation', ['-DMFC_SIMULATION=ON'], False, True, False, MFCTarget.Dependencies([], [FFTW], [HIPFORT]), 1) -POST_PROCESS = MFCTarget('post_process', ['-DMFC_POST_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([FFTW, SILO], [], []), 2) +POST_PROCESS = MFCTarget('post_process', ['-DMFC_POST_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([FFTW, HDF5, SILO], [], []), 2) SYSCHECK = MFCTarget('syscheck', ['-DMFC_SYSCHECK=ON'], False, False, True, MFCTarget.Dependencies([], [], [HIPFORT]), -1) DOCUMENTATION = MFCTarget('documentation', ['-DMFC_DOCUMENTATION=ON'], False, False, False, MFCTarget.Dependencies([], [], []), -1) @@ -215,16 +212,6 @@ def get_targets(targets: typing.List[typing.Union[str, MFCTarget]]) -> typing.Li return [ get_target(t) for t in targets ] -def get_dependency_install_dirpath(case: input.MFCInputFile) -> str: - # Since dependencies share the same install directory, we can just return - # the install directory of the first dependency we find. - for target in TARGETS: - if target.isDependency: - return target.get_install_dirpath(case) - - raise MFCException("No dependency target found.") - - def __build_target(target: typing.Union[MFCTarget, str], case: input.MFCInputFile, history: typing.Set[str] = None): if history is None: history = set() diff --git a/toolchain/templates/include/helpers.mako b/toolchain/templates/include/helpers.mako index 2a27491f90..149161e877 100644 --- a/toolchain/templates/include/helpers.mako +++ b/toolchain/templates/include/helpers.mako @@ -70,10 +70,6 @@ END % if os.name != 'nt': ok ":) Running$MAGENTA ${target.name}$COLOR_RESET:\n" - if [ '${target.name}' == 'simulation' ]; then - export CRAY_ACC_MODULE='${target.get_staging_dirpath(case)}/simulation-wg256.lld.exe' - fi - cd '${os.path.dirname(input)}' t_${target.name}_start=$(python3 -c 'import time; print(time.time())') @@ -98,8 +94,6 @@ END exit 1 fi - unset CRAY_ACC_MODULE - % if output_summary: cd '${MFC_ROOT_DIR}'