Code optimization - temporaries in the scalarizer

Paul Thomas paulthomas2@wanadoo.fr
Wed Oct 19 08:20:00 GMT 2005


>
>My conclusion of all this is that there is some room for some optimization
>of the scalarizer (by having gfc_conv_resolve_dependencies recognise that
>this is an element by element replacement?). 
>
This is indeed the case.  The enclosed "draft patch" determines that 
array references are equal, even when the expressions are of type 
EXPR_VARIABLE.

   temp = b(:,k)
   DO j = 1, n
      c = b(k,j)*d
      b(:,j) = b(:,j)-temp*c   ! b is automatic
      b(k,j) = c
   END DO

Thus, the marked line is detected as GFC_DEP_EQUAL, even though the 
array is automatic, and temporaries are duly dispensed with.

[prt@localhost f90]# /gcc-clean/bin/gfortran  -O2 -march=athlon 
-fmax-stack-var-size=1000000 TEST_FPU.f90

Test1 - Gauss 2000 (101x101) inverts 10.7 sec  Err= 0.000000000000003
Test2 - Crout 2000 (101x101) inverts 10.2 sec  Err= 0.000000000000001
Test3 - Crout  2 (1001x1001) inverts 38.0 sec  Err= 0.000000000000001
Test4 - Lapack 2 (1001x1001) inverts 35.5 sec  Err= 0.000000000000273
                             total = 94.4 sec

[prt@localhost f90]# ifc  -O3  TEST_FPU.f90
4447 Lines Compiled

  Benchmark running, hopefully as only ACTIVE task
Test1 - Gauss 2000 (101x101) inverts  7.8 sec  Err= 0.000000000000002
Test2 - Crout 2000 (101x101) inverts  8.9 sec  Err= 0.000000000000001
Test3 - Crout  2 (1001x1001) inverts 30.4 sec  Err= 0.000000000000001
Test4 - Lapack 2 (1001x1001) inverts 32.5 sec  Err= 0.000000000000306
                             total = 79.6 sec

I have not checked yet why tests 3-4 are factors of 3-4 slower, for both 
compilers, on Athlon/FC3, when compared with the Pentium/NT results of 
yesterday.  However, this is so encouraging that I am going to consider 
other cases (eg. simple expressions) that are amenable to dependency 
resolution before submitting a patch.

Paul T


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dependency.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20051019/4d5b0db3/attachment.ksh>


More information about the Fortran mailing list