From 3f75a6c66a7c65db4ccc51e9cc687b1f7d75cfc8 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 12:24:32 +0200 Subject: [PATCH 1/4] remove deprecated findFFTW that fails on runners --- CMakeLists.txt | 63 ++++++++++++++++++++++++++-------------------- src/CMakeLists.txt | 4 +-- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98dc87d9..12b0cd08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,36 +80,45 @@ find_package (LAPACK REQUIRED) # Find FFTW3. # Intel oneAPI has FFT3 available as part of MKL. Just linking against MKL gives FFTW functionality. if (NOT ${BLA_VENDOR} MATCHES "^Intel") - # For standard FFTW library - # We are using findfftw module from github/egpbos. - # PPPL provides fftwconfig.cmake. We could try that first in future - - # To guide cmake to the location of FFT, set FFTW_ROOT to the path of FFTW - # Ex: For PPPL gcc suite of compilers, - # We are using FFTW find module from github.com/egpbos - # - configure_file(downloadFindFFTW.cmake.in findFFTW-download/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download ) - if(result) - message(FATAL_ERROR "CMake step for findFFTW failed: ${result}") - else() - message("CMake step for findFFTW completed (${result}).") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download ) - if(result) - message(FATAL_ERROR "Build step for findFFTW failed: ${result}") - endif() + find_package(FFTW3 REQUIRED) + + # will find it, but FFTW_LIBRARIES is set to 'fftw3' simple string, which F2py does not like + + # Hack to find the proper .so looking first in conda, then in other + set(FFTW3_LIBRARY_PATHS) # Initialize empty list + + if(DEFINED CONDA_PREFIX) + list(APPEND FFTW3_LIBRARY_PATHS "${CONDA_PREFIX}/lib") # Add Conda first + endif() + + list(APPEND FFTW3_LIBRARY_PATHS + /usr/lib + /usr/local/lib + ${FFTW3_ROOT_DIR}/lib + ) + # also add a path relative to the found include dirs, which is a true path + if(FFTW3_INCLUDE_DIRS) + string(REPLACE "/include" "/lib" FFTW3_LIBRARY_DIR_FROM_INCLUDE "${FFTW3_INCLUDE_DIRS}") + list(APPEND FFTW3_LIBRARY_PATHS ${FFTW3_LIBRARY_DIR_FROM_INCLUDE}) + endif() + + # Find the library using the constructed list of paths. Should find the path to the .so + find_library(FFTW3_LIBRARY_TRUE + NAMES fftw3 + PATHS ${FFTW3_LIBRARY_PATHS} + NO_DEFAULT_PATH + ) + + if(FFTW3_LIBRARY_TRUE) + message(STATUS "FFTW3 Library with full path found: ${FFTW3_LIBRARY_TRUE}") + set(FFTW3_FULL_PATH ${FFTW3_LIBRARY}) + else() + message(FATAL_ERROR "Could not find FFTW3 library with find_library.") + endif() - set(findFFTW_DIR ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-src) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${findFFTW_DIR}") - find_package(FFTW REQUIRED) else() # Not required for OneAPI, but for older versions - set(FFTW_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) + set(FFTW3_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) endif() # Find HDF5 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcc9bfb3..387457d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -262,11 +262,11 @@ target_include_directories(spec PUBLIC ${HDF5_C_INCLUDE_DIRS} ${HDF5_Fortran_INC # MKL could be used for all the three target_link_libraries(spec PUBLIC - ${FFTW_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} + ${FFTW3_LIBRARY_TRUE} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ) target_include_directories(spec PUBLIC - ${FFTW_INCLUDE_DIRS} ${LAPACK_INCLUDE_DIRS} ${BLAS_INCLUDE_DIRS} + ${FFTW3_INCLUDE_DIRS} ${LAPACK_INCLUDE_DIRS} ${BLAS_INCLUDE_DIRS} ) #if(SKBUILD) From 8656934c65c7a102e62b40f61798c0025ea25064 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 13:16:42 +0200 Subject: [PATCH 2/4] find fftw in specific folders --- CMakeLists.txt | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b0cd08..d8ef131e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,42 +80,46 @@ find_package (LAPACK REQUIRED) # Find FFTW3. # Intel oneAPI has FFT3 available as part of MKL. Just linking against MKL gives FFTW functionality. if (NOT ${BLA_VENDOR} MATCHES "^Intel") - find_package(FFTW3 REQUIRED) - - # will find it, but FFTW_LIBRARIES is set to 'fftw3' simple string, which F2py does not like - # Hack to find the proper .so looking first in conda, then in other - set(FFTW3_LIBRARY_PATHS) # Initialize empty list + set(FFTW3_TEST_PATHS) # Initialize empty list if(DEFINED CONDA_PREFIX) - list(APPEND FFTW3_LIBRARY_PATHS "${CONDA_PREFIX}/lib") # Add Conda first + list(APPEND FFTW3_TEST_PATHS "${CONDA_PREFIX}/lib") # Add Conda first endif() - list(APPEND FFTW3_LIBRARY_PATHS + list(APPEND FFTW3_TEST_PATHS /usr/lib /usr/local/lib ${FFTW3_ROOT_DIR}/lib ) - # also add a path relative to the found include dirs, which is a true path - if(FFTW3_INCLUDE_DIRS) - string(REPLACE "/include" "/lib" FFTW3_LIBRARY_DIR_FROM_INCLUDE "${FFTW3_INCLUDE_DIRS}") - list(APPEND FFTW3_LIBRARY_PATHS ${FFTW3_LIBRARY_DIR_FROM_INCLUDE}) - endif() # Find the library using the constructed list of paths. Should find the path to the .so find_library(FFTW3_LIBRARY_TRUE NAMES fftw3 - PATHS ${FFTW3_LIBRARY_PATHS} - NO_DEFAULT_PATH + PATHS ${FFTW3_TEST_PATHS} + ) + + + set(FFTW_INC_TEST_PATHS) # Initialize an empty list for include paths + + foreach(path ${FFTW3_TEST_PATHS}) + string(REGEX REPLACE "/lib$" "/include" INCLUDE_PATH "${path}") + list(APPEND FFTW_INC_TEST_PATHS "${INCLUDE_PATH}") + endforeach() + + find_path(FFTW3_INCLUDE_DIRS # Use FFTW3_INCLUDE_DIRS as in the normal find_package call. + NAMES fftw3.f90 fftw3.h # Check for both Fortran and C headers + PATHS ${FFTW_INC_TEST_PATHS} + REQUIRED ) - if(FFTW3_LIBRARY_TRUE) - message(STATUS "FFTW3 Library with full path found: ${FFTW3_LIBRARY_TRUE}") - set(FFTW3_FULL_PATH ${FFTW3_LIBRARY}) - else() - message(FATAL_ERROR "Could not find FFTW3 library with find_library.") + if(NOT FFTW3_LIBRARY_TRUE) + message(FATAL_ERROR "Could not find FFTW3 library with find_library.") endif() + message(STATUS "found fftw3 library with path: ${FFTW3_LIBRARY_TRUE}") + message(STATUS "found fftw3 include dir with path: ${FFTW3_INCLUDE_DIRS}") + else() # Not required for OneAPI, but for older versions set(FFTW3_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) From 86c9a9ef3f968f4dcbe1dbe37dbd3d79a13b886d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 13:41:05 +0200 Subject: [PATCH 3/4] Remove specific hdf5 install in workflow --- .github/workflows/build.yml | 2 +- .github/workflows/build_cmake.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2dd748a1..1e2cd829 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib cd ${{ github.workspace }}/Utilities/pythontools pip3 install -v . diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 60496cd5..39d52a37 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -15,7 +15,7 @@ jobs: - name: Install prereqs run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev pip3 install --upgrade pip pip3 install --user ninja cmake scipy pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib From 24f45ba90ce33ab57eed1bac40c59f996226ecca Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 14:07:01 +0200 Subject: [PATCH 4/4] downgrade to python3.11 as install fails for 3.12 (numpy/f2py/meson issue?) --- .github/workflows/python_wrapper.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 8977807c..bae90752 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -8,6 +8,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + # Python3 should be pre-installed on 'ubuntu-latest' - name: Python version info run: |