Compiling with : /gcc -O3 -ftree-parallelize-loops=8 -fdump-tree-parloops-details parallelization-2.c -fno-tree-vectorize The runs do not always generate the same output: For example: > ./a.out tmps[1]=1044481 tmps[2]=1044482 tmps[3]=1044483 tmps[4]=1044484 tmps[5]=1044485 tmps[6]=1044486 tmps[7]=1044487 > ./a.out tmps[1]=786433 tmps[2]=786434 tmps[3]=786435 tmps[4]=786436 tmps[5]=786437 tmps[6]=786438 tmps[7]=786439
Created attachment 24901 [details] self dependence testcase
(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
Author: razya Date: Wed Nov 16 14:58:04 2011 New Revision: 181409 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181409 Log: PR tree-optimization/49960 * gcc.dg/autopar/pr49960.c: New test. * gcc.dg/autopar/pr49960-1.c: New test. Added: trunk/gcc/testsuite/gcc.dg/autopar/pr49960-1.c trunk/gcc/testsuite/gcc.dg/autopar/pr49960.c
Author: razya Date: Wed Nov 16 14:59:14 2011 New Revision: 181410 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181410 Log: PR tree-optimization/49960 * gcc.dg/autopar/pr49960.c: New test. * gcc.dg/autopar/pr49960-1.c: New test. Modified: trunk/gcc/testsuite/ChangeLog
Author: razya Date: Wed Nov 16 15:01:47 2011 New Revision: 181411 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181411 Log: PR tree-optimization/49960 * tree-data-ref.c (initialize_data_dependence_relation): Add initializations. Remove call to compute_self_dependence. (compute_affine_dependence): Remove the !DDR_SELF_REFERENCE condition. (compute_self_dependence): Remove old code. Add call to compute_affine_dependence. (compute_all_dependences): Remove call to compute_self_dependence. Add call to compute_affine_dependence. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-data-ref.c
Given this discussion ( https://gcc.gnu.org/ml/gcc-patches/2011-11/msg02081.html ) this follow-up patch was committed. https://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00985.html Author: razya Date: Thu Nov 24 14:07:36 2011 New Revision: 181691 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181691 Log: * tree-data-ref.c (initialize_data_dependence_relation): Update * comment for the self dependence case. (compute_self_dependence): Remove. * tree-vect-data-refs.c (vect_analyze_data_refs): Remove call to compute_self_dependenc. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-data-ref.c trunk/gcc/tree-vect-data-refs.c
patch and test-case committed long ago, resolving marked-fixed.