------- Comment #7 from bangerth at dealii dot org 2006-12-14 15:16 ------- I've reduced the code a bit by stripping all C++isms and collapsing everything into a single function: ----------------------------------- double data[9];
int main() { for( int factor = 0; factor < 1000000000; factor++ ) { #ifdef UNROLL data[ 0 + 3 * 0 ] = factor; data[ 1 + 3 * 0 ] = 0; data[ 2 + 3 * 0 ] = 0; data[ 0 + 3 * 1 ] = 0; data[ 1 + 3 * 1 ] = factor; data[ 2 + 3 * 1 ] = 0; data[ 0 + 3 * 2 ] = 0; data[ 1 + 3 * 2 ] = 0; data[ 2 + 3 * 2 ] = factor; #else for( int i = 0; i < 3; i++ ) for( int j = 0; j < 3; j++ ) data[i + 3 * j] = (i == j) * factor; #endif } } ----------------------------- For this, we get these results: g/x> gcc x.c -O3 -funroll-loops -std=c99 g/x> time ./a.out real 0m9.380s user 0m9.381s sys 0m0.000s g/x> gcc x.c -O3 -funroll-loops -std=c99 -DUNROLL g/x> time ./a.out real 0m0.420s user 0m0.420s sys 0m0.000s W. -- bangerth at dealii dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30201