Visible to Intel only — GUID: GUID-3E79B4A2-B2F3-4B37-B6F0-2D0DBA80FCA1
Use a Config file for setvars.bat on Windows*
The setvars.bat script sets environment variables for use with the oneAPI toolkits by executing each of the <install-dir>\latest\env\vars.bat scripts found in the respective oneAPI folders. Unless you configure your Windows system to run the setvars.bat script automatically, it must be executed every time a new terminal window is opened for command line development, or prior to launching Visual Studio Code, Sublime Text, or any other C/C++ editor you use. 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 (assuming a default installation and using the compiler as an example):
Program Files (x86)\\Intel\\oneAPI\\compiler\\
|-- 2021.1.1
|-- 2021.2.0
`-- latest -> 2021.2.0
For example:
For all tools, there is a symbolic link named latest that points to the latest installed version of that component; and the vars.bat script located in the latest\env\ folder is what the setvars.bat executes by default.
If required, setvars.bat can be customized to point to a specific directory by using a configuration file.
–config Parameter
The top level setvars.bat script accepts a --config parameter that identifies your custom config.txt file.
<install-dir>\setvars.bat --config="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 symbolic links (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 vars.bat script executed by the setvars.bat script.
The "key=value" pair "default=exclude" is a special case. When included, it will exclude executing ALL env\vars.bat 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.bat will process the latest version of each env\vars.bat script.
The sample below shows two versions of Intel® oneAPI Math Kernel Library (oneMKL) installed: 2021.1.1 and 2021.2.0. The latest shortcut points to the 2021.2.0 folder because it is the latest version installed. By default, setvars.bat will execute the 2021.2.0 vars.bat script in the mkl folder because that is the folder that latest points to.
Specify a Specific Version
To direct setvars.bat to execute the <install-dir>\mkl\2021.1.1\env\vars.bat script, add mkl=2021.1.1 to your config file.
This instructs setvars.bat to execute the env\vars.bat script located in the 2021.1.1 version folder inside the mkl directory. For other installed components, setvars.bat will execute the env\vars.bat 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® Integrated Performance Primitives (Intel® IPP), but include the 2021.1.1 version of Intel® oneAPI Math Kernel Library (oneMKL):
mkl=2021.1.1
ipp=exclude
In this example:
setvars.bat WILL execute the oneMKL 2021.1.1 env\vars.bat script
setvars.bat WILL NOT execute Intel® IPP env\vars.bat script files
setvars.bat WILL execute the latest version of the remaining env\vars.bat script files
Include Specific Components
To execute a specific list of component env\vars.bat scripts, you must first exclude all env\vars.bat scripts. Then add back the list of components to be executed by setvars.bat. Use the following syntax to exclude all component env\vars.bat scripts from being executed:
default=exclude
For example, to have setvars.bat execute only the oneMKL and Intel IPP component env\vars.bat scripts, use this config file:
default=exclude
mkl=2021.1.1
ipp=latest
In this example:
setvars.bat WILL execute the oneMKL 2021.1.1 env\vars.bat script
setvars.bat WILL execute the latest version of the Intel® IPP env\vars.bat script
setvars.bat WILL NOT execute the env\vars.bat script for any other components