In this step, you find the code section that finds the number of targets.
In Solution Explorer, double-click tbo_sort.c.
Find the following code:
#ifdef __INTEL_OFFLOAD printf(" Checking for Intel(R) Xeon Phi(TM) (Target CPU)devices...\n\n"); num_devices = _Offload_number_of_devices(); printf(" Number of Target devices installed: %d\n\n",num_devices); #endif
In this code block, the #ifdef
pragma contains the predefined macro __INTEL_OFFLOAD
. By default when the code contains offload language extensions appear in the source code, the compiler defines this macro to compile and execute the code block on the host. Otherwise, the compiler does not define the macro and does not compile the code block. You can exclude the offload language extension and disable defining this macro with the no-offload compiler option to compile the code into an application that runs on the host only. This option is useful when you want to ensure that your code works before offloading the code to the target.
Later in this tutorial, you will exclude this code block and other offload language extensions when you compile the same code with the no-offload compiler option.
Also within the code block is code to count the number of targets. The _Offload_number_of_devices
function returns the quantity installed and functioning targets. If the system does not have any installed and functioning targets, the function returns -1
.
In the next step, you will find the code section defined to run on both the host and target.