Intel® Fortran Compiler 16.0 User and Reference Guide

Writing Code that Should Not Be Built for CPU-Only Execution

This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

You can write code that should not be built when the target is a CPU-only executable.

By default, the compiler defines the macro __INTEL_OFFLOAD. You can write code within an #ifdef __INTEL_OFFLOAD section when the source code is customized for running on the coprocessor, either heterogeneously or natively.

For example, you can use this macro to protect code on the host that should only be executed for an offload build, such as calls to the omp_set_num_threads_target family of APIs in mic_lib.f90.

Example

The section for the host compiler works only when you compile with the [Q]offload compiler option with the keyword optional, or the Qmic (Windows*) or mmic (Linux*) compiler option.

#ifdef __INTEL_OFFLOAD
   #ifdef __MIC__
          PRINT *,"Using offload compiler :  Hello from the coprocessor"
   #else  /* __MIC__ */
          PRINT *,"Using offload compiler :  Hello from the CPU"
   #endif  /* __MIC__ */
   #else
   	#ifdef __MIC__
         	 PRINT *,"Using native compiler :  Hello from the coprocessor"
  	 #else
        	  PRINT *,"Using host compiler :  Hello from the CPU"
   	#endif

#endif

See Also