Skip to content

Commit 33c511f

Browse files
committed
Refactor: Move Intel in CI/CD
1 parent ec69082 commit 33c511f

File tree

2 files changed

+113
-52
lines changed

2 files changed

+113
-52
lines changed

.github/workflows/meta.yml

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
- os: macos-13
4545
mpi: mpich
4646

47-
4847
steps:
4948
- name: Checkout code
5049
uses: actions/checkout@v4
@@ -70,21 +69,6 @@ jobs:
7069
netcdf
7170
netcdf-fortran
7271
73-
- name: (Windows) Setup VS Build environment
74-
if: contains(matrix.os,'windows') && contains(matrix.mpi,'intel')
75-
uses: seanmiddleditch/gha-setup-vsdevenv@master
76-
77-
- name: (Windows) Retrieve Intel toolchain
78-
if: contains(matrix.os,'windows') && contains(matrix.mpi,'intel')
79-
shell: pwsh
80-
working-directory: C:\TEMP
81-
run: |
82-
curl.exe --output webimage.exe --url https://registrationcenter-download.intel.com/akdlm/irc_nas/19085/w_HPCKit_p_2023.0.0.25931_offline.exe --retry 5 --retry-delay 5
83-
Start-Process -FilePath "webimage.exe" -ArgumentList "-s -x -f oneAPI --log extract.log" -Wait
84-
Remove-Item "webimage.exe" -Force
85-
Start-Process -FilePath "oneAPI\bootstrapper.exe" -ArgumentList "-s --action install --eula=accept --components=""intel.oneapi.win.cpp-compiler:intel.oneapi.win.ifort-compiler:intel.oneapi.win.mpi.devel"" -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=." -Wait
86-
Remove-Item "oneAPI" -Force -Recurse
87-
8872
- name: (Ubuntu) Install gfortran
8973
if: contains(matrix.os,'ubuntu')
9074
run: |
@@ -106,48 +90,66 @@ jobs:
10690
sudo apt install -y -q mpich hwloc fabric libhdf5-dev libhdf5-fortran-102 \
10791
libnetcdf-dev libnetcdff-dev
10892
109-
- name: (Ubuntu) Retrieve Intel toolchain
110-
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
111-
timeout-minutes: 1
112-
run: |
113-
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
114-
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
115-
sudo apt-get update
93+
# Intel
11694

117-
- name: (Ubuntu) Install Intel oneAPI
118-
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
119-
uses: fortran-lang/[email protected]
120-
id: setup-fortran
95+
- name: Setup Intel Environment
96+
if: contains(matrix.mpi, 'intel')
97+
uses: ./.github/workflows/setup_intel.yml
12198
with:
122-
compiler: intel
123-
version: 2024.1.0
99+
os: ${{ matrix.os }}
124100

125-
- name: (Ubuntu) finalize oneAPI environment
126-
if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'intel')
101+
- name: (Ubuntu) Build and Install HDF5 from source
102+
if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
103+
# Needs checkout if source code isn't available, adjust if needed
104+
# Ensure compilers are available from the previous step's environment setup
105+
shell: bash
127106
run: |
128-
# Install MPI
129-
sudo apt-get install -y -q intel-oneapi-mpi-devel ninja-build cmake libcurl4-gnutls-dev
107+
# Source again just in case shell context is lost (shouldn't be, but safer)
130108
source /opt/intel/oneapi/setvars.sh --force
131-
printenv >> $GITHUB_ENV
132-
# To run HDF5 with oneAPI, we need to build it from source. Use CMake to generate pkg-config info
109+
# Download HDF5
133110
curl -O -L https://github.com/HDFGroup/hdf5/archive/refs/tags/snapshot-1.14.tar.gz
134111
tar zxf snapshot-1.14.tar.gz
135112
cd hdf5-snapshot-1.14
113+
# Configure HDF5 with Intel compilers
136114
cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DHDF5_BUILD_FORTRAN=ON -DCMAKE_INSTALL_PREFIX=/usr
137115
cd build
138-
make -j
116+
make -j $(nproc)
139117
sudo make install
118+
cd ../.. # Go back to workspace directory
119+
rm -rf hdf5-snapshot-1.14 snapshot-1.14.tar.gz # Clean up
120+
121+
- name: (Ubuntu) Build and Install NetCDF-C from source
122+
if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
123+
shell: bash
124+
run: |
125+
source /opt/intel/oneapi/setvars.sh --force
126+
# Download NetCDF-C
140127
curl -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz -o - | tar xz
141128
cd netcdf-c-4.9.2
142-
CC=icx CXX=icpx FC=ifx ./configure --prefix=/usr --with-hdf5=/usr
143-
CC=icx CXX=icpx FC=ifx make -j
129+
# Configure NetCDF-C with Intel Compilers, referencing installed HDF5
130+
# Set CC/CXX/FC explicitly in environment for configure script
131+
export CC=icx CXX=icpx FC=ifx
132+
./configure --prefix=/usr --enable-netcdf-4 --with-hdf5=/usr
133+
make -j $(nproc)
144134
sudo make install
135+
cd .. # Go back to workspace directory
136+
rm -rf netcdf-c-4.9.2 # Clean up
137+
138+
- name: (Ubuntu) Build and Install NetCDF-Fortran from source
139+
if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
140+
shell: bash
141+
run: |
142+
source /opt/intel/oneapi/setvars.sh --force
143+
# Download NetCDF-Fortran
145144
curl -L https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz -o - | tar xz
146145
cd netcdf-fortran-4.6.1
146+
# Configure NetCDF-Fortran with Intel Compilers using CMake
147147
cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=/usr
148148
cd build
149-
make -j
149+
make -j $(nproc)
150150
sudo make install
151+
cd ../.. # Go back to workspace directory
152+
rm -rf netcdf-fortran-4.6.1 # Clean up
151153
152154
- name: (Windows) Put MSYS2_MinGW64 on PATH
153155
if: contains(matrix.os,'windows') && (!contains(matrix.mpi,'intel'))
@@ -168,26 +170,13 @@ jobs:
168170
# can't use MSMPI_BIN as Actions doesn't update PATH from msmpisetup.exe
169171
run: Test-Path "C:\Program Files\Microsoft MPI\Bin\mpiexec.exe" -PathType leaf
170172

171-
- name: (Windows) test that OneAPI is installed
172-
if: contains(matrix.os,'windows') && contains(matrix.mpi,'intel')
173-
run: |
174-
Test-Path -Path "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" -PathType leaf
175-
Test-Path -Path "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat" -PathType leaf
176-
177173
- name: (Windows) put MSMPI_BIN on PATH (where mpiexec is)
178174
if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
179175
run: |
180176
echo "C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
181177
echo "/c/Program Files/Microsoft MPI/Bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
182178
echo "MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_ENV -Append
183179
184-
- name: (Windows) load OneAPI environment variables
185-
if: contains(matrix.os,'windows') && contains(matrix.mpi,'intel')
186-
shell: cmd
187-
run: |
188-
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
189-
"C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
190-
191180
- name: (Windows) Install MSYS2 msmpi package
192181
if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
193182
shell: msys2 {0}

.github/workflows/setup_intel.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Setup Intel Environment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
setup:
12+
runs-on: ${{ inputs.os }}
13+
steps:
14+
- name: (Windows) Setup VS Build environment
15+
if: contains(inputs.os, 'windows')
16+
uses: seanmiddleditch/gha-setup-vsdevenv@master
17+
18+
- name: (Windows) Retrieve Intel toolchain
19+
if: contains(inputs.os, 'windows')
20+
shell: pwsh
21+
working-directory: C:\TEMP
22+
run: |
23+
New-Item -ItemType Directory -Force -Path C:\TEMP
24+
curl.exe --output webimage.exe --url https://registrationcenter-download.intel.com/akdlm/irc_nas/19085/w_HPCKit_p_2023.0.0.25931_offline.exe --retry 5 --retry-delay 5
25+
Start-Process -FilePath "webimage.exe" -ArgumentList "-s -x -f oneAPI --log extract.log" -Wait
26+
Remove-Item "webimage.exe" -Force
27+
Start-Process -FilePath "oneAPI\bootstrapper.exe" -ArgumentList "-s --action install --eula=accept --components=""intel.oneapi.win.cpp-compiler:intel.oneapi.win.ifort-compiler:intel.oneapi.win.mpi.devel"" -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=." -Wait
28+
Remove-Item "oneAPI" -Force -Recurse
29+
30+
- name: (Windows) test that OneAPI is installed
31+
if: contains(inputs.os, 'windows')
32+
run: |
33+
Test-Path -Path "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" -PathType leaf
34+
Test-Path -Path "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat" -PathType leaf
35+
36+
- name: (Windows) load OneAPI environment variables
37+
if: contains(inputs.os, 'windows')
38+
shell: cmd
39+
run: |
40+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
41+
call "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
42+
echo "PATH=%PATH%" >> %GITHUB_ENV%
43+
echo "INCLUDE=%INCLUDE%" >> %GITHUB_ENV%
44+
echo "LIB=%LIB%" >> %GITHUB_ENV%
45+
# Add any other specific vars if needed, e.g., for MPI
46+
echo "I_MPI_ROOT=%I_MPI_ROOT%" >> %GITHUB_ENV%
47+
48+
# --- Ubuntu Intel Setup ---
49+
- name: (Ubuntu) Retrieve Intel toolchain repo info
50+
if: contains(inputs.os, 'ubuntu')
51+
run: |
52+
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
53+
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
54+
sudo apt-get update
55+
56+
- name: (Ubuntu) Install Intel oneAPI Compilers and MPI
57+
if: contains(inputs.os, 'ubuntu')
58+
# Using the fortran-lang action simplifies compiler setup
59+
uses: fortran-lang/[email protected]
60+
with:
61+
compiler: intel
62+
version: 2024.1.0 # Specify the version you need
63+
64+
- name: (Ubuntu) Install Intel oneAPI MPI and dependencies, setup environment
65+
if: contains(inputs.os, 'ubuntu')
66+
run: |
67+
# Install MPI devel package and build tools needed for HDF5/NetCDF
68+
sudo apt-get install -y -q intel-oneapi-mpi-devel ninja-build cmake libcurl4-gnutls-dev
69+
70+
# Source environment and export to GITHUB_ENV for subsequent steps in the calling workflow
71+
source /opt/intel/oneapi/setvars.sh --force
72+
printenv >> $GITHUB_ENV

0 commit comments

Comments
 (0)