User and Reference Guide for the Intel® C++ Compiler 14.0
This topic only applies to IA-32 architecture targeting Intel® Graphics Technology. Intel® Graphics Technology is a preview feature.
The statement following the offload pragma is converted into an outlined function that runs on the coprocessor. This code is permitted to call other functions. To ensure that these called functions are also available on the coprocessor, you must specify the following special function attribute:
__declspec( target (gfx)) function-declaration
All functions in the program are always compiled for the CPU and are available to be called on the CPU. However, only functions marked with this special attribute are available to be called by offloaded code, and only these functions can be called on the coprocessor.
Global variables are treated in a similar fashion. All global variables are always present in the CPU code. But only global variables with the target attribute are compiled into the binary offloaded to the target. Specify the following special variable attribute:
__declspec( target (gfx))variable-declaration
Compiling only functions and data explicitly marked with the target attribute into the target binary ensures that the code on the coprocessor is as small as possible.
The compiler issues warnings for functions and data referenced within offloaded code that do not have the target attribute.
The presence of a function call within an offloaded construct with a target attribute does not automatically declare that function as available on that target. The function definition must include the appropriate target attribute to ensure that the function is available on the target.
The definition and all declarations of a variable or function with a target attribute must be consistent with each other across all compilation units.
__declspec(target(gfx))
int glo__declspec(target(gfx)) //create a host and a target allocation of the global variable
int global = 55;
__declspec(target(gfx)) //create a host and a target version of the function foo
int foo()
{
return ++global;
}
int main (int argc, char* argv)
{
int i;
#pragma offload target(gfx) inout(global) //offload the following loop to the target
#pragma parallel_loop
for (int i = 0; i < 1; i++)
{
foo();
}
printf("global = %d (should be 56)\n", global);
if (global == 56) {
printf("Passed\n");
return 0;
}
else {
printf("Failed\n");
return 1;
}
}
|
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. Notice revision #20110804 |