Programming Guide

Contents

Use a Config file for
setvars.sh
on Linux or macOS

The
setvars.sh
script sets environment variables for use with the oneAPI toolkits by sourcing each of the
<install-dir>/latest/env/vars.sh
scripts found in the respective oneAPI folders. Unless you configure your Linux system to source the
setvars.sh
script automatically, it must be sourced every time a new terminal window is opened for command line development, or prior to launching Eclipse* or any other C/C++ IDE or editor you use for C/C++ development. For more information, see Configure Your System.
The procedure below describes how to use a configuration file to manage environment variables.

Versions and Configurations

Some oneAPI tools support installation of multiple versions. For those tools that do support multiple versions, the directory is organized like this:
[Component] directory - [1.0] version directory - [1.1] version directory - [1.2] version directory - [latest -> 1.2] symlink or shortcut
For example:
For all tools, there is a symlink named
latest
that points to the latest installed version of that component; and the
vars.sh
script located in the
latest/env/
folder is what the
setvars.sh
sources by default.
If required,
setvars.sh
can be customized to point to a specific directory by using a configuration file.

--config Parameter

The top level
setvars.sh
script accepts a
--config
parameter that identifies your custom
config.txt
file.
> source <install-dir>/setvars.sh --config="full/path/to/your/config.txt"
The name of your configuration file can have any name you choose. You can create many config files to setup a variety of development or test environments. For example, you might want to test the latest version of a library with an older version of a compiler; use a setvars config file to manage such a setup.

Config File Sample

The examples below show a simple example of the config file:
Load Latest of Everything but...
mkl=1.1 dldt=exclude
Exclude Everything but...
default=exclude mkl=1.0 ipp=latest
The configuration text file must follow these requirements:
  • a newline delimited text file
  • each line consists of a single
    "key=value"
    pair
  • "key"
    names a component folder in the top-level set of oneAPI directories (the folders found in the
    $ONEAPI_ROOT
    directory). If a
    "key"
    appears more than once in a config file, the last
    "key"
    wins and any prior keys with the same name are ignored.
  • "
    value
    " names a version directory that is found at the top-level of the component directory. This includes any symlinks (such as
    latest
    ) that might be present at that level in the component directory.
    • OR
      "value"
      can be
      "exclude"
      , which means the named key will NOT have its
      env/vars.sh
      script sourced by the
      setvars.sh
      script.
The
"key=value"
pair
"default=exclude"
is a special case. When included, it will exclude sourcing ALL
env/vars.sh
scripts, except those that are listed in the config file. See the examples below.

Further Customization of Config Files

The config file can be used to exclude specific components, include specific component versions or only include specific component versions that are named after a
"default=exclude"
statement.
By default,
setvars.sh
will process the
latest
version of each
env/vars.sh
script.
To explain this further, the sample below shows two versions of oneMKL installed: 2021.1-beta03 and 2021.1-beta04. There is a symlink to 2021-beta04 indicating that it is the latest version, so by default
setvars.sh
will
source
the 2021.1-beta04
vars.sh
script in the
mkl
folder.
/opt/intel/oneapi/mkl | |-- 2021.1-beta03 | |-- env | |-- include | |-- interfaces | |-- lib | `-- tools | |-- 2021.1-beta04 | |-- env | |-- include | |-- interfaces | |-- lib | `-- tools | `-- latest -> 2021.1-beta04 |-- env |-- include |-- interfaces |-- lib `-- tools
Specify a Specific Version
To direct
setvars.sh
to source the
<install-dir>/mkl/2021.1-beta03/env/vars.sh
script, add
mkl=2021.1-beta03
to your config file.
This instructs
setvars.sh
to source on the
env/vars.sh
script located in the
2021.1-beta03
version folder inside the
mkl
directory. For other installed components,
setvars.sh
will source the
env/vars.sh
script located in the latest version folder.
Exclude Specific Components
To exclude a component, use the following syntax:
<key>=exclude
For example, to exclude Intel IPP, but include the 2021.1-beta03 version of oneMKL:
mkl=2021.1-beta03 ipp=exclude
In this example:
  • setvars.sh
    WILL source the Intel one MKL 2021.1-beta03
    env/vars.sh
    script
  • setvars.sh
    WILL NOT source any Intel IPP
    env/vars.sh
    script files
  • setvars.sh
    WILL source the latest version of the remaining
    env/vars.sh
    script files
Include Specific Components
To source a specific list of component
env/vars.sh
scripts, you must first exclude all
env/vars.sh
scripts. Then add back the list of components to be sourced by
setvars.sh
. Use the following syntax to exclude all component
env/vars.sh
scripts from being sourced:
default=exclude
For example, to have
setvars.sh
source only the oneMKL and Intel IPP component
env/vars.sh
scripts, use this config file:
default=exclude mkl=2021.1-beta03 ipp=latest
In this example:
  • setvars.sh
    WILL source the oneMKL 2021.1-beta03
    env/vars.sh
    script
  • setvars.sh
    WILL source the latest version of the Intel IPP
    env/vars.sh
    script
  • setvars.sh
    WILL NOT source the
    env/vars.sh
    script for any other components

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.