Skip to content

Commit 2b86442

Browse files
committed
rebase fork
1 parent acc8fcd commit 2b86442

File tree

7 files changed

+212
-27
lines changed

7 files changed

+212
-27
lines changed

.github/actions/test-mkl/action.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Test mkl
2+
description: Test installation of mkl libraries
3+
inputs:
4+
compiler:
5+
description: "Toolchain or compiler to install"
6+
required: true
7+
version:
8+
description: "Version of toolchain or compiler"
9+
required: true
10+
install_mkl:
11+
description: "If MKL should be installed along with the compiler"
12+
required: false
13+
default: "false"
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Test compile and link mkl (bash)
18+
working-directory: test
19+
shell: bash
20+
run: |
21+
# check settings if mkl tests should be run
22+
# mkl cannot be installed for 2021.5 on macos;
23+
# and for macos-14 also not 2021.6-2021.9
24+
mkl_tests=true
25+
echo "$RUNNER_OS"
26+
if [[ "${{ inputs.compiler }}" =~ "gcc" ]]; then mkl_tests=false; fi
27+
if [[ "${{ inputs.compiler }}" =~ "lfortran" ]]; then mkl_tests=false; fi
28+
if [[ "${{ inputs.compiler }}" =~ "nvidia" ]]; then mkl_tests=false; fi
29+
if [[ "${{ inputs.install_mkl }}" == "false" ]]; then mkl_tests=false; fi
30+
if [[ "${{ inputs.version }}" == "2021.5" ]] && [[ "$RUNNER_OS" == "macOS" ]]; then mkl_tests=false; fi
31+
if [[ "$RUNNER_OS" == "macOS" ]]; then
32+
macos_version=$(sw_vers | grep "ProductVersion")
33+
echo "$macos_version"
34+
if [[ "$macos_version" =~ "14." ]] && [[ "${{ inputs.version }}" == '2021.6' || "${{ inputs.version }}" == '2021.7' || "${{ inputs.version }}" == '2021.7.1' || "${{ inputs.version }}" == '2021.8' ]]; then
35+
mkl_tests=false
36+
fi
37+
fi
38+
39+
# # now we know if we should, run the tests
40+
if $mkl_tests; then
41+
if [ "$RUNNER_OS" == "macOS" ]; then
42+
MKLLIB="$MKLROOT/lib"
43+
export DYLD_LIBRARY_PATH="$MKLLIB:$DYLD_LIBRARY_PATH"
44+
elif [ "$RUNNER_OS" == "Linux" ]; then
45+
MKLLIB="$MKLROOT/latest/lib/intel64"
46+
export LD_LIBRARY_PATH="$MKLLIB:$LD_LIBRARY_PATH"
47+
fi
48+
linking="-L$MKLLIB -lmkl_intel_lp64 -lmkl_sequential -lmkl_core"
49+
# hello world with blas call program
50+
${{ env.FC }} $args $linking -o hw_mkl hw_mkl.f90
51+
output=$(./hw_mkl '2>&1')
52+
[[ "$output" == *"hello world 9.00000000000000"* ]] && echo "$output" || (echo "Unexpected Fortran program 'hw_mkl' output: $output"; exit 1)
53+
rm hw_mkl
54+
else
55+
echo "Skipping MKL tests"
56+
fi

.github/workflows/test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
branches:
1313
- main
1414
- develop*
15+
- math
1516
paths-ignore:
1617
- '**.md'
1718
schedule:
@@ -74,6 +75,7 @@ jobs:
7475
with:
7576
compiler: ${{ matrix.toolchain.compiler }}
7677
version: ${{ matrix.toolchain.version }}
78+
install_mkl: true
7779

7880
# - name: Debug with tmate
7981
# uses: mxschmitt/action-tmate@v3
@@ -85,6 +87,17 @@ jobs:
8587
compiler: ${{ matrix.toolchain.compiler }}
8688
version: ${{ matrix.toolchain.version }}
8789

90+
- name: Test MKL libraries
91+
# we could also exclude 2021.5 for all macos versions here
92+
# this needs refactoring at some point - should the install
93+
# fail if no mkl version exists?
94+
if: steps.setup-fortran.outcome == 'success' && runner.os != 'windows'
95+
uses: ./.github/actions/test-mkl
96+
with:
97+
compiler: ${{ matrix.toolchain.compiler }}
98+
version: ${{ matrix.toolchain.version }}
99+
install_mkl: true
100+
88101
- name: Test C compiler
89102
continue-on-error: true
90103
if: needs.options.outputs.mode == 'report' && steps.setup-fortran.outcome == 'success'

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
with:
5454
compiler: ${{ matrix.toolchain.compiler }}
5555
version: ${{ matrix.toolchain.version }}
56+
install_mkl: "true"
5657

5758
- run: |
5859
${{ env.FC }} ... # environment vars FC, CC, and CXX are set
@@ -69,6 +70,7 @@ jobs:
6970
- *lfortran* for `lfortran`
7071
- *nvidia-hpc* for `nvfortran`
7172
- *version*: Version of the compiler toolchain. See [runner compatibility](#runner-compatibility) charts below.
73+
- *install_mkl*: If MKL libraries should be installed alongsider the intel compiler. Defaults to `false`.
7274

7375

7476
## Outputs
@@ -119,6 +121,8 @@ Toolchain support varies across GitHub-hosted runner images.
119121

120122
**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).
121123

124+
**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.
125+
122126
## License
123127

124128
Licensed under the Apache License, Version 2.0 (the “License”);

action.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Setup Fortran"
1+
name: "Setup Fortran and math libraries"
22
description: "Setup Fortran compiler and toolchain"
33
inputs:
44
compiler:
@@ -8,6 +8,10 @@ inputs:
88
version:
99
description: "Version of toolchain or compiler"
1010
required: false
11+
install_mkl:
12+
description: "If MKL should be installed along with the compiler"
13+
required: false
14+
default: "false"
1115
outputs:
1216
fc:
1317
description: "Path to Fortran compiler"
@@ -68,6 +72,7 @@ runs:
6872
env:
6973
COMPILER: ${{ inputs.compiler }}
7074
VERSION: ${{ inputs.version }}
75+
INSTALL_MKL: ${{ inputs.install_mkl }}
7176
run: |
7277
action_path=$(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://')
7378
source "$action_path/setup-fortran.sh"
@@ -87,11 +92,11 @@ runs:
8792
;;
8893
intel-classic)
8994
version=${VERSION:-2023.2.0}
90-
install_intel $platform true
95+
install_intel $platform true ${{ inputs.install_mkl }}
9196
;;
9297
intel)
9398
version=${VERSION:-2024.1}
94-
install_intel $platform false
99+
install_intel $platform false ${{ inputs.install_mkl }}
95100
;;
96101
nvidia-hpc)
97102
version=${VERSION:-23.11}
@@ -151,6 +156,7 @@ runs:
151156
echo FC=$FC>>$GITHUB_ENV
152157
echo CC=$CC>>$GITHUB_ENV
153158
echo CXX=$CXX>>$GITHUB_ENV
159+
echo "MKLLIB=$MKLLIB" >> $GITHUB_ENV
154160
155161
# set fpm env vars
156162
echo FPM_FC=$FC>>$GITHUB_ENV

install-intel-macos.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
install_mkl=$1
2+
MACOS_URL=$2
3+
if [ "$MACOS_URL" == "" ]; then
4+
echo "ERROR: MACOS URL is empty - please check the version mapping for mkl/intel compiler"
5+
echo "SKIPPING MKL/intel installation..."
6+
elif [ "$MACOS_URL" == "2021.5" ] and $install_mkl; then
7+
echo "ERROR: MKL not available for this intel compiler version"
8+
echo "SKIPPING MKL installation..."
9+
else
10+
require_fetch
11+
$fetch $MACOS_URL > m_BASE_HPC_Kit.dmg
12+
hdiutil verify m_BASE_HPC_Kit.dmg
13+
hdiutil attach m_BASE_HPC_Kit.dmg
14+
sudo /Volumes/"$(basename "$MACOS_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \
15+
--action install \
16+
--eula=accept \
17+
--continue-with-optional-error=yes \
18+
--log-dir=.
19+
hdiutil detach /Volumes/"$(basename "$MACOS_URL" .dmg)" -quiet
20+
rm m_BASE_HPC_Kit.dmg
21+
fi

0 commit comments

Comments
 (0)