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