Skip to content

Commit 6c255e5

Browse files
authored
feat: support Intel on Windows (#27)
1 parent d95b9de commit 6c255e5

File tree

5 files changed

+245
-26
lines changed

5 files changed

+245
-26
lines changed

.github/workflows/test.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ jobs:
7676
# {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.2'}}
7777
# {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.1'}}
7878

79+
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.2.0'}}
80+
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.1.0'}}
81+
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.0.0'}}
82+
- {os: windows-2022, toolchain: {compiler: intel, version: '2022.2.0'}}
83+
- {os: windows-2022, toolchain: {compiler: intel, version: '2022.1.0'}}
84+
85+
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.10.0'}}
86+
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.9.0'}}
87+
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.8.0'}}
88+
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.7.0'}}
89+
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.6.0'}}
90+
7991
steps:
8092

8193
- name: Checkout repository
@@ -90,26 +102,37 @@ jobs:
90102
version: ${{ matrix.toolchain.version }}
91103

92104
- name: Check compiler version
93-
if: ${{ steps.setup-fortran.outcome == 'success' }}
105+
if: steps.setup-fortran.outcome == 'success'
94106
shell: bash
95107
env:
96108
FC: ${{ steps.setup-fortran.outputs.fc }}
97109
CC: ${{ steps.setup-fortran.outputs.cc }}
98110
run: |
99-
fcv=$(${{ env.FC }} --version | head -n 1)
100-
ccv=$(${{ env.CC }} --version | head -n 1)
101-
102-
echo $fcv
103-
echo $ccv
104-
105-
fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1)
106-
ccv=$(echo "$ccv" | grep -woE '[0123456789.]+' | head -n 1)
111+
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ matrix.toolchain.compiler }}" =~ "intel" ]]); then
112+
# only last line of output captured by command substitution, write to temp file instead
113+
${{ env.FC }} //QV > "$RUNNER_TEMP/${{ env.FC }}.ver" 2>&1
114+
${{ env.CC }} //QV > "$RUNNER_TEMP/${{ env.CC }}.ver" 2>&1
115+
116+
fcv=$(cat "$RUNNER_TEMP/${{ env.FC }}.ver" | head -n 1)
117+
ccv=$(cat "$RUNNER_TEMP/${{ env.CC }}.ver" | head -n 1)
118+
119+
fcv=${fcv#*Version }
120+
fcv=${fcv%% Build*}
121+
ccv=${ccv#*Version }
122+
ccv=${ccv%% Build*}
123+
else
124+
fcv=$(${{ env.FC }} --version | head -n 1)
125+
ccv=$(${{ env.CC }} --version | head -n 1)
126+
127+
fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1)
128+
ccv=$(echo "$ccv" | grep -woE '[0123456789.]+' | head -n 1)
129+
fi
107130
108-
[[ $fcv == ${{ matrix.toolchain.version }}* ]] || (echo "unexpected Fortran compiler version: $fcv"; exit 1)
109-
[[ $ccv == ${{ matrix.toolchain.version }}* ]] || (echo "unexpected C compiler version: $ccv"; exit 1)
131+
[[ "$fcv" == ${{ matrix.toolchain.version }}* ]] && (echo "found ${{ env.FC }} version: $fcv") || (echo "unexpected ${{ env.FC }} version: $fcv"; exit 1)
132+
[[ "$ccv" == ${{ matrix.toolchain.version }}* ]] && (echo "found ${{ env.CC }} version: $ccv") || (echo "unexpected ${{ env.CC }} version: $ccv"; exit 1)
110133
111134
- name: Test compile program (bash)
112-
if: ${{ steps.setup-fortran.outcome == 'success' }}
135+
if: steps.setup-fortran.outcome == 'success'
113136
shell: bash
114137
env:
115138
FC: ${{ steps.setup-fortran.outputs.fc }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Supported Intel toolchains:
108108
| ubuntu-\* | intel | 2023.2, 2023.1, 2023.0, <br/> 2022.2.1, 2022.2, 2022.1, 2022.0, <br/> 2021.4, 2021.3, 2021.2, 2021.1.2, 2021.1 |
109109
| ubuntu-\* | intel-classic | 2021.10, 2021.9, 2021.8, <br/> 2021.7.1, 2021.7, 2021.6, 2021.5, <br/> 2021.4, 2021.3, 2021.2, 2021.1.2, 2021.1 |
110110
| macos-\* | intel-classic | 2021.10, 2021.9, 2021.8, <br/> 2021.7.1, 2021.7, 2021.6, 2021.5, <br/> 2021.4, 2021.3, 2021.2, 2021.1 |
111+
| windows-\* | intel | 2023.2, 2023.1, 2023.0, 2022.2.0, 2022.1.0 |
112+
| windows-\* | intel-classic | 2021.10.0, 2021.9.0, 2021.8.0, 2021.7.0, 2021.6.0 |
111113

112114

113115
## License

action.yml

Lines changed: 95 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,48 @@ inputs:
1111
outputs:
1212
fc:
1313
description: "Path to Fortran compiler"
14-
value: ${{ steps.setup.outputs.fc }}
14+
value: ${{ steps.outputs.outputs.fc }}
1515
cc:
1616
description: "Path to C compiler"
17-
value: ${{ steps.setup.outputs.cc }}
17+
value: ${{ steps.outputs.outputs.cc }}
1818
runs:
1919
using: "composite"
2020
steps:
21-
- id: setup
22-
name: Setup toolchain
21+
22+
- name: Set oneAPI install dir
23+
id: oneapi-root
24+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
25+
shell: bash
26+
run: echo "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI" >> "$GITHUB_ENV"
27+
28+
# GNU tar can't handle symlinks on Windows, hide it so default Windows tar is used to restore cache
29+
- name: Hide GNU tar
30+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
31+
shell: bash
32+
run: mv "C:\Program Files\Git\usr\bin\tar.exe" "$RUNNER_TEMP\tar.exe"
33+
34+
- name: Get Date
35+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
36+
id: get-date
37+
shell: bash
38+
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> "$GITHUB_OUTPUT"
39+
40+
- name: Restore cache
41+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
42+
id: cache
43+
uses: actions/cache/restore@v3
44+
with:
45+
path: ${{ env.ONEAPI_ROOT }}
46+
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.version }}-${{ steps.get-date.outputs.date }}
47+
48+
- name: Restore GNU tar
49+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
50+
shell: bash
51+
run: mv "$RUNNER_TEMP\tar.exe" 'C:\Program Files\Git\usr\bin\tar.exe'
52+
53+
- name: Setup toolchain
54+
id: setup
55+
if: steps.cache.outputs.cache-hit != 'true'
2356
shell: bash
2457
env:
2558
COMPILER: ${{ inputs.compiler }}
@@ -49,13 +82,61 @@ runs:
4982
;;
5083
esac
5184
52-
which "${FC}"
53-
which "${CC}"
54-
55-
# set outputs
56-
echo "fc=${FC}" >> $GITHUB_OUTPUT
57-
echo "cc=${CC}" >> $GITHUB_OUTPUT
58-
59-
# persist environment variables
60-
echo "FC=${FC}" >> $GITHUB_ENV
61-
echo "CC=${CC}" >> $GITHUB_ENV
85+
if ! ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]]); then
86+
which "${FC}"
87+
which "${CC}"
88+
89+
# persist environment variables
90+
echo "FC=${FC}" >> $GITHUB_ENV
91+
echo "CC=${CC}" >> $GITHUB_ENV
92+
fi
93+
94+
- name: Save cache
95+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel') && steps.cache.outputs.cache-hit != 'true'
96+
uses: actions/cache/save@v3
97+
with:
98+
path: ${{ env.ONEAPI_ROOT }}
99+
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.version }}-${{ steps.get-date.outputs.date }}
100+
101+
- name: Activate oneAPI
102+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
103+
shell: cmd
104+
run: |
105+
for /f "tokens=* usebackq" %%f in (`dir /b "%ONEAPI_ROOT%\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST=%%f"
106+
:: this script fails when install location is not the default
107+
call "%ONEAPI_ROOT%\compiler\%LATEST%\env\vars.bat"
108+
set | findstr /c:"oneAPI" >> "%GITHUB_ENV%"
109+
110+
- name: Set outputs and env vars
111+
shell: bash
112+
id: outputs
113+
run: |
114+
if [ "$RUNNER_OS" == "Windows" ]; then
115+
if [[ "${{ inputs.compiler }}" == "intel" ]]; then
116+
echo fc=ifx>>$GITHUB_OUTPUT
117+
echo cc=icx>>$GITHUB_OUTPUT
118+
echo FC=ifx>>$GITHUB_ENV
119+
echo CC=icx>>$GITHUB_ENV
120+
elif [[ "${{ inputs.compiler }}" == "intel-classic" ]]; then
121+
echo fc=ifort>>$GITHUB_OUTPUT
122+
echo cc=icl>>$GITHUB_OUTPUT
123+
echo FC=ifort>>$GITHUB_ENV
124+
echo CC=icl>>$GITHUB_ENV
125+
else
126+
echo fc=$FC>>$GITHUB_OUTPUT
127+
echo cc=$CC>>$GITHUB_OUTPUT
128+
echo FC=$FC>>$GITHUB_ENV%
129+
echo CC=$CC>>$GITHUB_ENV%
130+
fi
131+
else
132+
echo fc=$FC>>$GITHUB_OUTPUT
133+
echo cc=$CC>>$GITHUB_OUTPUT
134+
echo FC=$FC>>$GITHUB_ENV
135+
echo CC=$CC>>$GITHUB_ENV
136+
fi
137+
138+
# GitHub Actions prepends GNU linker to the PATH before all bash steps, hide it so MSVC linker is found
139+
- name: Hide GNU linker (Windows)
140+
if: runner.os == 'Windows' && contains(inputs.compiler, 'intel')
141+
shell: bash
142+
run: mv "/usr/bin/link" "$RUNNER_TEMP/link"

install-intel-windows.bat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
3+
:: download and unpack installer
4+
curl.exe --output %TEMP%\webimage.exe --url %1 --retry 5 --retry-delay 5
5+
start /b /wait %TEMP%\webimage.exe -s -x -f %TEMP%\webimage_extracted --log %TEMP%\extract.log
6+
del %TEMP%\webimage.exe
7+
8+
:: run installer
9+
%TEMP%\webimage_extracted\bootstrapper.exe -s --action install --components=intel.oneapi.win.cpp-compiler:intel.oneapi.win.ifort-compiler --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=%TEMP%

setup-fortran.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,49 @@ intel_version_map_m()
227227
esac
228228
}
229229

230+
intel_version_map_w()
231+
{
232+
local actual_version=$1
233+
local classic=$2
234+
if $classic; then
235+
case $actual_version in
236+
2021.10.0 | 2021.10)
237+
version=2023.2.0
238+
;;
239+
2021.9.0 | 2021.9)
240+
version=2023.1.0
241+
;;
242+
2021.8.0 | 2021.8)
243+
version=2023.0.0
244+
;;
245+
2021.7.0 | 2021.7)
246+
version=2022.3.0
247+
;;
248+
2021.6.0 | 2021.6)
249+
version=2022.2.0
250+
;;
251+
*)
252+
version=$actual_version
253+
;;
254+
esac
255+
else
256+
case $actual_version in
257+
2023.2 | 2023.1 | 2023.0)
258+
version=$actual_version.0
259+
;;
260+
2022.2.0 | 2022.2)
261+
version=2022.3.0
262+
;;
263+
2022.1.0 | 2022.1)
264+
version=2022.2.0
265+
;;
266+
*)
267+
version=$actual_version
268+
;;
269+
esac
270+
fi
271+
}
272+
230273
install_intel_apt()
231274
{
232275
local version=$1
@@ -334,6 +377,58 @@ install_intel_dmg()
334377
export CXX="icpc"
335378
}
336379

380+
install_intel_win()
381+
{
382+
local version=$1
383+
local classic=$2
384+
intel_version_map_w $version $classic
385+
386+
case $version in
387+
2023.2.0)
388+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/438527fc-7140-422c-a851-389f2791816b/w_HPCKit_p_2023.2.0.49441_offline.exe
389+
;;
390+
2023.1.0)
391+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2a13d966-fcc5-4a66-9fcc-50603820e0c9/w_HPCKit_p_2023.1.0.46357_offline.exe
392+
;;
393+
2023.0.0)
394+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19085/w_HPCKit_p_2023.0.0.25931_offline.exe
395+
;;
396+
2022.3.1)
397+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18976/w_HPCKit_p_2022.3.1.19755_offline.exe
398+
;;
399+
2022.3.0)
400+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18857/w_HPCKit_p_2022.3.0.9564_offline.exe
401+
;;
402+
2022.2.0)
403+
WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18680/w_HPCKit_p_2022.2.0.173_offline.exe
404+
;;
405+
# the installer versions below fail
406+
# 2022.1.2)
407+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18529/w_HPCKit_p_2022.1.2.116_offline.exe
408+
# ;;
409+
# 2022.1.0)
410+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18417/w_HPCKit_p_2022.1.0.93_offline.exe
411+
# ;;
412+
# 2021.4.0)
413+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18247/w_HPCKit_p_2021.4.0.3340_offline.exe
414+
# ;;
415+
# 2021.3.0)
416+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17940/w_HPCKit_p_2021.3.0.3227_offline.exe
417+
# ;;
418+
# 2021.2.0)
419+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17762/w_HPCKit_p_2021.2.0.2901_offline.exe
420+
# ;;
421+
# 2021.1.0)
422+
# WINDOWS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17392/w_HPCKit_p_2021.1.0.2682_offline.exe
423+
# ;;
424+
*)
425+
exit 1
426+
;;
427+
esac
428+
429+
"$GITHUB_ACTION_PATH/install-intel-windows.bat" $WINDOWS_HPCKIT_URL
430+
}
431+
337432
install_intel()
338433
{
339434
local platform=$1
@@ -345,6 +440,15 @@ install_intel()
345440
darwin*)
346441
install_intel_dmg $version
347442
;;
443+
mingw*)
444+
install_intel_win $version $classic
445+
;;
446+
msys*)
447+
install_intel_win $version $classic
448+
;;
449+
cygwin*)
450+
install_intel_win $version $classic
451+
;;
348452
*)
349453
echo "Unsupported platform: $platform"
350454
exit 1

0 commit comments

Comments
 (0)