[Patch, fortran] Inline DOT_PRODUCT
Paul Thomas
paulthomas2@wanadoo.fr
Mon Feb 27 00:05:00 GMT 2006
Steven,
:ADDPATCH fortran:
Please find attached a patch to implement dot_product inline. This
version includes support for logical types and a corresponding test.
All dotprod.m4's and the corresponding generated functions have been
removed.
I note that I did not remember to update the copyright dateline in
libgfortran/makefile.am - I will do so before I commit the patch.
Whilst I have regtested and all is well, the main purpose of this patch
is to speed up execution of dot_product for small arrays. To this end,
I attach a test program that is not part of the patch but produces the
results below, on a quiet Athlon1700. It may be seen that, with -O3,
the patch removes the function call overhead of ~25-30ns, which is
highly significant for arrays of sizes below approximately 32. The
error on the timing is a few ns and there is a residual overhead, which
must(?) be the dot_product loop overhead, which is about 15ns. The
performance, with the patch, is identical to that of ifort.
It will be seen that I have replaced gfc_conv_expr's with
gfc_conv_expr_val's and have not, therefore, attached the corresponding
post blocks to the block enclosed by the loop. This does not, however,
change the generated code.
OK for trunk and, whenever, 4.1?
Paul
2006-02-27 Paul Thomas <pault@gcc.gnu.org>
* iresolve.c (gfc_resolve_dot_product): Remove any difference in
treatment of logical types.
* trans-intrinsic.c (gfc_conv_intrinsic_dot_product): New function.
* libgfortran/Makefile.in: Regenerated.
* libgfortran/Makefile.am: Remove all references to dotprod.
* libgfortran/aclocal.m4: Regenerated.
* libgfortran/m4/dotprodc.m4: Removed.
* libgfortran/m4/dotprodl.m4: Removed.
* libgfortran/m4/dotprod.m4: Removed.
* libgfortran/generated/dotprod_xx.c: All types removed.
2006-02-27 Paul Thomas <pault@gcc.gnu.org>
* gfortran.dg/dot_product_logical.f90: New test.
PATCHED:
[prt@localhost dot_product]# /svn-4.2/bin/gfortran -O3
-fdump-tree-original dottest.f90;./a.out
DOT_PRODUCT test
array length time(ns)
4 21.50
8 15.70
16 56.10
32 100.20
64 191.70
128 372.50
256 735.60
512 1459.90
1024 2908.60
NOT PATCHED:
[prt@localhost dot_product]# export
LD_LIBRARY_PATH=/svn-4.1/lib:/opt/intel/fc/9.0/lib [prt@localhost
dot_product]# /svn-4.1/bin/gfortran -O3 -fdump-tree-original
dottest.f90;./a.out
DOT_PRODUCT test
array length time(ns)
4 44.60
8 39.90
16 80.70
32 126.30
64 216.90
128 398.50
256 760.50
512 1489.60
1024 2936.40
[prt@localhost dot_product]# ifort dottest.f90;./a.out DOT_PRODUCT test
array length time(ns)
4 20.90
8 18.90
16 52.70
32 98.90
64 189.50
128 370.90
256 732.70
512 1458.40
1024 2986.90
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: total.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060227/f9be5cd1/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: logical_dot_product.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060227/f9be5cd1/attachment.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dottest.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060227/f9be5cd1/attachment-0001.f90>
More information about the Gcc-patches
mailing list