[Bug tree-optimization/49960] inconsistant outputs when enabling autopar for a self -dependence testcase

razya at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 1 09:58:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49960

--- Comment #2 from razya at gcc dot gnu.org 2011-09-01 09:57:21 UTC ---
(In reply to comment #1)
> Created attachment 24901 [details]
> self dependence testcase

Another testcase failing due to a slightly different problem with the self data
dependence analysis:

#include <stdio.h>
#define MB 100
#define NA 70
#define MA 80

int T[MB][MA],A[MA][NA],B[MB][NA];
void MRTRBR(int MA_1, int NA_1, int MB_1)
{
   int i,j, t,k;

   for (k = 3; k < NA_1; k++)
     for (i= 3; i < MA_1; i++)
       for (j = 3; j < MB_1; j++)
         {
            t = T[i][j];
            T[i][j] = t+2+A[i][k]*B[j][k];
         }
}
void main ()
{
 int j,i;

  for (i= 3; i < MA; i++)
    for (j = 3; j < MB; j++)
       T[i][j] = (i>j?i:j);

  MRTRBR (MA,NA,MB);

  for (i= MA-1; i < MA; i++)
    for (j = MB-10; j < MB; j++)
      printf ("i %d j %d T[i][j] = %d\n",i,j,T[i][j]);
}

autopar parallelizes the k loop (I reduced the threshold of # of iterations to
enable parallelization of the outer loop), because
the data dependence analysis claims that the dependence between  
the writes to T[i][j] is (0,0,0).

This causes inconsistent runs:

> ./a.out 
i 79 j 90 T[i][j] = 216
i 79 j 91 T[i][j] = 217
i 79 j 92 T[i][j] = 220
i 79 j 93 T[i][j] = 219
i 79 j 94 T[i][j] = 222
i 79 j 95 T[i][j] = 221
i 79 j 96 T[i][j] = 222
i 79 j 97 T[i][j] = 223
i 79 j 98 T[i][j] = 224
i 79 j 99 T[i][j] = 225
> ./a.out 
i 79 j 90 T[i][j] = 224
i 79 j 91 T[i][j] = 225
i 79 j 92 T[i][j] = 226
i 79 j 93 T[i][j] = 227
i 79 j 94 T[i][j] = 228
i 79 j 95 T[i][j] = 229
i 79 j 96 T[i][j] = 230
i 79 j 97 T[i][j] = 231
i 79 j 98 T[i][j] = 232
i 79 j 99 T[i][j] = 233



More information about the Gcc-bugs mailing list