This topic shows how to use predefined macros to specify an Intel® compiler or version of an Intel compiler.
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:
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. |
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 |
---|---|
SYCL_LANGUAGE_VERSION: 202001 __INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel® Clang Based C++, clang 12.0.0 |
SYCL_LANGUAGE_VERSION: 202001 __INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel® Clang Based C++, gcc 4.2.1 mode |
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 |
---|---|
__INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel® Clang Based C++, clang 12.0.0 |
__INTEL_LLVM_COMPILER: 202110 __VERSION__: Intel® Clang Based C++, gcc 4.2.1 mode |