From: John Peterson <peterson@cf...>  20060915 20:34:46

Hi Tim, I'm almost afraid to ask... how did you ever find that one!? Do you have a link to a GCC3.3.5 bug report for this issue? John Tim Kr=F6ger writes: > Dear John and all, >=20 > On Tue, 29 Aug 2006, Tim Kr=F6ger wrote: >=20 > > I have been running in optimized mode so far. I now tried debug m= ode > > and got the same results as you. After switching back to optimize= d > > mode, I again got the results I got before. > > > > Maximum number of processes without crash (n.t. =3D not tested): > > > > =09=09debug=09optimized > > grid 1*1*1=091=091 > > grid 2*1*1=093=093 > > grid 3*1*1=095=095 > > grid 4*1*1=097=097=09// seems to be no problem for x*1*1 > > grid 3*3*3=09n.t.=091 > > grid 4*4*4=0927=092=09// this is not a typo > > grid 5*5*5=09n.t.=094 > > grid 6*6*6=09n.t.=095 >=20 > I now found out what the problem is: gcc3.3.5 seems to have an=20 > optimization bug that makes DofMap::sort_sparsity_row() work wrong, = so=20 > that the rows are sometimes not sorted correctly and consequently so= me=20 > indices are inserted more than once. The computed number of nonzero= =20 > local matrix row entries is then too large and sometimes larger than= =20 > the total number of columns of the matrix, in which case PETSc's=20 > function MatCreateMPIAIJ() crashes. >=20 > As a workaround, I have inserted a call to a dummy function, so that= =20 > the compiler does not optimize (see attached patch). My test progra= m=20 > now works fine. >=20 > Since other users might also be using gcc3.3.5, it might be=20 > appropriate to commit this change to cvs. If you know a better way = of=20 > avoiding optimization at a certain place, please let me know. >=20 > Best Regards, >=20 > Tim? patch > Index: include/base/dof_map.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/libmesh/libmesh/include/base/dof_map.h,v > retrieving revision 1.17 > diff c r1.17 dof_map.h > *** include/base/dof_map.h=0928 Jun 2006 21:32:21 0000=091.17 >  include/base/dof_map.h=0915 Sep 2006 07:20:56 0000 > *************** > *** 504,509 **** >  504,516  > DofConstraints _dof_constraints; > =20 > #endif > +=20 > + /** > + * Dummy function that does nothing but can be used to prohibit > + * compiler optimization in some situations where some compilers= > + * have optimization bugs. > + */ > + static void _dummy_function(void); > }; > =20 > =20 > *************** > *** 568,573 **** >  575,584  > =09{ > =09 std::swap (*a, *b); > =20 > + =09 /* Prohibit optimization at this point since gcc 3.3.5 seems > + =09 to have a bug. */ > + =09 this>_dummy_function(); > +=20 > =09 if (a =3D=3D begin) break; > =09 =20 > =09 b=3Da; > Index: src/base/dof_map.C > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/libmesh/libmesh/src/base/dof_map.C,v > retrieving revision 1.94 > diff c r1.94 dof_map.C > *** src/base/dof_map.C=0912 Jun 2006 22:51:29 0000=091.94 >  src/base/dof_map.C=0915 Sep 2006 07:20:56 0000 > *************** > *** 1554,1556 **** >  1554,1561  > #endif // #ifdef ENABLE_AMR > =20 > } > +=20 > + void DofMap::_dummy_function(void) > + { > + } > +=20 