Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include mkl libraries for intel compiler on linux and macOS #72

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
56f36a1
install intel mkl libraries in addition to the compiler (#1)
iulusoy Sep 13, 2023
adbf96a
Update action.yml
iulusoy Sep 13, 2023
f731ad7
Update compatibility matrix (#3)
github-actions[bot] Sep 14, 2023
687069d
Update compatibility matrix (#2)
github-actions[bot] Sep 14, 2023
81c4847
V0 (#4)
iulusoy Sep 14, 2023
3dacbb4
merge
iulusoy Feb 22, 2024
2b7dceb
Merge branch 'fortran-lang-main'
iulusoy Feb 22, 2024
646b405
fix failing macos tests (#6)
iulusoy Mar 7, 2024
d712ae0
Merge branch 'fortran-lang:main' into main
iulusoy Mar 7, 2024
3b77edb
Check usage of marketplace action (#7)
iulusoy Mar 11, 2024
281d495
Sync fork (#8)
iulusoy Mar 14, 2024
428a567
Merge branch 'main' into create-PR-and-sync
iulusoy Mar 14, 2024
0e8b621
removed source setvars and manipulation of DYLD_LIBRARY_PATH
iulusoy Mar 20, 2024
2e936a9
use macos install script for both dmgs, answer y in apt install for a…
iulusoy Mar 27, 2024
940e8cb
remove accidental duplication
iulusoy Mar 27, 2024
847d447
reverse order of passed variables in case string is empty
iulusoy Mar 27, 2024
c594266
remove pasted garbage in link
iulusoy Mar 27, 2024
dc2ccc7
rename macos install script
iulusoy Mar 27, 2024
0bcfd2f
try wo another export of MKLLIB in the action.yml
iulusoy Mar 27, 2024
2e74f55
Merge branch 'main' into create-PR-and-sync
iulusoy Mar 27, 2024
67c9148
export mkllib in test
iulusoy Mar 27, 2024
9a69df5
no latest when using MKLROOT for macos
iulusoy Mar 27, 2024
6894565
Merge branch 'main' into create-PR-and-sync
iulusoy Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/actions/test-mkl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: |
if [[ "${{ inputs.compiler }}" =~ "intel" ]] && [[ "${{ inputs.install_mkl }}" == "true" ]] && ([[ "${{ inputs.version }}" != "2021.5" ]] && [[ "$runner.os" != "macOS" ]]); 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
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
fi
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
install_mkl: true

# - name: Debug with tmate
# uses: mxschmitt/action-tmate@v3
Expand All @@ -85,6 +86,14 @@ jobs:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Test MKL libraries
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'
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- {compiler: gcc, version: 13}
- {compiler: intel, version: '2023.2'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: nvidia-hpc, version: '23.11'}
include:
- os: ubuntu-latest
Expand All @@ -48,11 +49,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
Expand All @@ -68,6 +71,7 @@ jobs:
- *intel-classic* (for `ifort`)
- *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
Expand Down Expand Up @@ -115,8 +119,8 @@ Toolchain support varies across GitHub-hosted runner images.
<!-- compat ends -->

**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

Expand Down
13 changes: 9 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Setup Fortran"
name: "Setup Fortran and libraries"
description: "Setup Fortran compiler and toolchain"
inputs:
compiler:
Expand All @@ -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"
Expand Down Expand Up @@ -57,6 +61,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"
Expand All @@ -76,11 +81,11 @@ runs:
;;
intel-classic)
version=${VERSION:-2023.2.0}
install_intel $platform true
install_intel $platform true ${{ inputs.install_mkl }}
;;
intel)
version=${VERSION:-2024.0}
install_intel $platform false
install_intel $platform false ${{ inputs.install_mkl }}
;;
nvidia-hpc)
version=${VERSION:-23.11}
Expand Down Expand Up @@ -140,6 +145,7 @@ runs:
echo FC=$FC>>$GITHUB_ENV
echo CC=$CC>>$GITHUB_ENV
echo CXX=$CXX>>$GITHUB_ENV
echo "MKLLIB=$MKLLIB" >> $GITHUB_ENV
iulusoy marked this conversation as resolved.
Show resolved Hide resolved

# set fpm env vars
echo FPM_FC=$FC>>$GITHUB_ENV
Expand All @@ -150,7 +156,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
Expand Down
21 changes: 21 additions & 0 deletions install-intel-macos.sh
Original file line number Diff line number Diff line change
@@ -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
109 changes: 82 additions & 27 deletions setup-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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
Expand Down Expand Up @@ -244,6 +245,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
Expand Down Expand Up @@ -278,6 +292,25 @@ intel_version_map_m()
esac
}

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
}

intel_version_map_w()
{
local actual_version=$1
Expand Down Expand Up @@ -328,7 +361,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-2023.PUB"
Expand All @@ -342,84 +378,95 @@ install_intel_apt()
# c/cpp compiler package names changed with 2024+
case $version in
2024*)
sudo apt-get install \
intel-oneapi-compiler-{fortran,dpcpp-cpp}-$version
cpp_name=dpcpp-cpp
;;
*)
sudo apt-get install \
intel-oneapi-compiler-{fortran,dpcpp-cpp-and-cpp-classic}-$version
cpp_name=dpcpp-cpp-and-cpp-classic
;;
esac

if $install_mkl; then
sudo apt-get install -y \
intel-oneapi-compiler-{fortran,"$cpp_name"}-$version \
intel-oneapi-mkl-$mkl_version
else
sudo apt-get install -y \
intel-oneapi-compiler-{fortran,"$cpp_name"}-$version
fi

source /opt/intel/oneapi/setvars.sh
export_intel_vars
}

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
;;
*)
exit 1
;;
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
Expand Down Expand Up @@ -476,12 +523,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
Expand All @@ -507,6 +557,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()
Expand Down
Loading