GAP Message - remark #30525: (PAR) Insert a "#pragma loop count min(128)" or "!dir$ loop count min(128)" statement right before the loop to parallelize the loop


Message

Insert a "#pragma loop count min(128)" or "!dir$ loop count min(128)" statement right before the loop at line 123 to parallelize the loop. [VERIFY] Make sure that the loop has a minimum of 128 iterations.

Description

This message advises you to add "#pragma loop count" before the specified loop. This pragma indicates the minimum trip count (that is, the number of iterations) of the loop that enables the parallelization of the loop.

The minimum trip count required to parallelize the loop may differ depending on the target architecture, and this will be reflected in the message generated.

Example (in C language)

#define N 10000
float A[N], B[N];
void foo(int n)
{
  int i;
  for (i =0; i < n; i++) {
      A[i] = A[i] + B[i] * B[i] + 1.5;
  }
}

In this case, the compiler may not parallelize the loop because it is not sure that n is large enough for the parallelization to be beneficial. The message it generates is of the form [C/C++]:

id30525.c(6): remark #30525: (PAR) Insert a "#pragma loop count min(128)" statement right before the loop at line 6 to parallelize the loop. [VERIFY] Make sure that the loop has a minimum of 128 iterations.

If you determine it is safe to do so, you can add the pragma as follows:

#define N 10000
float A[N], B[N];
void foo(int n)
{
  int i;
#pragma loop count min(128)
  for (i =0; i < n; i++) {
      A[i] = A[i] + B[i] * B[i] + 1.5;
  }
}

Verify

Make sure that the loop has the minimum number of iterations, as specified in the diagnostic message.

 

Optimization Notice in English

标签:
如需更全面地了解编译器优化,请参阅优化注意事项