| 1 |
name: 'Setup Intel oneAPI Environment' |
| 2 |
description: 'Sets up Intel oneAPI C++, Fortran compilers and MPI on Windows or Ubuntu runners.' |
| 3 |
|
| 4 |
inputs: |
| 5 |
os: |
| 6 |
description: 'Operating system of the runner. Must contain "windows" or "ubuntu".' |
| 7 |
required: true |
| 8 |
type: string |
| 9 |
|
| 10 |
version: |
| 11 |
description: 'Intel oneAPI installer version for Ubuntu (e.g. 2024.1.0).' |
| 12 |
required: false |
| 13 |
default: '2024.1.0' |
| 14 |
type: string |
| 15 |
|
| 16 |
runs: |
| 17 |
using: "composite" |
| 18 |
steps: |
| 19 |
- name: (Windows) Setup VS Build environment |
| 20 |
if: contains(inputs.os, 'windows') |
| 21 |
uses: seanmiddleditch/gha-setup-vsdevenv@v4 |
| 22 |
|
| 23 |
- name: (Windows) Retrieve and Install Intel toolchain |
| 24 |
if: contains(inputs.os, 'windows') |
| 25 |
shell: pwsh |
| 26 |
run: | |
| 27 |
$tempDir = "C:\TEMP\intel_install" |
| 28 |
New-Item -ItemType Directory -Force -Path $tempDir |
| 29 |
cd $tempDir |
| 30 |
$installerName = "w_HPCKit_p_2023.0.0.25931_offline.exe" # Consider using inputs.intel_version_windows if added |
| 31 |
$installerUrl = "https://registrationcenter-download.intel.com/akdlm/irc_nas/19085/$installerName" |
| 32 |
Write-Host "Downloading Intel oneAPI installer..." |
| 33 |
curl.exe --output $installerName --url $installerUrl --retry 5 --retry-delay 5 -L # Added -L for potential redirects |
| 34 |
Write-Host "Extracting installer..." |
| 35 |
Start-Process -FilePath ".\$installerName" -ArgumentList "-s -x -f oneAPI --log extract.log" -Wait -NoNewWindow |
| 36 |
Remove-Item ".\$installerName" -Force |
| 37 |
Write-Host "Installing oneAPI components..." |
| 38 |
# Install C++, Fortran, and MPI development tools silently |
| 39 |
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 -NoNewWindow |
| 40 |
Write-Host "Cleaning up extracted files..." |
| 41 |
Remove-Item ".\oneAPI" -Force -Recurse |
| 42 |
cd .. |
| 43 |
Remove-Item $tempDir -Force -Recurse |
| 44 |
|
| 45 |
- name: (Windows) Test that OneAPI is installed |
| 46 |
if: contains(inputs.os, 'windows') |
| 47 |
shell: pwsh |
| 48 |
run: | |
| 49 |
$setvarsPath = "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" |
| 50 |
$compilerVarsPath = "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat" |
| 51 |
if (-not (Test-Path -Path $setvarsPath -PathType Leaf)) { |
| 52 |
Write-Error "Intel oneAPI setvars.bat not found at $setvarsPath" |
| 53 |
exit 1 |
| 54 |
} |
| 55 |
if (-not (Test-Path -Path $compilerVarsPath -PathType Leaf)) { |
| 56 |
Write-Warning "Intel oneAPI compiler vars.bat not found at $compilerVarsPath. MPI might still work." |
| 57 |
# Depending on requirements, you might want to 'exit 1' here too |
| 58 |
} |
| 59 |
Write-Host "Intel oneAPI installation paths verified." |
| 60 |
|
| 61 |
- name: (Windows) Load OneAPI environment variables |
| 62 |
if: contains(inputs.os, 'windows') |
| 63 |
shell: cmd |
| 64 |
run: | |
| 65 |
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" > NUL |
| 66 |
echo "Setting Intel environment variables..." |
| 67 |
echo "PATH=%PATH%" >> %GITHUB_ENV% |
| 68 |
echo "INCLUDE=%INCLUDE%" >> %GITHUB_ENV% |
| 69 |
echo "LIB=%LIB%" >> %GITHUB_ENV% |
| 70 |
REM Add any other specific vars if needed, e.g., for MPI |
| 71 |
echo "I_MPI_ROOT=%I_MPI_ROOT%" >> %GITHUB_ENV% |
| 72 |
echo "FI_PROVIDER_PATH=%FI_PROVIDER_PATH%" >> %GITHUB_ENV% |
| 73 |
echo "MPI_BIN=%MPI_BIN%" >> %GITHUB_ENV% |
| 74 |
|
| 75 |
# --- Ubuntu Intel Setup --- |
| 76 |
- name: (Ubuntu) Install prerequisites and Intel GPG key |
| 77 |
if: contains(inputs.os, 'ubuntu') |
| 78 |
shell: bash |
| 79 |
run: | |
| 80 |
sudo apt-get update -y -qq |
| 81 |
sudo apt-get install -y -qq gpg wget ca-certificates curl gpg-agent software-properties-common |
| 82 |
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 |
| 83 |
|
| 84 |
- name: (Ubuntu) Add Intel oneAPI repository |
| 85 |
if: contains(inputs.os, 'ubuntu') |
| 86 |
shell: bash |
| 87 |
run: | |
| 88 |
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 |
| 89 |
sudo apt-get update -y -qq |
| 90 |
|
| 91 |
- name: (Ubuntu) Install Intel oneAPI Compilers using fortran-lang action |
| 92 |
if: contains(inputs.os, 'ubuntu') |
| 93 |
uses: fortran-lang/setup-fortran@v1 |
| 94 |
with: |
| 95 |
compiler: intel |
| 96 |
version: ${{ inputs.version }} |
| 97 |
|
| 98 |
- name: (Ubuntu) Install Intel oneAPI MPI and build dependencies |
| 99 |
if: contains(inputs.os, 'ubuntu') |
| 100 |
shell: bash |
| 101 |
run: | |
| 102 |
# Install MPI devel package and common build tools |
| 103 |
# The compilers (icc, ifort) should already be installed by setup-fortran action |
| 104 |
sudo apt-get install -y -q intel-oneapi-mpi-devel intel-oneapi-mkl ninja-build cmake libcurl4-gnutls-dev |
| 105 |
|
| 106 |
- name: (Ubuntu) Source oneAPI environment and add to GITHUB_ENV |
| 107 |
if: contains(inputs.os, 'ubuntu') |
| 108 |
shell: bash |
| 109 |
run: | |
| 110 |
# Source the main setvars script to set up the environment for this step |
| 111 |
# Use --force as we might be in a non-interactive shell |
| 112 |
source /opt/intel/oneapi/setvars.sh --force > /dev/null 2>&1 |
| 113 |
echo "Sourced setvars.sh. Adding key variables to GITHUB_ENV..." |
| 114 |
# Explicitly add key variables to GITHUB_ENV for subsequent steps |
| 115 |
echo "PATH=$PATH" >> $GITHUB_ENV |
| 116 |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV |
| 117 |
echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV |
| 118 |
echo "CPATH=$CPATH" >> $GITHUB_ENV |
| 119 |
echo "CMPLR_ROOT=$CMPLR_ROOT" >> $GITHUB_ENV # Example compiler root |
| 120 |
echo "MPI_ROOT=$MPI_ROOT" >> $GITHUB_ENV # MPI root (check actual variable name if needed, e.g., I_MPI_ROOT) |
| 121 |
echo "I_MPI_ROOT=$I_MPI_ROOT" >> $GITHUB_ENV # Common variable name for Intel MPI root |
| 122 |
echo "FI_PROVIDER_PATH=$FI_PROVIDER_PATH" >> $GITHUB_ENV # Often needed for MPI |