public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] OpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax
Date: Mon, 4 Jul 2022 19:20:26 +0200	[thread overview]
Message-ID: <YsMhWknsLYx93etE@tucnak> (raw)
In-Reply-To: <b2e1c445-2e5c-a67c-784f-dc63d5ded043@codesourcery.com>

On Mon, Jul 04, 2022 at 06:09:31PM +0200, Tobias Burnus wrote:
> thanks for the comment & spec referral. I have now updated the patch –
> and included the new C/Fortran testcase.

Thanks.

> +		  while (true)
> +		    {
> +		      old_loc = gfc_current_locus;
> +		      if (gfc_match ("val )") == MATCH_YES)
> +			{
> +			  if (linear_op != OMP_LINEAR_DEFAULT)
> +			    {
> +			      duplicate_mod = true;
> +			      break;
> +			    }
> +			  linear_op = OMP_LINEAR_VAL;
> +			  has_modifiers = true;
> +			  break;
> +			}
> +		      else if (gfc_match ("val , ") == MATCH_YES)
> +			{
> +			  if (linear_op != OMP_LINEAR_DEFAULT)
> +			    {
> +			      duplicate_mod = true;
> +			      break;
> +			    }
> +			  linear_op = OMP_LINEAR_VAL;
> +			  has_modifiers = true;
> +			  continue;
> +			}

Perhaps you could avoid some code duplication by doing it like:
		      bool close_paren = gfc_match ("val )") == MATCH_YES;
		      if (close_paren || gfc_match ("val , ") == MATCH_YES)
			{
			  if (linear_op != OMP_LINEAR_DEFAULT)
			    {
			      duplicate_mod = true;
			      break;
			    }
			  linear_op = OMP_LINEAR_VAL;
			  has_modifiers = true;
			  if (close_paren)
			    break;
			  else
			    continue;
			}
and similarly for uval and ref.

> +		      else if (!has_modifiers
> +			       && gfc_match ("%e )", &step) == MATCH_YES)
> +			{
> +			  if ((step->expr_type == EXPR_FUNCTION
> +				|| step->expr_type == EXPR_VARIABLE)
> +			      && strcmp (step->symtree->name, "step") == 0)
> +			    {
> +			      gfc_current_locus = old_loc;
> +			      gfc_match ("step (");
> +			      has_error = true;
> +			    }

I think the above should accept even
linear (v : step (1) + 0) or linear (v : step (1, 2, 3) * 1)
which is desirable, because step then will be some other operation (hope
folding isn't performed yet).

> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/gomp/linear-4.f90
> @@ -0,0 +1,102 @@
> +! { dg-do compile }
> +! { dg-options "-fopenmp" }
> +
> +module m
> +implicit none
> +
> +integer :: i
> +
> +interface
> +  integer function bar (x,  y, z)
> +    integer :: x, y
> +    integer, value :: z
> +    !!$omp declare simd linear (x : ref, step (1)) linear (y : step (2), uval)

Are all these !! intentional?
The test then doesn't test much.

Or is that a FIXME?

	Jakub


  reply	other threads:[~2022-07-04 17:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 14:10 Tobias Burnus
2022-07-04 14:53 ` Jakub Jelinek
2022-07-04 16:09   ` Tobias Burnus
2022-07-04 17:20     ` Jakub Jelinek [this message]
2022-07-04 18:29       ` Tobias Burnus
2022-07-04 19:08         ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsMhWknsLYx93etE@tucnak \
    --to=jakub@redhat.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).