Intel® C++ Compiler 16.0 User and Reference Guide

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

This topic only applies to Intel® 64 and IA-32 architectures targeting Intel® Graphics Technology.

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 target.

For example, you can use this macro to check that the code was built with the negative form of the [Q]offload compiler option.

Example

The section for the host compiler works only when you compile with the negative form of the Qoffload compiler option.

#ifdef __INTEL_OFFLOAD
        cout << "\nThis program is built with __INTEL_OFFLOAD.\n"
<< "The target(gfx) code will be executed on target if it is available\n";
#else
        cout << "\nThis program is built without __INTEL_OFFLOAD\n";
<< "The target(gfx) code will be executed on CPU only.\n";
#endif

Note

This code can only be used in the host code because code for Intel® Graphics Technology does not support this kind of I/O.