Intel® C++ Compiler 16.0 User and Reference Guide
This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
Some CPU APIs have offload equivalents, each of which take two additional arguments to specify the target type and target number, defined by the following arguments:
The offload.h header file defines all the function calls that can be made from the CPU to affect the coprocessor's environment.
This topic uses the CPU API omp_set_num_threads and its offload variations as an example. See also the topics listed below for more CPU APIs.
| CPU API |
|---|
void omp_set_num_threads (int num_threads); |
| Offload API |
|---|
void omp_set_num_threads_target (TARGET_TYPE target_type, int target_number, int num_threads); |
#include "offload.h"
#include "omp.h"
#include <stdio.h>
int main()
{
int value, result;
value = 66;
omp_set_num_threads_target(TARGET_MIC, 0, value);
#pragma offload target(mic) out(result)
#pragma omp parallel
#pragma omp master
result = omp_get_num_threads();
printf("Number of threads on target %d\n", result);
if (result != value) {
printf("failed1 result=%d, value=%d\n", result, value);
return 1;
}
return 0;
}