Dealing with Multiple Coprocessors in a System

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

Use the functions described in this section to determine:

  • the number of coprocessors in a system

  • the coprocessor on which a program is running

Use the header file offload.h to define the interfaces for these functions and their usage. Include it with #include offload.h.

Note

In a system with multiple coprocessors, you need to specify the target-number argument when using the offload pragma to reliably use data persistence. When you use alloc_if or free_if to implement data persistence on the coprocessor, but do not specify target-number, the compiler runtime randomly chooses a coprocessor, so the chosen coprocessor could be one on which the data is not available.

Determining the Number of Coprocessors in a System

To determine the number of coprocessors in the system, use the function int _Offload_number_of_devices().

The function returns an integer equal to the number of coprocessors installed and working in the system. If none are installed and working, the return value is 0.

Determining the Coprocessor on Which a Program is Running

To determine the coprocessor that is executing the program, use the function int _Offload_get_device_number().

The function returns an integer equal to the number of the coprocessor executing the program, where 0 is the first card. If the program is executing on the CPU, the return value is -1.

Determining if Code has Completed Running on a Coprocessor

To determine if a section of offloaded code has completed running on a given coprocessor, you can use the API _Offload_signaled().

The syntax for this API is:

extern int _Offload_signaled(int target_number, void *signal);

For more complete information about compiler optimizations, see our Optimization Notice.