Intel® C++ Compiler 16.0 User and Reference Guide
This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
You can write offloaded sections of code to take advantage of target-specific intrinsic functions. When the compiler generates code for the coprocessor, it defines the macro __MIC__. You can write target-specific code within an #ifdef __MIC__ section.
This example shows how target-specific code may be written within an #ifdef __MIC__ section.
The implementation of the class F32vec is specialized for the CPU and the coprocessor. The offloaded code can use the specialized version if it runs on the coprocessor. If function_1 is executed on the CPU, it uses the CPU version of the class F32vec. If it runs on the coprocessor, it uses the definition from micvec.h.
// The class F32vec will be used in offloaded code // It needs the target(mic) attribute #pragma offload_attribute(push,_Cilk_shared) // Use customized versions for CPU and coprocessor #ifdef __MIC__ // The Intel® MIC Architecture version of the class is in micvec.h #include <micvec.h> #else // The CPU version is written inline class F32vec16 { public: ... friend F32vec16 sqrt(const F32vec16& a); }; #endif #pragma offload_attribute(pop) _Cilk_shared void function_3() { F32vec16 w = ...; F32vec16 s; s = sqrt(w); ... }