Use Predefined Macros to Specify Intel® Compilers
This topic shows how to use predefined macros to specify an Intel® compiler or version of an Intel compiler.
Predefined Macros to Specify Compiler and Version
When you install both the Intel® oneAPI Base Toolkit (Base Kit) and the Intel® oneAPI HPC Toolkit (HPC Kit), you will notice that there are three compilers installed:
- Intel® DPC++ Compiler
- Intel® C++ Compiler
- Intel® C++ Compiler Classic
You can use the following predefined macros to invoke a specific compiler or version of a compiler:
Compiler
| Predefined Macros to Differentiate from Other Compiler
| Notes
|
---|---|---|
Intel® DPC++ Compiler
|
| SYCL_LANGUAGE_VERSION is defined in SYCL* spec and should be defined by all SYCL compilers.
__INTEL_LLVM_COMPILER is used to select the compiler.
|
Intel® C++ Compiler
|
| __INTEL_LLVM_COMPILER is used to select the compiler.
__VERSION is used to select the compiler version.
|
Predefined Macros for Intel® DPC++ Compiler
The following example uses
#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
to define a code block specific to the Intel® DPC++ Compiler:
// dpcpp only #if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) // code specific for DPC++ compiler below // ... ... // example only std::cout << "SYCL_LANGUAGE_VERSION: " << SYCL_LANGUAGE_VERSION << std::endl; std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl; std::cout << "__VERSION__: " << __VERSION__ << std::endl; #endif
Example output using the Intel® oneAPI Toolkit Gold release with an Intel DPC++ Compiler patch release of 2021.1.2:
Windows
| Linux
|
---|---|
|
|
Predefined Macros for Intel® C++ Compiler
The following example uses
#if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
to define a code block specific to the Intel® C++ Compiler:
// icx only #if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER) // code specific for Intel C++ Compiler below // ... ... // example only std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl; std::cout << "__VERSION__: " << __VERSION__ << std::endl; #endif
Example output using the Intel® oneAPI Toolkit Gold release with an Intel C++ Compiler patch release of 2021.1.2:
Windows
| Linux
|
---|---|
|
|