Use Predefined Macros for Specific Code for Intel® DPC++ Compiler, Intel® C++ Compiler, Intel® C++ Compiler Classic

By Jennifer L Jiang,

Published:01/26/2021

If you have installed both Intel® oneAPI Base Toolkit (BaseKit) and Intel® oneAPI HPC toolkit (HPC Kit), you might have noticed that there are 3 C++ compilers installed: 

  1. Intel® DPC++ Compiler included in Intel® oneAPI Base Toolkit (BaseKit) 
  2. Intel® C++ Compiler included in Intel® oneAPI Base Toolkit (BaseKit) 
  3. Intel® C++ Compiler Classic  included in Intel® oneAPI HPC toolkit (HPC Kit) 

Different C++ Compilers and Drivers 

The following table provides the different compiler front-end information and drivers. 

Compiler Notes Linux* Driver Windows* Driver
Intel® DPC++ Compiler (BaseKit)  A C++ and Khronos SYCL* compiler with a Clang front-end  dpcpp dpcpp.exe
Intel® C++ Compiler (BaseKit)  A C++ compiler with a Clang front-end, supporting OpenMP* offload icx icx.exe

Intel® C++ Compiler Classic ( HPC-Kit)

A C++ compiler with EDG front-end, supporting OpenMP* but not OpenMP offload

icpc for C++

icc for C

icl.exe

 

 

 

 

 

 

 

 


Predefined Macros of Each Compiler

There are times that you may find the need to have specific code for the specific compiler above, it can be archieved by using the predefined macros provided by Intel Compilers. The differentiative predefined macros are included in the table below:  

Compiler  Predefined Macros to Differentiate from Other Compiler Notes
Intel® DPC++ Compiler

SYCL_LANGUAGE_VERSION; 

__INTEL_LLVM_COMPILER; 

__VERSION

 

SYCL_LANGUAGE_VERSION is defined in SYCL spec and should be defined by all SYCL compilers. 

__INTEL_LLVM_COMPILER can be used to differentiate Intel DPC++ compiler from others. 

Intel® C++ Compiler

__INTEL_LLVM_COMPILER; 

__VERSION

 
Intel® C++ Compiler Classic

__INTEL_COMPILER;

__INTEL_COMPILER_BUILD_DATE

 

 

 

 

 

 

 

 

 

 

 


Predefined Macros for Intel® DPC++ Compiler

To define code block specific to Intel® DPC++ compiler, see the example below by using "#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_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

Output of oneAPI Toolkits gold release with Intel Compiler patch release 2021.1.2:  

Windows Linux

SYCL_LANGUAGE_VERSION: 202001

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, clang 12.0.0

SYCL_LANGUAGE_VERSION: 202001

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode


Predefined Macros for Intel® C++ Compiler

To define code block specific to Intel® C++ Compiler, see the example below by using "#if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_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

Output of oneAPI Toolkits gold release with Intel Compiler patch release 2021.1.2:  

Windows Linux

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, clang 12.0.0

__INTEL_LLVM_COMPILER: 202110

__VERSION__: Intel(R) Clang Based C++, gcc 4.2.1 mode


Predefined Macros for Intel® C++ Compiler Classic

To define code block specific to Intel® C++ Compiler Classic, see the example below by using "#if defined(__INTEL_COMPILER)": 

// icc/icpc classic only
#if defined(__INTEL_COMPILER)
   // code specific for Intel C++ Compiler Classic below
   // ... ...

   // example only
   std::cout << "__INTEL_COMPILER_BUILD_DATE: " << __INTEL_COMPILER_BUILD_DATE << std::endl;
   std::cout << "__INTEL_COMPILER: " << __INTEL_COMPILER << std::endl;
   std::cout << "__VERSION__: " << __VERSION__ << std::endl;
#endif 

Output of oneAPI Toolkits gold release with Intel Compiler patch release 2021.1.2:  

Windows Linux

__INTEL_COMPILER_BUILD_DATE: 20201208

__INTEL_COMPILER: 202110

__INTEL_COMPILER_BUILD_DATE: 20201208

__INTEL_COMPILER: 2021

__VERSION__: Intel(R) C++ g++ 7.5 mode

 

Product and Performance Information

1

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