Install Intel oneAPI C++ and Fortran compiler
Intel oneAPI is a cross-platform toolset that covers several programming languages including C, C++, Fortran and Python. Intel oneAPI replaces Intel Parallel Studio. Intel oneAPI including the C++ “icpx” compiler, Fortran “ifx” compiler, and Intel MPI is free-to-use and no login is required to download oneAPI.
We suggest using the “online installer” download, which is a small download. The “online” installer can be copied over SSH to an HPC user directory for example and installed from the Terminal.
Windows requires Visual Studio Community to be installed first–IDE integration is optional and we don’t use it.
Visual Studio integration is optional–if installed, cmake -G "Visual Studio 17 2022"
can be used to generate Visual Studio project files.
Install the oneAPI Base Toolkit with options:
- Math Kernel Library (oneMKL)
- (optional) GDB debugger
Install oneAPI HPC toolkit with options:
- Intel MPI library
- Intel C++ compiler
- Intel Fortran compiler
Usage
There are distinct usage patterns to access Intel oneAPI compilers on Windows vs. Linux.
Windows
On Windows a Start menu shortcut for a oneAPI command prompt is installed. Powershell can also use “oneapi-vars.bat” to set the environment variables. For example, make a script “oneapi.ps1” like:
$Env:CC="icx"
$Env:FC="ifx"
$Env:CXX="icx"
& $Env:COMSPEC /c '"%PROGRAMFILES(X86)%\Intel\oneAPI\2024.2\oneapi-vars.bat" && pwsh'
$Env:MPI_ROOT=$Env:I_MPI_ROOT
Note that oneapi-vars.bat sets environment variable CMAKE_PREFIX_PATH so don’t just blindly overwrite it.
If CMake Visual Studio generater is desired, ensure:
- CMake ≥ 3.29 is used
- Intel oneAPI Visual Studio integrations are installed
- use CMake configure options
cmake -Bbuild -G "Visual Studio 17 2022" -T fortran=ifx
Troubleshooting:
If problems with finding packages with oneAPI on Windows and CMake occur, ensure that MSYS2 paths aren’t mixed in with the oneAPI environment. See the project CMakeConfigureLog.yaml and look for unwanted paths in the include commands.
Linux
Set environment variables CC, CXX, FC via script
On Linux, oneAPI requires GNU GCC headers etc.. Some HPC systems have a too-old GCC version defaulting for Intel oneAPI. This can cause problems with C++ stdlib or other linking problems. If needed, set environment variable CXXFLAGS for Intel GCC toolchain if needed in custom “oneapi.sh” like:
export CXXFLAGS=--gcc-toolchain=/opt/rh/gcc-toolset-12/root/usr/
which can be determined like:
scl enable gcc-toolset-12 "which g++"