Compilation of enumerated DATA statements is extremely slow. Related PR: * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13465 Related threads on ML: * http://gcc.gnu.org/ml/fortran/2004-08/msg00131.html * http://gcc.gnu.org/ml/fortran/2006-09/msg00025.html Shell script to generate example data: $> cat datagen.sh #! /bin/bash outfile=data.f90 dim1=50 dim2=1000 echo "MODULE appdata" > ${outfile} echo "INTEGER :: thedata(${dim1}, ${dim2})" >> ${outfile} for i in `seq 1 ${dim1}` ; do for j in `seq 1 ${dim2}` ; do echo "DATA thedata(${i}, ${j}) / $((i*j)) /" >> ${outfile} done done echo "END MODULE" >> ${outfile} P4 3.2 GHz, 2GB RAM: $> bash datagen.sh $> time gfortran-4.2 -c data.f90 real 3m31.646s user 3m29.545s sys 0m0.172s
Quadratic (or worse?) behavior
This problem is very intriguing. For a first attempt I plan on adding a splay tree to constructors that need 'by element' access. This may allow this problem to be taken care of without changing every routine that uses gfc_constructor. bd
more mailing list traffic on this topic: http://gcc.gnu.org/ml/fortran/2006-09/msg00210.html --bud
before the patch: $ time /usr/local/bin/gfortran -c data.f90 real 3m1.263s user 3m0.519s sys 0m0.120s after: $ time /usr/local/bin/gfortran -c data.f90 real 0m3.215s user 0m3.052s sys 0m0.092s
patch here: http://gcc.gnu.org/ml/fortran/2006-11/msg00148.html
Subject: Bug 28974 Author: bdavis Date: Wed Nov 15 05:10:22 2006 New Revision: 118844 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118844 Log: 2006-11-15 Bud Davis <bdavis9659@sbcglobal.net> PR fortran/28974 * gfortran.h (gfc_expr): Add element which holds a splay-tree for the exclusive purpose of quick access to a constructor by offset. * data.c (find_con_by_offset): Use the splay tree for the search. (gfc_assign_data_value): Use the splay tree. (gfc_assign_data_value_range): ditto. * expr.c (gfc_get_expr): Initialize new element to null. (gfc_free_expr): Delete splay tree when deleting gfc_expr. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/data.c trunk/gcc/fortran/expr.c trunk/gcc/fortran/gfortran.h
Fixed.
Are there any plans to backport this fix to the gcc 4.2 branch since it does fix a pretty nasty performace hit?