diff --git a/.github/actions/test-mkl/action.yml b/.github/actions/test-mkl/action.yml new file mode 100644 index 0000000..a586838 --- /dev/null +++ b/.github/actions/test-mkl/action.yml @@ -0,0 +1,56 @@ +name: Test mkl +description: Test installation of mkl libraries +inputs: + compiler: + description: "Toolchain or compiler to install" + required: true + version: + description: "Version of toolchain or compiler" + required: true + install_mkl: + description: "If MKL should be installed along with the compiler" + required: false + default: "false" +runs: + using: "composite" + steps: + - name: Test compile and link mkl (bash) + working-directory: test + shell: bash + run: | + # 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 + 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$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/compat.csv b/.github/compat/compat.csv index 4825c59..60890fe 100644 --- a/.github/compat/compat.csv +++ b/.github/compat/compat.csv @@ -1,10 +1,10 @@ compiler,gcc,gcc,gcc,gcc,gcc,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,lfortran,lfortran,lfortran,nvidia-hpc,nvidia-hpc,nvidia-hpc,nvidia-hpc,nvidia-hpc,nvidia-hpc,nvidia-hpc,nvidia-hpc -version,10,11,12,13,9,2021.1,2021.1.2,2021.2,2021.4,2022.0,2022.1,2022.2,2022.2.1,2023.0,2023.1,2023.2,2024.0,2024.1,2021.1,2021.1.2,2021.10,2021.11,2021.12,2021.2,2021.3,2021.4,2021.5,2021.6,2021.7,2021.7.1,2021.8,2021.9,0.31.0,0.32.0,0.33.0,20.11,21.11,22.11,23.11,23.3,23.5,23.7,23.9 +version,9,10,11,12,13,2021.1,2021.1.2,2021.2,2021.4,2022.0,2022.1,2022.2,2022.2.1,2023.0,2023.1,2023.2,2024.0,2024.1,2021.1,2021.1.2,2021.2,2021.3,2021.4,2021.5,2021.6,2021.7,2021.7.1,2021.8,2021.9,2021.10,2021.11,2021.12,0.31.0,0.32.0,0.33.0,20.11,21.11,22.11,23.3,23.5,23.7,23.9,23.11 runner,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -macos-12,✓,✓,✓,✓,✓,,,,,,,,,,,,,,✓,,✓,,,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,,,,,,,, -macos-13,✓,✓,✓,✓,,,,,,,,,,,,,,,✓,,✓,,,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,,,,,,,, -macos-14,,✓,✓,✓,,,,,,,,,,,,,,,✓,,✓,,,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,,,,,,,, -ubuntu-20.04,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓ -ubuntu-22.04,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓ -windows-2019,✓,✓,✓,✓,✓,,,,,,✓,✓,,,✓,✓,✓,✓,,,✓,✓,✓,,,,,✓,✓,,,✓,✓,✓,✓,,,,,,,, -windows-2022,✓,✓,✓,✓,✓,,,,,,✓,✓,,,✓,✓,✓,✓,,,✓,✓,✓,,,,,✓,✓,,,✓,✓,✓,✓,,,,,,,, +macos-12,✓,✓,✓,✓,✓,,,,,,,,,,,,,,✓,,✓,✓,✓,✓,✓,✓,,✓,✓,✓,,,✓,✓,✓,,,,,,,, +macos-13,,✓,✓,✓,✓,,,,,,,,,,,,,,✓,,✓,✓,✓,✓,✓,,,✓,✓,✓,,,✓,✓,✓,,,,,,,, +macos-14,,,✓,✓,✓,,,,,,,,,,,,,,✓,,✓,✓,✓,✓,✓,✓,,✓,✓,✓,,,✓,✓,✓,,,,,,,, +ubuntu-20.04,✓,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓ +ubuntu-22.04,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓ +windows-2019,✓,✓,✓,✓,✓,,,,,,✓,✓,,,✓,✓,✓,✓,,,,,,,✓,✓,,,✓,✓,✓,✓,✓,✓,✓,,,,,,,, +windows-2022,✓,✓,✓,✓,✓,,,,,,✓,✓,,,✓,✓,✓,✓,,,,,,,✓,✓,,,✓,✓,✓,✓,✓,✓,✓,,,,,,,, diff --git a/.github/compat/long_compat.csv b/.github/compat/long_compat.csv index 5770c67..b309b98 100644 --- a/.github/compat/long_compat.csv +++ b/.github/compat/long_compat.csv @@ -7,6 +7,8 @@ macos-12,gcc,9,✓ macos-12,intel-classic,2021.1.2, macos-12,intel-classic,2021.1,✓ macos-12,intel-classic,2021.10,✓ +macos-12,intel-classic,2021.11, +macos-12,intel-classic,2021.12, macos-12,intel-classic,2021.2,✓ macos-12,intel-classic,2021.3,✓ macos-12,intel-classic,2021.4,✓ @@ -26,13 +28,15 @@ macos-13,gcc,13,✓ macos-13,intel-classic,2021.1.2, macos-13,intel-classic,2021.1,✓ macos-13,intel-classic,2021.10,✓ +macos-13,intel-classic,2021.11, +macos-13,intel-classic,2021.12, macos-13,intel-classic,2021.2,✓ macos-13,intel-classic,2021.3,✓ macos-13,intel-classic,2021.4,✓ macos-13,intel-classic,2021.5,✓ macos-13,intel-classic,2021.6,✓ macos-13,intel-classic,2021.7.1, -macos-13,intel-classic,2021.7,✓ +macos-13,intel-classic,2021.7, macos-13,intel-classic,2021.8,✓ macos-13,intel-classic,2021.9,✓ macos-13,lfortran,0.31.0,✓ @@ -44,6 +48,8 @@ macos-14,gcc,13,✓ macos-14,intel-classic,2021.1.2, macos-14,intel-classic,2021.1,✓ macos-14,intel-classic,2021.10,✓ +macos-14,intel-classic,2021.11, +macos-14,intel-classic,2021.12, macos-14,intel-classic,2021.2,✓ macos-14,intel-classic,2021.3,✓ macos-14,intel-classic,2021.4,✓ @@ -96,8 +102,6 @@ ubuntu-20.04,nvidia-hpc,20.7, ubuntu-20.04,nvidia-hpc,20.9, ubuntu-20.04,nvidia-hpc,21.1, ubuntu-20.04,nvidia-hpc,21.11,✓ -ubuntu-20.04,nvidia-hpc,21.3, -ubuntu-20.04,nvidia-hpc,21.5, ubuntu-20.04,nvidia-hpc,21.7, ubuntu-20.04,nvidia-hpc,21.9, ubuntu-20.04,nvidia-hpc,22.1, @@ -153,12 +157,13 @@ ubuntu-22.04,nvidia-hpc,20.7, ubuntu-22.04,nvidia-hpc,20.9, ubuntu-22.04,nvidia-hpc,21.1, ubuntu-22.04,nvidia-hpc,21.11,✓ -ubuntu-22.04,nvidia-hpc,21.9, +ubuntu-22.04,nvidia-hpc,22.1, ubuntu-22.04,nvidia-hpc,22.11,✓ ubuntu-22.04,nvidia-hpc,22.2, ubuntu-22.04,nvidia-hpc,22.3, ubuntu-22.04,nvidia-hpc,22.5, ubuntu-22.04,nvidia-hpc,22.7, +ubuntu-22.04,nvidia-hpc,22.9, ubuntu-22.04,nvidia-hpc,23.1, ubuntu-22.04,nvidia-hpc,23.11,✓ ubuntu-22.04,nvidia-hpc,23.3,✓ diff --git a/.github/compat/wide_compat_reports.py b/.github/compat/wide_compat_reports.py index 6b67479..90e536e 100644 --- a/.github/compat/wide_compat_reports.py +++ b/.github/compat/wide_compat_reports.py @@ -16,7 +16,7 @@ # read long CSV df = pd.read_csv(ip) -# pivot and sort +# pivot and sort by runners df = pd.pivot_table( df, index="runner", @@ -26,6 +26,22 @@ aggfunc="first", ).sort_values(by=["runner"]) + +# group by compiler and sort by versions +grouped_versions = {} +for compiler in df.columns.get_level_values("compiler").unique(): + versions = df.loc[:, (compiler,)].columns.get_level_values("version").unique() + versions = sorted(versions, key=lambda version: tuple(map(int, version.split(".")))) + grouped_versions[compiler] = versions + +sorted_columns = [] +for compiler in grouped_versions: + sorted_columns.extend( + [(compiler, version) for version in grouped_versions[compiler]] + ) + +df = df[sorted_columns] + # write wide CSV df.to_csv(op) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f65195..21a5bd5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ on: branches: - main - develop* + - math paths-ignore: - '**.md' schedule: @@ -74,6 +75,7 @@ jobs: with: compiler: ${{ matrix.toolchain.compiler }} version: ${{ matrix.toolchain.version }} + install_mkl: true # - name: Debug with tmate # uses: mxschmitt/action-tmate@v3 @@ -85,6 +87,17 @@ jobs: compiler: ${{ matrix.toolchain.compiler }} version: ${{ matrix.toolchain.version }} + - name: Test MKL libraries + # 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 }} + version: ${{ matrix.toolchain.version }} + install_mkl: true + - name: Test C compiler continue-on-error: true if: needs.options.outputs.mode == 'report' && steps.setup-fortran.outcome == 'success' diff --git a/README.md b/README.md index 7f4b183..5df3642 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,13 @@ jobs: toolchain: {compiler: nvidia-hpc, version: '23.11'} steps: - - uses: fortran-lang/setup-fortran@v1 + - uses: ssciwr/setup-fortran@v0.1 id: setup-fortran with: compiler: ${{ matrix.toolchain.compiler }} version: ${{ matrix.toolchain.version }} + install_mkl: "true" + - run: | ${{ env.FC }} ... # environment vars FC, CC, and CXX are set @@ -69,6 +71,7 @@ jobs: - *lfortran* for `lfortran` - *nvidia-hpc* for `nvfortran` - *version*: Version of the compiler toolchain. See [runner compatibility](#runner-compatibility) charts below. +- *install_mkl*: If MKL libraries should be installed alongsider the intel compiler. Defaults to `false`. ## Outputs @@ -104,21 +107,23 @@ These are made available to subsequent workflow steps via the [`GITHUB_ENV` envi Toolchain support varies across GitHub-hosted runner images. -| runner | gcc 10 | gcc 11 | gcc 12 | gcc 13 | gcc 9 | intel 2021.1 | intel 2021.1.2 | intel 2021.2 | intel 2021.4 | intel 2022.0 | intel 2022.1 | intel 2022.2 | intel 2022.2.1 | intel 2023.0 | intel 2023.1 | intel 2023.2 | intel 2024.0 | intel 2024.1 | intel-classic 2021.1 | intel-classic 2021.1.2 | intel-classic 2021.10 | intel-classic 2021.11 | intel-classic 2021.12 | intel-classic 2021.2 | intel-classic 2021.3 | intel-classic 2021.4 | intel-classic 2021.5 | intel-classic 2021.6 | intel-classic 2021.7 | intel-classic 2021.7.1 | intel-classic 2021.8 | intel-classic 2021.9 | lfortran 0.31.0 | lfortran 0.32.0 | lfortran 0.33.0 | nvidia-hpc 20.11 | nvidia-hpc 21.11 | nvidia-hpc 22.11 | nvidia-hpc 23.11 | nvidia-hpc 23.3 | nvidia-hpc 23.5 | nvidia-hpc 23.7 | nvidia-hpc 23.9 | -|:-------------|:----------------|:----------------|:----------------|:----------------|:---------------|:----------------------|:------------------------|:----------------------|:----------------------|:----------------------|:----------------------|:----------------------|:------------------------|:----------------------|:----------------------|:----------------------|:----------------------|:----------------------|:------------------------------|:--------------------------------|:-------------------------------|:-------------------------------|:-------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:--------------------------------|:------------------------------|:------------------------------|:-------------------------|:-------------------------|:-------------------------|:--------------------------|:--------------------------|:--------------------------|:--------------------------|:-------------------------|:-------------------------|:-------------------------|:-------------------------| -| macos-12 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | | | | | | ✓ | | ✓ | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | -| macos-13 | ✓ | ✓ | ✓ | ✓ | | | | | | | | | | | | | | | ✓ | | ✓ | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | -| macos-14 | | ✓ | ✓ | ✓ | | | | | | | | | | | | | | | ✓ | | ✓ | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | -| ubuntu-20.04 | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| ubuntu-22.04 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | -| windows-2019 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | | | | | | | -| windows-2022 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | | | | | | | +| runner | gcc 9 | gcc 10 | gcc 11 | gcc 12 | gcc 13 | intel 2021.1 | intel 2021.1.2 | intel 2021.2 | intel 2021.4 | intel 2022.0 | intel 2022.1 | intel 2022.2 | intel 2022.2.1 | intel 2023.0 | intel 2023.1 | intel 2023.2 | intel 2024.0 | intel 2024.1 | intel-classic 2021.1 | intel-classic 2021.1.2 | intel-classic 2021.2 | intel-classic 2021.3 | intel-classic 2021.4 | intel-classic 2021.5 | intel-classic 2021.6 | intel-classic 2021.7 | intel-classic 2021.7.1 | intel-classic 2021.8 | intel-classic 2021.9 | intel-classic 2021.10 | intel-classic 2021.11 | intel-classic 2021.12 | lfortran 0.31.0 | lfortran 0.32.0 | lfortran 0.33.0 | nvidia-hpc 20.11 | nvidia-hpc 21.11 | nvidia-hpc 22.11 | nvidia-hpc 23.3 | nvidia-hpc 23.5 | nvidia-hpc 23.7 | nvidia-hpc 23.9 | nvidia-hpc 23.11 | +|:-------------|:---------------|:----------------|:----------------|:----------------|:----------------|:----------------------|:------------------------|:----------------------|:----------------------|:----------------------|:----------------------|:----------------------|:------------------------|:----------------------|:----------------------|:----------------------|:----------------------|:----------------------|:------------------------------|:--------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:------------------------------|:--------------------------------|:------------------------------|:------------------------------|:-------------------------------|:-------------------------------|:-------------------------------|:-------------------------|:-------------------------|:-------------------------|:--------------------------|:--------------------------|:--------------------------|:-------------------------|:-------------------------|:-------------------------|:-------------------------|:--------------------------| +| macos-12 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | | | | | | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | | | | | | | +| macos-13 | | ✓ | ✓ | ✓ | ✓ | | | | | | | | | | | | | | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | | | | | | | +| macos-14 | | | ✓ | ✓ | ✓ | | | | | | | | | | | | | | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ | | | | | | | | | +| ubuntu-20.04 | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| ubuntu-22.04 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| windows-2019 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | +| windows-2022 | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | | | | | | | ✓ | ✓ | | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | | | | | | | | **Note:** Intel's `ifx` compiler is not supported on macOS, so the `intel` option redirects to `intel-classic` (`ifort`). **Note:** LFortran is currently only discoverable by name with `bash` on Windows, see [here for context](https://github.com/fortran-lang/setup-fortran/pull/57#issuecomment-2021605094). +**Note:** MKL libraries can only be installed for the Intel Fortran compiler, and only on linux and MacOS operating systems; with the exception of intel-classic 2021.5, for which no compatible library is available. + ## License Licensed under the Apache License, Version 2.0 (the “License”); diff --git a/action.yml b/action.yml index 5f2f627..847fd69 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: "Setup Fortran" +name: "Setup Fortran and math libraries" description: "Setup Fortran compiler and toolchain" inputs: compiler: @@ -8,6 +8,10 @@ inputs: version: description: "Version of toolchain or compiler" required: false + install_mkl: + description: "If MKL should be installed along with the compiler" + required: false + default: "false" outputs: fc: description: "Path to Fortran compiler" @@ -68,6 +72,7 @@ runs: env: COMPILER: ${{ inputs.compiler }} VERSION: ${{ inputs.version }} + INSTALL_MKL: ${{ inputs.install_mkl }} run: | action_path=$(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://') source "$action_path/setup-fortran.sh" @@ -87,11 +92,11 @@ runs: ;; intel-classic) version=${VERSION:-2023.2.0} - install_intel $platform true + install_intel $platform true ${{ inputs.install_mkl }} ;; intel) version=${VERSION:-2024.1} - install_intel $platform false + install_intel $platform false ${{ inputs.install_mkl }} ;; nvidia-hpc) version=${VERSION:-23.11} @@ -151,6 +156,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 @@ -161,7 +167,6 @@ runs: echo fc=$FC>>$GITHUB_OUTPUT echo cc=$CC>>$GITHUB_OUTPUT echo cxx=$CXX>>$GITHUB_OUTPUT - - name: Hide GNU linker (Windows) if: runner.os == 'Windows' && !contains(inputs.compiler, 'gcc') shell: bash 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/requirements.txt b/requirements.txt index debfb47..ec752b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pandas -tabulate \ No newline at end of file +tabulate diff --git a/setup-fortran.sh b/setup-fortran.sh index 1dc5c5f..095b16b 100755 --- a/setup-fortran.sh +++ b/setup-fortran.sh @@ -156,6 +156,7 @@ LD_LIBRARY_PATH=$LD_LIBRARY_PATH LIBRARY_PATH=$LIBRARY_PATH INFOPATH=$INFOPATH MANPATH=$MANPATH +MKLROOT=$MKLROOT ONEAPI_ROOT=$ONEAPI_ROOT CLASSPATH=$CLASSPATH CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH @@ -237,6 +238,19 @@ intel_version_map_l() fi } +mkl_version_map_l() +{ + local intel_version=$1 + case $intel_version in + 2021.1 | 2021.1.2) + mkl_version=2021.1.1 + ;; + *) + mkl_version=$intel_version + ;; + esac +} + intel_version_map_m() { local actual_version=$1 @@ -271,6 +285,45 @@ intel_version_map_m() esac } +mkl_version_map_m() +{ + local intel_version=$1 + 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.9 works with other basekits + 2023.1.0) + mkl_version=2023.1.0 + ;; + # all others don't work with any basekit + *) + 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() { local actual_version=$1 @@ -330,7 +383,10 @@ install_intel_apt() { local version=$1 local classic=$2 + local mkl_version=$1 + local install_mkl=$3 intel_version_map_l $version $classic + mkl_version_map_l $version require_fetch local _KEY="GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB" @@ -341,6 +397,11 @@ install_intel_apt() | sudo tee /etc/apt/sources.list.d/oneAPI.list sudo apt-get update + # first install mkl, then the compilers, to keep setvars clean + if $install_mkl; then + sudo apt-get install intel-oneapi-mkl-$mkl_version + fi + # c/cpp compiler package names changed with 2024+ case $version in 2024*) @@ -352,7 +413,6 @@ install_intel_apt() intel-oneapi-compiler-{fortran,dpcpp-cpp-and-cpp-classic}-$version ;; esac - source /opt/intel/oneapi/setvars.sh export_intel_vars } @@ -360,51 +420,43 @@ install_intel_apt() install_intel_dmg() { local version=$1 + local mkl_version=$1 + local install_mkl=$2 intel_version_map_m $version + mkl_version_map_m $version case $version in 2021.1.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17426/m_BaseKit_p_2021.1.0.2427.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17398/m_HPCKit_p_2021.1.0.2681.dmg ;; 2021.2.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17714/m_BaseKit_p_2021.2.0.2855.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17643/m_HPCKit_p_2021.2.0.2903.dmg ;; 2021.3.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226.dmg ;; 2021.4.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18256/m_BaseKit_p_2021.4.0.3384.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18242/m_HPCKit_p_2021.4.0.3389.dmg ;; 2022.1.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18342/m_BaseKit_p_2022.1.0.92.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18341/m_HPCKit_p_2022.1.0.86.dmg ;; 2022.2.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18675/m_BaseKit_p_2022.2.0.226_offline.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18681/m_HPCKit_p_2022.2.0.158_offline.dmg ;; 2022.3.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18865/m_BaseKit_p_2022.3.0.8743.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18866/m_HPCKit_p_2022.3.0.8685.dmg ;; 2022.3.1) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18971/m_BaseKit_p_2022.3.1.17244.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18977/m_HPCKit_p_2022.3.1.15344.dmg ;; 2023.0.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19080/m_BaseKit_p_2023.0.0.25441.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19086/m_HPCKit_p_2023.0.0.25440.dmg ;; 2023.1.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2516a0a0-de4d-4f3d-9e83-545b32127dbb/m_BaseKit_p_2023.1.0.45568.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/a99cb1c5-5af6-4824-9811-ae172d24e594/m_HPCKit_p_2023.1.0.44543.dmg ;; 2023.2.0) - MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/cd013e6c-49c4-488b-8b86-25df6693a9b7/m_BaseKit_p_2023.2.0.49398.dmg MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/edb4dc2f-266f-47f2-8d56-21bc7764e119/m_HPCKit_p_2023.2.0.49443.dmg ;; *) @@ -412,16 +464,28 @@ install_intel_dmg() ;; esac - require_fetch - $fetch $MACOS_HPCKIT_URL > 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 + case $mkl_version in + 2022.2.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18675/m_BaseKit_p_2022.2.0.226_offline.dmg + ;; + 2023.1.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2516a0a0-de4d-4f3d-9e83-545b32127dbb/m_BaseKit_p_2023.1.0.45568.dmg + ;; + 2023.2.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/cd013e6c-49c4-488b-8b86-25df6693a9b7/m_BaseKit_p_2023.2.0.49398.dmg + ;; + "") + ;; + *) + exit 1 + ;; + esac + + if $install_mkl; then + source "$GITHUB_ACTION_PATH/install-intel-macos.sh" true $MACOS_BASEKIT_URL + fi + + source "$GITHUB_ACTION_PATH/install-intel-macos.sh" false $MACOS_HPCKIT_URL source /opt/intel/oneapi/setvars.sh export_intel_vars @@ -482,12 +546,15 @@ install_intel() { local platform=$1 local classic=$2 + local install_mkl=$3 + mkl_subdir="" case $platform in linux*) - install_intel_apt $version $classic + install_intel_apt $version $classic $install_mkl + mkl_subdir="intel64" ;; darwin*) - install_intel_dmg $version + install_intel_dmg $version $install_mkl ;; mingw*) install_intel_win $version $classic @@ -513,6 +580,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() diff --git a/test/hw_mkl.f90 b/test/hw_mkl.f90 new file mode 100644 index 0000000..cc7445c --- /dev/null +++ b/test/hw_mkl.f90 @@ -0,0 +1,13 @@ +program hello + implicit none + double precision, dimension(3):: a, b + double precision:: c + double precision:: DDOT + + a = (/ 3.D0, 3.D0, 3.D0 /) + b = (/ 1.D0, 1.D0, 1.D0 /) + + c = DDOT(3, a, 1, b, 1) + + print *, "hello world", c +end program hello \ No newline at end of file