public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix up matmul in !$omp workshare (PR fortran/70855)
@ 2016-05-11 13:22 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2016-05-11 13:22 UTC (permalink / raw)
  To: gcc-patches, fortran

Hi!

The parsing of !$omp workshare requires only small precise set of statements
that can appear inside, which the inlining of matmul assign breaks.

Fixed by disabling the inlining in !$omp workshare regions.

Long term, it would be nice to inline those in !$omp workshare again and
actually parallelize, but I guess in that case it should not be done during
frontend passes, but during workshare translation into generic - and would
need to arrange for proper worksharing of both of the actions (clearing of
the target array as well as actually computing it).

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 6.2.

2016-05-11  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/70855
	* frontend-passes.c (inline_matmul_assign): Disable in !$omp workshare.

	* gfortran.dg/gomp/pr70855.f90: New test.

--- gcc/fortran/frontend-passes.c.jj	2016-02-29 19:33:09.000000000 +0100
+++ gcc/fortran/frontend-passes.c	2016-05-11 11:54:43.747298277 +0200
@@ -2812,6 +2812,12 @@ inline_matmul_assign (gfc_code **c, int
   if (in_where)
     return 0;
 
+  /* For now don't do anything in OpenMP workshare, it confuses
+     its translation, which expects only the allowed statements in there.
+     We should figure out how to parallelize this eventually.  */
+  if (in_omp_workshare)
+    return 0;
+
   expr1 = co->expr1;
   expr2 = co->expr2;
   if (expr2->expr_type != EXPR_FUNCTION
--- gcc/testsuite/gfortran.dg/gomp/pr70855.f90.jj	2016-05-11 12:03:37.627977013 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr70855.f90	2016-05-11 12:04:06.927575148 +0200
@@ -0,0 +1,18 @@
+! PR fortran/70855
+! { dg-do compile }
+! { dg-additional-options "-O2" }
+
+program pr70855
+   integer, parameter :: m = 4
+   integer, parameter :: n = 2
+   real :: a(m,n)
+   real :: x(n)
+   real :: y(m)
+   a = 1.0
+   x = 1.0
+!$omp parallel
+!$omp workshare
+   y(1:m) = matmul ( a(1:m,1:n), x(1:n) )
+!$omp end workshare
+!$omp end parallel
+end program pr70855

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-05-11 13:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 13:22 [committed] Fix up matmul in !$omp workshare (PR fortran/70855) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).