oneAPI: Compiling [medbow]

The intention of this page is to demonstrate how to use the oneAPI toolkit on MedicineBow

It is not to teach C/C++/Fortran nor any of the associated libraries such as the MKL, MPI and TBB.

Module Loading

To get started, first load the oneapi/<version> module you wsh to use.

This will setup your environment, adding and extending various environment variables, opening up access to compilers and libraries.

[]$ module load oneapi/2024.1.0 :: initializing oneAPI environment ... -bash: BASH_VERSION = 5.1.8(1)-release args: Using "$@" for setvars.sh arguments: load oneapi/2024.1.0 :: advisor -- latest :: ccl -- latest :: compiler -- latest :: dal -- latest :: debugger -- latest :: dev-utilities -- latest :: dnnl -- latest :: dpcpp-ct -- latest :: dpl -- latest :: ipp -- latest :: ippcp -- latest :: mkl -- latest :: mpi -- latest :: tbb -- latest :: vtune -- latest :: oneAPI environment initialized ::

If you try loading the module a second time within an existing session, you will see the following warning:

[]$ module load oneapi/2024.2.1 :: WARNING: setvars.sh has already been run. Skipping re-execution. To force a re-execution of setvars.sh, use the '--force' option. Using '--force' can result in excessive use of your environment variables. usage: source setvars.sh [--force] [--config=file] [--help] [...] --force Force setvars.sh to re-run, doing so may overload environment. --config=file Customize env vars using a setvars.sh configuration file. --help Display this help message and exit. ... Additional args are passed to individual env/vars.sh scripts and should follow this script's arguments. Some POSIX shells do not accept command-line options. In that case, you can pass command-line options via the SETVARS_ARGS environment variable. For example: $ SETVARS_ARGS="ia32 --config=config.txt" ; export SETVARS_ARGS $ . path/to/setvars.sh The SETVARS_ARGS environment variable is cleared on exiting setvars.sh.

Note: Although performing a module purge will remove the oneapi module from your module list, it does not clean up the new/modified environment variables. This is due to them not being directly set by the module file, but rather by an addition script that was called.

Currently, you will need to start a new session if you want a clean environment.

Using

Use the module name oneapi to discover versions available and to load the toolkit.

Examples

Intel provides a comprehensive list of examples of code samples available via their GitHub oneAPI-samples repository.

[]$ git clone https://github.com/oneapi-src/oneAPI-samples []$ module load oneapi/2024.2.1 []$ cd oneAPI-samples/Libraries/MPI/jacobian_solver []$ make clean []$ make [jacobian_solver]$ salloc -A arcc -t 10:00 --cpus-per-task=1 --nodes=3 --ntasks-per-node=2 --mem=16G --partition=teton salloc: Granted job allocation 3782711 salloc: Nodes t[285-287] are ready for job [@t285 jacobian_solver]$ unset I_MPI_EXTRA_FILESYSTEM_LIST [@t285 jacobian_solver]$ unset I_MPI_PMI_LIBRARY [@t285 jacobian_solver]$ mpirun -n 6 ./src/01_jacobian_host_mpi_one-sided/mpi3_onesided_jacobian NORM value on iteration 10: 52.076099 ... NORM value on iteration 100: 9.178927 Average solver time: 11.540843(sec) SUCCESS [@t285 jacobian_solver]$ exit exit salloc: Relinquishing job allocation 3782711 [jacobian_solver]$

Note: In the MPI Example above:

  • You must unset I_MPI_EXTRA_FILESYSTEM_LIST and I_MPI_PMI_LIBRARY.

  • Use mpirun (which is actually the oneAPI’s version) and not srun to execute your code.

If you do not, you will warnings of the following form: