Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 482c7cc

Browse files
authored
feat(compilers): include C/C++ compilers (#14)
* feat(compilers): include c/c++ compilers * fix(env): set ONEAPI_ROOT env var * fix(ci): use shell: bash for pip install
1 parent b4436ee commit 482c7cc

File tree

8 files changed

+171
-31
lines changed

8 files changed

+171
-31
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ on:
33
push:
44
branches:
55
- main
6-
- develop
6+
- develop*
77
pull_request:
88
branches:
99
- main
10-
- develop
10+
- develop*
1111
jobs:
1212
test:
1313
name: Test
@@ -52,19 +52,19 @@ jobs:
5252
}
5353
5454
echo "TEST_BINDIR=$bindir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
55-
- name: Install ifort
55+
- name: Install compilers
5656
if: matrix.path != 'default'
5757
uses: ./
5858
with:
5959
path: ${{ env.TEST_BINDIR }}
60-
- name: Install ifort
60+
- name: Install compilers
6161
if: matrix.path == 'default'
6262
uses: ./
63-
- name: Test ifort (Linux & Mac)
63+
- name: Test compilers (Linux & Mac)
6464
if: runner.os != 'Windows'
6565
run: |
6666
./test/test.sh ${{ env.TEST_BINDIR }}
67-
- name: Test ifort (Windows bash)
67+
- name: Test compilers (Windows bash)
6868
if: runner.os == 'Windows'
6969
shell: bash
7070
run: |
@@ -89,12 +89,12 @@ jobs:
8989
echo "unexpected output: $output"
9090
exit 1
9191
fi
92-
- name: Test ifort (Windows pwsh)
92+
- name: Test compilers (Windows pwsh)
9393
if: runner.os == 'Windows'
9494
shell: pwsh
9595
run: |
9696
./test/test.ps1 "${{ env.TEST_BINDIR }}"
97-
- name: Test ifort (Windows cmd)
97+
- name: Test compilers (Windows cmd)
9898
if: runner.os == 'Windows'
9999
shell: cmd
100100
run: |

.github/workflows/integration.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
cache: 'pip'
4242
- name: Install Python dependencies
4343
if: matrix.env == 'pip'
44-
run: |
45-
pip3 install -r test/requirements.txt
44+
shell: bash
45+
run: pip install -r test/requirements.txt
4646
- name: Install miniconda environment
4747
if: matrix.env == 'miniconda'
4848
uses: conda-incubator/setup-miniconda@v2
@@ -60,7 +60,15 @@ jobs:
6060
with:
6161
path: ${{ runner.os != 'Windows' && 'bin' || 'C:\Program Files (x86)\Intel\oneAPI' }}
6262
- name: Build modflow6 (Linux & Mac)
63-
if: runner.os != 'Windows'
63+
if: runner.os != 'Windows' && matrix.env == 'pip'
64+
working-directory: modflow6
65+
shell: bash
66+
run: |
67+
meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin
68+
meson compile -v -C builddir
69+
meson install -C builddir
70+
- name: Build modflow6 (Linux & Mac)
71+
if: runner.os != 'Windows' && matrix.env != 'pip'
6472
working-directory: modflow6
6573
run: |
6674
meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI](https://github.com/modflowpy/install-intelfortran-action/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/modflowpy/install-intelfortran-action/actions/workflows/ci.yml)
44

5-
An action to install and cache the [Intel OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html#gs.bksc2p) Fortran classic compiler via the [HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit.html#gs.g10hgy) and add `ifort` to the path.
5+
An action to install and cache the [Intel OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html#gs.bksc2p) Fortran and C/C++ classic compilers via the [HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit.html#gs.g10hgy).
66

77
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
88
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -24,7 +24,7 @@ An action to install and cache the [Intel OneAPI](https://www.intel.com/content/
2424

2525
## Overview
2626

27-
This action installs the [Intel OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html#gs.bksc2p) Fortran compiler. It does this by downloading and running the [HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit.html#gs.g10hgy) offline installer, selecting only the `ifort-compiler` component. After installing the compiler distribution, the action configures [environment variables](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup.html) necessary to invoke `ifort` from subsequent workflow steps.
27+
This action installs the [Intel OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html#gs.bksc2p) Fortran and C/C++ classic compilers. It does this by downloading and running the [HPC Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit.html#gs.g10hgy) offline installer, selecting only the `ifort-compiler` component. After installing the compiler distribution, the action configures [environment variables](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup.html) necessary to invoke `ifort` or `icc` (`icl` on Windows) from subsequent workflow steps.
2828

2929
## Usage
3030

@@ -67,6 +67,7 @@ A few additional variables are also set:
6767
- `INTEL_COMPILER_BIN_PATH` is the location of compiler executables (this is equivalent to `$HPCKIT_INSTALL_PATH/compilers/latest/<mac, linux, or windows>/bin/intel64`, substituting the proper OS)
6868
- `INTEL_HPCKIT_VERSION` is the oneAPI HPC toolkit version number used (currently `2022.3`)
6969
- `FC` is set to `ifort`
70+
- `CC` is set to `icc` on Linux and macOS and `icl` on Windows
7071

7172
**Note:** GitHub Actions does not preserve environment variables between steps by default &mdash; this action persists them via the [`GITHUB_ENV` environment file](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable).
7273

action.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runs:
3131
echo "INTEL_HPCKIT_INSTALL_PATH=$normalized" >> $GITHUB_ENV
3232
mkdir -p "$normalized"
3333
34-
- name: Set install path
34+
- name: Set install path (Windows)
3535
if: runner.os == 'Windows'
3636
shell: pwsh
3737
run: |
@@ -57,13 +57,13 @@ runs:
5757
version="2022.3.0"
5858
if [ "$RUNNER_OS" == "Linux" ]; then
5959
echo "INTEL_HPCKIT_INSTALLER_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18856/l_HPCKit_p_$version.8751_offline.sh" >> $GITHUB_ENV
60-
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.lin.ifort-compiler" >> $GITHUB_ENV
60+
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.lin.dpcpp-cpp-compiler-pro:intel.oneapi.lin.ifort-compiler" >> $GITHUB_ENV
6161
elif [ "$RUNNER_OS" == "macOS" ]; then
6262
echo "INTEL_HPCKIT_INSTALLER_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18866/m_HPCKit_p_$version.8685_offline.dmg" >> $GITHUB_ENV
63-
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.mac.ifort-compiler" >> $GITHUB_ENV
63+
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.mac.cpp-compiler:intel.oneapi.mac.ifort-compiler" >> $GITHUB_ENV
6464
else
6565
echo "INTEL_HPCKIT_INSTALLER_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18857/w_HPCKit_p_$version.9564_offline.exe" >> $GITHUB_ENV
66-
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.win.ifort-compiler" >> $GITHUB_ENV
66+
echo "INTEL_HPCKIT_COMPONENTS=intel.oneapi.win.cpp-compiler:intel.oneapi.win.ifort-compiler" >> $GITHUB_ENV
6767
fi
6868
6969
echo "using HPC toolkit version $version"
@@ -81,7 +81,7 @@ runs:
8181
uses: martijnhols/actions-cache/restore@v3
8282
with:
8383
path: ${{ env.INTEL_HPCKIT_INSTALL_PATH }}
84-
key: ifort-${{ runner.os }}-${{ env.INTEL_HPCKIT_VERSION }}-${{ env.INTEL_HPCKIT_COMPONENTS }}
84+
key: intelfortran-${{ runner.os }}-${{ env.INTEL_HPCKIT_VERSION }}-${{ env.INTEL_HPCKIT_COMPONENTS }}
8585

8686
- name: Restore GNU tar
8787
if: runner.os == 'windows'
@@ -90,15 +90,15 @@ runs:
9090
# restore GNU tar
9191
mv "$RUNNER_TEMP\tar.exe" 'C:\Program Files\Git\usr\bin\tar.exe'
9292
93-
- name: Install Intel fortran
93+
- name: Install compilers
9494
if: runner.os != 'Windows' && steps.cache-ifort.outputs.cache-hit != 'true'
9595
shell: bash
9696
run: |
9797
echo "downloading and running HPC kit installer"
9898
os=$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]')
9999
"${{ github.action_path }}/scripts/install_$os.sh" "${{ env.INTEL_HPCKIT_INSTALL_PATH }}" "${{ env.INTEL_HPCKIT_INSTALLER_URL }}" "${{ env.INTEL_HPCKIT_COMPONENTS }}"
100100
101-
- name: Install Intel fortran
101+
- name: Install compilers (Windows)
102102
if: runner.os == 'Windows' && steps.cache-ifort.outputs.cache-hit != 'true'
103103
shell: cmd
104104
run: |
@@ -110,7 +110,7 @@ runs:
110110
uses: martijnhols/actions-cache/save@v3
111111
with:
112112
path: ${{ env.INTEL_HPCKIT_INSTALL_PATH }}
113-
key: ifort-${{ runner.os }}-${{ env.INTEL_HPCKIT_VERSION }}-${{ env.INTEL_HPCKIT_COMPONENTS }}
113+
key: intelfortran-${{ runner.os }}-${{ env.INTEL_HPCKIT_VERSION }}-${{ env.INTEL_HPCKIT_COMPONENTS }}
114114

115115
- name: Configure system path
116116
if: runner.os != 'Windows'
@@ -136,8 +136,10 @@ runs:
136136
echo "$bindir" >> $GITHUB_PATH
137137
echo "INTEL_COMPILER_BIN_PATH=$bindir" >> $GITHUB_ENV
138138
echo "FC=ifort" >> $GITHUB_ENV
139+
echo "CC=icc" >> $GITHUB_ENV
140+
echo "ONEAPI_ROOT=$INTEL_HPCKIT_INSTALL_PATH" >> $GITHUB_ENV
139141
140-
- name: Configure system path
142+
- name: Configure system path (Windows)
141143
if: runner.os == 'Windows'
142144
shell: cmd
143145
run: |
@@ -148,6 +150,8 @@ runs:
148150
echo %bindir%>>"%GITHUB_PATH%"
149151
echo INTEL_COMPILER_BIN_PATH=%bindir%>>"%GITHUB_ENV%"
150152
echo FC=ifort>>"%GITHUB_ENV%"
153+
echo CC=icl>>"%GITHUB_ENV%"
154+
echo ONEAPI_ROOT=%INTEL_HPCKIT_INSTALL_PATH%>>"%GITHUB_ENV%"
151155
152156
:: prepend MSVC bindir to path
153157
set bindir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64

test/hw.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
cout << "hello world" << endl;
5+
return 0;
6+
}

test/test.bat

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,33 @@ SET output=%%F
55
)
66

77
if /I "%output:hello=%" neq "%output%" (
8-
echo compile succeeded
8+
echo fortran compile succeeded
99
) else (
1010
echo "unexpected output: %output%" exit /b 1
11+
)
12+
13+
del hw
14+
icl test/hw.cpp -o hw
15+
16+
FOR /F "tokens=* USEBACKQ" %%F IN (`hw`) DO (
17+
SET output=%%F
18+
)
19+
20+
if /I "%output:hello=%" neq "%output%" (
21+
echo icl compile succeeded
22+
) else (
23+
echo "icl unexpected output: %output%" exit /b 1
24+
)
25+
26+
del hw
27+
icx test/hw.cpp -o hw
28+
29+
FOR /F "tokens=* USEBACKQ" %%F IN (`hw`) DO (
30+
SET output=%%F
31+
)
32+
33+
if /I "%output:hello=%" neq "%output%" (
34+
echo icx compile succeeded
35+
) else (
36+
echo "icx unexpected output: %output%" exit /b 1
1137
)

test/test.ps1

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,50 @@ if ((get-command "ifort" -ErrorAction SilentlyContinue) -eq $null) {
2020
ifort /QV
2121
}
2222

23-
ifort test/hw.f90 -o hw
24-
$output=$(./hw)
23+
if ((get-command "icl" -ErrorAction SilentlyContinue) -eq $null) {
24+
write-output "icl not available"
25+
exit 1
26+
} else {
27+
write-output "icl found"
28+
icl /QV
29+
}
30+
31+
if ((get-command "icx" -ErrorAction SilentlyContinue) -eq $null) {
32+
write-output "icx not available"
33+
exit 1
34+
} else {
35+
write-output "icx found"
36+
icx /QV
37+
}
38+
39+
ifort test/hw.f90 -o hw.exe
40+
$output=$(./hw.exe)
41+
if ($output -match "hello world") {
42+
write-output "ifort compile succeeded"
43+
write-output $output
44+
} else {
45+
write-output "ifort unexpected output: $output"
46+
exit 1
47+
}
48+
49+
rm -Force hw.exe
50+
icl test/hw.cpp -o hw.exe
51+
$output=$(./hw.exe)
52+
if ($output -match "hello world") {
53+
write-output "icl compile succeeded"
54+
write-output $output
55+
} else {
56+
write-output "icl unexpected output: $output"
57+
exit 1
58+
}
59+
60+
rm -Force hw.exe
61+
icx test/hw.cpp -o hw.exe
62+
$output=$(./hw.exe)
2563
if ($output -match "hello world") {
26-
write-output "compile succeeded"
64+
write-output "icx compile succeeded"
2765
write-output $output
2866
} else {
29-
write-output "unexpected output: $output"
67+
write-output "icx unexpected output: $output"
3068
exit 1
3169
}

test/test.sh

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,76 @@ fi
1717

1818
if command -v ifort &> /dev/null
1919
then
20-
echo "ifort found"
20+
echo "Fortran classic compiler found"
2121
else
22-
echo "ifort not available"
22+
echo "Fortran classic compiler not available"
2323
exit 1
2424
fi
2525

26+
if [[ ( "$OSTYPE" == "cygwin" ) || ( "$OSTYPE" == "msys" ) || ( "$OSTYPE" == "win32" ) ]]; then
27+
cmd=$(command -v icl)
28+
else
29+
cmd=$(command -v icpc)
30+
fi
31+
if [ "$cmd" ]; then
32+
echo "C/C++ classic compiler found"
33+
else
34+
echo "C/C++ classic compiler not available"
35+
exit 1
36+
fi
37+
38+
# if [[ "$OSTYPE" == "darwin"* ]]; then
39+
# echo "DPC++/C++ not supported on macOS, use classic compilers instead"
40+
# else
41+
# if command -v icpx &> /dev/null
42+
# then
43+
# echo "icpx found"
44+
# else
45+
# echo "icpx not available"
46+
# exit 1
47+
# fi
48+
# fi
49+
2650
ifort test/hw.f90 -o hw
2751
output=$(./hw '2>&1')
2852
if [[ "$output" == *"hello world"* ]]
2953
then
30-
echo "compile succeeded"
54+
echo "Fortran program compilation succeeded"
3155
echo "$output"
3256
else
33-
echo "unexpected output: $output"
57+
echo "Fortran program gave unexpected output: $output"
3458
exit 1
3559
fi
60+
61+
sudo rm -rf hw
62+
if [[ ( "$OSTYPE" == "cygwin" ) || ( "$OSTYPE" == "msys" ) || ( "$OSTYPE" == "win32" ) ]]; then
63+
icl test/hw.cpp -o hw.exe
64+
output=$(./hw.exe '2>&1')
65+
else
66+
icpc test/hw.cpp -o hw
67+
output=$(./hw '2>&1')
68+
fi
69+
if [[ "$output" == *"hello world"* ]]
70+
then
71+
echo "C++ program compilation succeeded"
72+
echo "$output"
73+
else
74+
echo "C++ program gave unexpected output: $output"
75+
exit 1
76+
fi
77+
78+
# if [[ "$OSTYPE" == "darwin"* ]]; then
79+
# echo "DPC++/C++ not supported on macOS, use classic compilers instead"
80+
# else
81+
# sudo rm -rf hw
82+
# icpx test/hw.cpp -o hw
83+
# output=$(./hw '2>&1')
84+
# if [[ "$output" == *"hello world"* ]]
85+
# then
86+
# echo "icpx compile succeeded"
87+
# echo "$output"
88+
# else
89+
# echo "icpx unexpected output: $output"
90+
# exit 1
91+
# fi
92+
# fi

0 commit comments

Comments
 (0)