diff --git a/.github/actions/test-fc/action.yml b/.github/actions/test-fc/action.yml index 2f1cd4c..2d7212f 100644 --- a/.github/actions/test-fc/action.yml +++ b/.github/actions/test-fc/action.yml @@ -61,22 +61,6 @@ runs: } rm hw.exe - - name: Test compile Fortran (pwsh) - working-directory: test - if: ${{ (success() || failure()) && runner.os == 'Windows' }} - shell: pwsh - run: | - ${{ env.FC }} -o hw.exe hw.f90 - $output=$(& ".\hw.exe") - if ($output -match "hello world") { - write-output $output - } else { - write-output "unexpected output: $output" - exit 1 - } - rm hw.exe - - - name: Test compile Fortran (powershell) working-directory: test if: ${{ (success() || failure()) && runner.os == 'Windows' && inputs.compiler != 'lfortran' }} diff --git a/.github/actions/test-mkl/action.yml b/.github/actions/test-mkl/action.yml index 7b25e50..a586838 100644 --- a/.github/actions/test-mkl/action.yml +++ b/.github/actions/test-mkl/action.yml @@ -18,17 +18,39 @@ runs: working-directory: test shell: bash run: | - if [[ "${{ inputs.compiler }}" =~ "intel" ]] && [[ "${{ inputs.install_mkl }}" == "true" ]] && ([[ "${{ inputs.version }}" != "2021.5" ]] && [[ "$runner.os" != "macOS" ]]); then + # check settings if mkl tests should be run + # mkl cannot be installed for 2021.5 on macos; + # and for macos-14 also not 2021.6-2021.9 + mkl_tests=true + echo "$RUNNER_OS" + if [[ "${{ inputs.compiler }}" =~ "gcc" ]]; then mkl_tests=false; fi + if [[ "${{ inputs.compiler }}" =~ "lfortran" ]]; then mkl_tests=false; fi + if [[ "${{ inputs.compiler }}" =~ "nvidia" ]]; then mkl_tests=false; fi + if [[ "${{ inputs.install_mkl }}" == "false" ]]; then mkl_tests=false; fi + if [[ "${{ inputs.version }}" == "2021.5" ]] && [[ "$RUNNER_OS" == "macOS" ]]; then mkl_tests=false; fi + if [[ "$RUNNER_OS" == "macOS" ]]; then + macos_version=$(sw_vers | grep "ProductVersion") + echo "$macos_version" + if [[ "$macos_version" =~ "14." ]] && [[ "${{ inputs.version }}" == '2021.6' || "${{ inputs.version }}" == '2021.7' || "${{ inputs.version }}" == '2021.7.1' || "${{ inputs.version }}" == '2021.8' ]]; then + mkl_tests=false + fi + fi + + # # now we know if we should, run the tests + if $mkl_tests; then if [ "$RUNNER_OS" == "macOS" ]; then - # required for macOS 11, intel-classic 2021.1-2021.10 - # required for macOS 12, intel-classic 2021.1, 2021.4, 2021.6, 2021.10 - # for all others, setting DYLD path through environment works correctly - export DYLD_LIBRARY_PATH="${{ env.MKLLIB }}:$DYLD_LIBRARY_PATH" + MKLLIB="$MKLROOT/lib" + export DYLD_LIBRARY_PATH="$MKLLIB:$DYLD_LIBRARY_PATH" + elif [ "$RUNNER_OS" == "Linux" ]; then + MKLLIB="$MKLROOT/latest/lib/intel64" + export LD_LIBRARY_PATH="$MKLLIB:$LD_LIBRARY_PATH" fi - linking="-L${{ env.MKLLIB }} -lmkl_intel_lp64 -lmkl_sequential -lmkl_core" + linking="-L$MKLLIB -lmkl_intel_lp64 -lmkl_sequential -lmkl_core" # hello world with blas call program ${{ env.FC }} $args $linking -o hw_mkl hw_mkl.f90 output=$(./hw_mkl '2>&1') [[ "$output" == *"hello world 9.00000000000000"* ]] && echo "$output" || (echo "Unexpected Fortran program 'hw_mkl' output: $output"; exit 1) rm hw_mkl + else + echo "Skipping MKL tests" fi \ No newline at end of file diff --git a/.github/compat/long_compat.csv b/.github/compat/long_compat.csv index c58a541..b60d489 100644 --- a/.github/compat/long_compat.csv +++ b/.github/compat/long_compat.csv @@ -237,4 +237,4 @@ windows-2022,intel,2023.2,✓ windows-2022,intel,2024.0,✓ windows-2022,lfortran,0.31.0,✓ windows-2022,lfortran,0.32.0,✓ -windows-2022,lfortran,0.33.0,✓ +windows-2022,lfortran,0.33.0,✓ \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e669aa..7905235 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,10 @@ jobs: version: ${{ matrix.toolchain.version }} - name: Test MKL libraries - if: steps.setup-fortran.outcome == 'success' && runner.os != 'windows' + # we could also exclude 2021.5 for all macos versions here + # this needs refactoring at some point - should the install + # fail if no mkl version exists? + if: steps.setup-fortran.outcome == 'success' && runner.os != 'windows' uses: ./.github/actions/test-mkl with: compiler: ${{ matrix.toolchain.compiler }} diff --git a/action.yml b/action.yml index c668dae..d08dce1 100644 --- a/action.yml +++ b/action.yml @@ -145,6 +145,7 @@ runs: echo FC=$FC>>$GITHUB_ENV echo CC=$CC>>$GITHUB_ENV echo CXX=$CXX>>$GITHUB_ENV + echo "MKLLIB=$MKLLIB" >> $GITHUB_ENV # set fpm env vars echo FPM_FC=$FC>>$GITHUB_ENV diff --git a/install-intel-macos.sh b/install-intel-macos.sh new file mode 100644 index 0000000..4a16bd2 --- /dev/null +++ b/install-intel-macos.sh @@ -0,0 +1,21 @@ +install_mkl=$1 +MACOS_URL=$2 +if [ "$MACOS_URL" == "" ]; then + echo "ERROR: MACOS URL is empty - please check the version mapping for mkl/intel compiler" + echo "SKIPPING MKL/intel installation..." +elif [ "$MACOS_URL" == "2021.5" ] and $install_mkl; then + echo "ERROR: MKL not available for this intel compiler version" + echo "SKIPPING MKL installation..." +else + require_fetch + $fetch $MACOS_URL > m_BASE_HPC_Kit.dmg + hdiutil verify m_BASE_HPC_Kit.dmg + hdiutil attach m_BASE_HPC_Kit.dmg + sudo /Volumes/"$(basename "$MACOS_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \ + --action install \ + --eula=accept \ + --continue-with-optional-error=yes \ + --log-dir=. + hdiutil detach /Volumes/"$(basename "$MACOS_URL" .dmg)" -quiet + rm m_BASE_HPC_Kit.dmg +fi \ No newline at end of file diff --git a/setup-fortran.sh b/setup-fortran.sh index 03f6c86..ae26419 100755 --- a/setup-fortran.sh +++ b/setup-fortran.sh @@ -171,9 +171,7 @@ LD_LIBRARY_PATH=$LD_LIBRARY_PATH LIBRARY_PATH=$LIBRARY_PATH INFOPATH=$INFOPATH MANPATH=$MANPATH -MKLLIB=$MKLLIB MKLROOT=$MKLROOT -DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH ONEAPI_ROOT=$ONEAPI_ROOT CLASSPATH=$CLASSPATH CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH @@ -297,20 +295,39 @@ intel_version_map_m() mkl_version_map_m() { local intel_version=$1 - case $intel_version in - 2021.1.0 | 2021.2.0 | 2021.3.0 | 2021.4.0 | 2022.2.0 | 2022.3.0 | 2022.3.1 | 2023.0.0 ) - mkl_version=2022.2.0 - ;; - 2022.1.0) - mkl_version="" - ;; - 2023.1.0) - mkl_version=2023.1.0 - ;; - *) - mkl_version=2023.2.0 - ;; - esac + macos_version=$(sw_vers | grep "ProductVersion") + echo "Found macos version $macos_version" + if [[ "$macos_version" == *"14"* ]]; then + echo "MacOS 14 requires different basekit versions to work" + case $intel_version in + # compiler versions 2021.1, 2021.2, 2021.3, 2021.4, 2021.10 work with latest basekit + 2021.1.0 | 2021.2.0 | 2021.3.0 | 2021.4.0 | 2023.2.0) + mkl_version=2023.2.0 + ;; + # compiler versions 2021.5, 2021.6, 2021.7, 2021.7.1, 2021.8, 2021.9 work with other basekits + 2023.1.0) + mkl_version=2022.2.0 + ;; + *) + mkl_version="" + ;; + esac + else + case $intel_version in + 2021.1.0 | 2021.2.0 | 2021.3.0 | 2021.4.0 | 2022.2.0 | 2022.3.0 | 2022.3.1 | 2023.0.0 ) + mkl_version=2022.2.0 + ;; + 2022.1.0) + mkl_version="" + ;; + 2023.1.0) + mkl_version=2023.1.0 + ;; + *) + mkl_version=2023.2.0 + ;; + esac + fi } intel_version_map_w() @@ -388,11 +405,11 @@ install_intel_apt() esac if $install_mkl; then - sudo apt-get install \ + sudo apt-get install -y \ intel-oneapi-compiler-{fortran,"$cpp_name"}-$version \ intel-oneapi-mkl-$mkl_version else - sudo apt-get install \ + sudo apt-get install -y \ intel-oneapi-compiler-{fortran,"$cpp_name"}-$version fi @@ -465,36 +482,10 @@ install_intel_dmg() esac if $install_mkl; then - if [ "$MACOS_BASEKIT_URL" == "" ]; then - echo "ERROR: MACOS_BASEKIT_URL is empty - please check the version mapping for MKL" - echo "SKIPPING MKL installation..." - else - require_fetch - $fetch $MACOS_BASEKIT_URL > m_BASEKit.dmg - ls -lh - hdiutil verify m_BASEKit.dmg - hdiutil attach m_BASEKit.dmg - sudo /Volumes/"$(basename "$MACOS_BASEKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \ - --action install \ - --eula=accept \ - --continue-with-optional-error=yes \ - --log-dir=. - hdiutil detach /Volumes/"$(basename "$MACOS_BASEKIT_URL" .dmg)" -quiet - rm m_BASEKit.dmg - fi + source "$GITHUB_ACTION_PATH/install-intel-macos.sh" true $MACOS_BASEKIT_URL fi - require_fetch - $fetch $MACOS_HPCKIT_URL > m_HPCKit.dmg - hdiutil verify m_HPCKit.dmg - hdiutil attach m_HPCKit.dmg - sudo /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \ - --action install \ - --eula=accept \ - --continue-with-optional-error=yes \ - --log-dir=. - hdiutil detach /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)" -quiet - rm m_HPCKit.dmg + source "$GITHUB_ACTION_PATH/install-intel-macos.sh" false $MACOS_HPCKIT_URL source /opt/intel/oneapi/setvars.sh export_intel_vars @@ -552,9 +543,11 @@ install_intel() local platform=$1 local classic=$2 local install_mkl=$3 + mkl_subdir="" case $platform in linux*) install_intel_apt $version $classic $install_mkl + mkl_subdir="intel64" ;; darwin*) install_intel_dmg $version $install_mkl @@ -583,6 +576,11 @@ install_intel() export CC="icx" export CXX="icpx" fi + + if $install_mkl; then + export MKLLIB="$ONEAPI_ROOT/mkl/latest/lib/$mkl_subdir" + export MKLROOT="$ONEAPI_ROOT/mkl/latest" + fi } export_nvidiahpc_vars()