public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>,
	Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
Cc: gfortran <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	opencoarrays@googlegroups.com
Subject: Re: [Fortran, Patch] Memory sync after coarray image control statements and assignment
Date: Wed, 09 Dec 2015 07:23:00 -0000	[thread overview]
Message-ID: <5667D6D9.9000906@net-b.de> (raw)
In-Reply-To: <CAHqFgjWbU3rvs4ZhD=mHuFzsvAQmxr+v7qJDzBc=mUkp=Qj1pw@mail.gmail.com>

Alessandro Fanfarillo wrote:
> in attachment the new patch. I also checked the behavior with
> move_alloc: it synchronizes right after the deregistration of the
> destination.
> I also noticed that __asm__ __volatile__ ("":::"memory") is called
> before sync all and not after. It shouldn't be a problem, right?

The patch looks mostly good to me, except:

> @@ -1222,6 +1230,15 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind,
>     se->expr = res_var;
>     if (array_expr->ts.type == BT_CHARACTER)
>       se->string_length = argse.string_length;
> +
> +  /* It guarantees memory consistency within the same segment */
> +  /* tmp = gfc_build_string_const (strlen ("memory")+1, "memory"), */
> +  /* tmp = build5_loc (input_location, ASM_EXPR, void_type_node, */
> +  /* 		    gfc_build_string_const (1, ""), NULL_TREE, NULL_TREE, */
> +  /* 		    tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE); */
> +  /* ASM_VOLATILE_P (tmp) = 1; */
> +  /* gfc_add_expr_to_block (&se->pre, tmp); */
> +
>   }

Do not add out-commented code. Please remove.


>  gfc_trans_critical (gfc_code *code)
>  {
>    stmtblock_t block;
>    tree tmp, token = NULL_TREE;
>
>    gfc_start_block (&block);
>
>    if (flag_coarray == GFC_FCOARRAY_LIB)
>      {
>        token = gfc_get_symbol_decl (code->resolved_sym);
>        token = GFC_TYPE_ARRAY_CAF_TOKEN (TREE_TYPE (token));
>        tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7,
>                                  token, integer_zero_node, 
> integer_one_node,
>                                  null_pointer_node, null_pointer_node,
>                                  null_pointer_node, integer_zero_node);
>        gfc_add_expr_to_block (&block, tmp);
>      }
>
> +  /* It guarantees memory consistency within the same segment */
> +  tmp = gfc_build_string_const (strlen ("memory")+1, "memory"),
> +    tmp = build5_loc (input_location, ASM_EXPR, void_type_node,
> +                     gfc_build_string_const (1, ""), NULL_TREE, 
> NULL_TREE,
> +                     tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE);
> +  ASM_VOLATILE_P (tmp) = 1;
> +
> +  gfc_add_expr_to_block (&block, tmp);
> +
>    tmp = gfc_trans_code (code->block->next);
>    gfc_add_expr_to_block (&block, tmp);
>
>    if (flag_coarray == GFC_FCOARRAY_LIB)
>      {
>        tmp = build_call_expr_loc (input_location, 
> gfor_fndecl_caf_unlock, 6,
>                                  token, integer_zero_node, 
> integer_one_node,
>                                  null_pointer_node, null_pointer_node,
>                                  integer_zero_node);
>        gfc_add_expr_to_block (&block, tmp);
>      }
>
> +      /* It guarantees memory consistency within the same segment */
> +      tmp = gfc_build_string_const (strlen ("memory")+1, "memory"),
> +      tmp = build5_loc (input_location, ASM_EXPR, void_type_node,
> +                       gfc_build_string_const (1, ""), NULL_TREE, 
> NULL_TREE,
> +                       tree_cons (NULL_TREE, tmp, NULL_TREE), NULL_TREE);
> +      ASM_VOLATILE_P (tmp) = 1;
> +
> +      gfc_add_expr_to_block (&block, tmp);
>
>    return gfc_finish_block (&block);
>  }

Please move the two new code additions into the associated "if 
(flag_coarray == GFC_FCOARRAY_LIB)" blocks - and keep an eye on the 
indentation: for the current code location, the second block is wrongly 
idented.


With the two issues fixed: LGTM.

Cheers,

Tobias

PS: I assume you can still commit yourself. I am asking because Steve 
did commit the recent EVENT patch for you.

  reply	other threads:[~2015-12-09  7:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 21:02 Alessandro Fanfarillo
2015-12-07  7:20 ` Tobias Burnus
2015-12-07  9:16   ` Alessandro Fanfarillo
2015-12-07 10:06   ` Tobias Burnus
2015-12-07 14:09     ` Matthew Wahab
2015-12-08  9:26       ` Tobias Burnus
2015-12-09 14:47         ` Matthew Wahab
2015-12-07 14:48     ` Alessandro Fanfarillo
2015-12-08 10:01       ` Tobias Burnus
2015-12-08 14:21         ` Alessandro Fanfarillo
2015-12-09  7:23           ` Tobias Burnus [this message]
2015-12-09 16:08             ` Alessandro Fanfarillo
2015-12-09 22:16               ` Tobias Burnus
2015-12-10  8:44                 ` Alessandro Fanfarillo
     [not found]                   ` <20151210090345.GB6991@physik.fu-berlin.de>
     [not found]                     ` <CAHqFgjVhx6pcVFEaCT8=9P+vkR=SP-mohZwr+B315N0_41OtKA@mail.gmail.com>
2015-12-14 19:14                       ` Tobias Burnus

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=5667D6D9.9000906@net-b.de \
    --to=burnus@net-b.de \
    --cc=fanfarillo.gcc@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=opencoarrays@googlegroups.com \
    --cc=tobias.burnus@physik.fu-berlin.de \
    /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).