aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2017-02-26 13:22:43 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2017-02-26 13:22:43 +0000
commitc7b608a9f7d5785714e9d46548ee0f5f85b109be (patch)
tree9563b838df164709ffbd08a5b4dff1b70a81dc31 /gcc
parent462a7b568542e2dabd2aa6632976d47a3780deb1 (diff)
downloadgcc-c7b608a9f7d5785714e9d46548ee0f5f85b109be.zip
gcc-c7b608a9f7d5785714e9d46548ee0f5f85b109be.tar.gz
gcc-c7b608a9f7d5785714e9d46548ee0f5f85b109be.tar.bz2
re PR libfortran/51119 (MATMUL slow for large matrices)
2017-02-26 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/51119 * options.c (gfc_post_options): Set default limit for matmul inlining to 30. * invoke.texi: Document change. 2017-02-26 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/51119 * gfortran.dg/inline_matmul_1.f90: Scan optimized dump instead of original. * gfortran.dg/inline_matmul_11.f90: Likewise. * gfortran.dg/inline_matmul_9.f90: Likewise. * gfortran.dg/matmul_13.f90: New test. * gfortran.dg/matmul_14.f90: New test. From-SVN: r245745
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/invoke.texi5
-rw-r--r--gcc/fortran/options.c12
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gfortran.dg/inline_matmul_1.f904
-rw-r--r--gcc/testsuite/gfortran.dg/inline_matmul_11.f904
-rw-r--r--gcc/testsuite/gfortran.dg/inline_matmul_9.f904
-rw-r--r--gcc/testsuite/gfortran.dg/matmul_13.f9012
-rw-r--r--gcc/testsuite/gfortran.dg/matmul_14.f9012
9 files changed, 58 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 6ee1474..e3af1c5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2017-02-26 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/51119
+ * options.c (gfc_post_options): Set default limit for matmul
+ inlining to 30.
+ * invoke.texi: Document change.
+
2017-02-25 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/79601
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 2a89647..636432f 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -1629,9 +1629,8 @@ for matrices with size up to @var{n}. If the matrices involved are not
square, the size comparison is performed using the geometric mean of
the dimensions of the argument and result matrices.
-The default value for @var{n} is the value specified for
-@code{-fblas-matmul-limit} if this option is specified, or unlimitited
-otherwise.
+The default value for @var{n} is 30. The @code{-fblas-matmul-limit}
+can be used to change this value.
@item -frecursive
@opindex @code{frecursive}
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index dc8df5b..1af76aa 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -388,10 +388,16 @@ gfc_post_options (const char **pfilename)
if (!flag_automatic)
flag_max_stack_var_size = 0;
- /* If we call BLAS directly, only inline up to the BLAS limit. */
+ /* If the user did not specify an inline matmul limit, inline up to the BLAS
+ limit or up to 30 if no external BLAS is specified. */
- if (flag_external_blas && flag_inline_matmul_limit < 0)
- flag_inline_matmul_limit = flag_blas_matmul_limit;
+ if (flag_inline_matmul_limit < 0)
+ {
+ if (flag_external_blas)
+ flag_inline_matmul_limit = flag_blas_matmul_limit;
+ else
+ flag_inline_matmul_limit = 30;
+ }
/* Optimization implies front end optimization, unless the user
specified it directly. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e2850e8..30198a6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2017-02-26 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/51119
+ * gfortran.dg/inline_matmul_1.f90: Scan optimized dump instead
+ of original.
+ * gfortran.dg/inline_matmul_11.f90: Likewise.
+ * gfortran.dg/inline_matmul_9.f90: Likewise.
+ * gfortran.dg/matmul_13.f90: New test.
+ * gfortran.dg/matmul_14.f90: New test.
+
2017-02-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/79396
diff --git a/gcc/testsuite/gfortran.dg/inline_matmul_1.f90 b/gcc/testsuite/gfortran.dg/inline_matmul_1.f90
index 266aad0..c3177d7 100644
--- a/gcc/testsuite/gfortran.dg/inline_matmul_1.f90
+++ b/gcc/testsuite/gfortran.dg/inline_matmul_1.f90
@@ -1,5 +1,5 @@
! { dg-do run }
-! { dg-options "-ffrontend-optimize -fdump-tree-original -Wrealloc-lhs" }
+! { dg-options "-ffrontend-optimize -fdump-tree-optimized -Wrealloc-lhs" }
! PR 37131 - check basic functionality of inlined matmul, making
! sure that the library is not called, with and without reallocation.
@@ -149,4 +149,4 @@ program main
end program main
-! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }
diff --git a/gcc/testsuite/gfortran.dg/inline_matmul_11.f90 b/gcc/testsuite/gfortran.dg/inline_matmul_11.f90
index 783c83c..016d8d7 100644
--- a/gcc/testsuite/gfortran.dg/inline_matmul_11.f90
+++ b/gcc/testsuite/gfortran.dg/inline_matmul_11.f90
@@ -1,5 +1,5 @@
! { dg-do run }
-! { dg-additional-options "-ffrontend-optimize -fdump-tree-original" }
+! { dg-additional-options "-ffrontend-optimize -fdump-tree-optimized" }
! PR fortran/66176 - inline conjg for matml.
program main
complex, dimension(3,2) :: a
@@ -29,4 +29,4 @@ program main
c = matmul(conjg(a), b)
if (any(conjg(c) /= res2)) call abort
end program main
-! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }
diff --git a/gcc/testsuite/gfortran.dg/inline_matmul_9.f90 b/gcc/testsuite/gfortran.dg/inline_matmul_9.f90
index 67b9fca..901cd96 100644
--- a/gcc/testsuite/gfortran.dg/inline_matmul_9.f90
+++ b/gcc/testsuite/gfortran.dg/inline_matmul_9.f90
@@ -1,5 +1,5 @@
! { dg-do run }
-! { dg-options "-ffrontend-optimize -fdump-tree-original" }
+! { dg-options "-ffrontend-optimize -fdump-tree-optimized" }
! PR 66041 - this used to ICE with an incomplete fix for the PR.
program main
implicit none
@@ -21,4 +21,4 @@ program main
if (any (c2-reshape([248., -749.],shape(c2)) /= 0.)) call abort
end program main
-! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }
diff --git a/gcc/testsuite/gfortran.dg/matmul_13.f90 b/gcc/testsuite/gfortran.dg/matmul_13.f90
new file mode 100644
index 0000000..3262d1a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/matmul_13.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-O3 -fdump-tree-optimized" }
+! Check that the default limit of 30 for inlining matmul applies.
+program main
+ integer, parameter :: n = 31
+ real, dimension(n,n) :: a, b, c
+ call random_number(a)
+ call random_number(b)
+ c = matmul(a,b)
+ print *,sum(c)
+end program main
+! { dg-final { scan-tree-dump-times "_gfortran_matmul_r4" 1 "optimized" } }
diff --git a/gcc/testsuite/gfortran.dg/matmul_14.f90 b/gcc/testsuite/gfortran.dg/matmul_14.f90
new file mode 100644
index 0000000..5c2b3f2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/matmul_14.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-O3 -fdump-tree-optimized" }
+! Check that the default limit of 30 for inlining matmul applies.
+program main
+ integer, parameter :: n = 30
+ real, dimension(n,n) :: a, b, c
+ call random_number(a)
+ call random_number(b)
+ c = matmul(a,b)
+ print *,sum(c)
+end program main
+! { dg-final { scan-tree-dump-times "_gfortran_matmul_r4" 0 "optimized" } }