Advice
If the loop contains a call to a function, the compiler cannot parallelize the loop without more information about the function being called.
However, if the function being called in the loop is a const function or a concurrency-safe function, then the call does not inhibit parallelization of the loop.
Example
Consider the following:
#define N 10000
double A[N], B[N];
int bar(int);
void foo(){
int i;
for (i=0;i<N;i++){
A[i] = B[i] * bar(i);
}
}
In this case, the compiler does not parallelize the loop because it is not safe to do so without further information about routine bar, which is being called.
If you determine it is safe to do so, you can modify the program code as follows:
#define N 10000
double A[N], B[N];
__declspec(const) int bar(int);
void foo(){
int i;
for (i=0;i<N;i++){
A[i] = B[i] * bar(i);
}
}
If you determine it is safe to do so, an alternative way you can modify the program code is as follows:
#define N 10000
double A[N], B[N];
__declspec(concurrency_safe(profitable)) int bar(int);
void foo(){
int i;
for (i=0;i<N;i++){
A[i] = B[i] * bar(i);
}
}
Parent topic: Guided Auto Parallelism Messages
Inglés