From: Tobias Burnus <burnus@net-b.de>
To: gcc-patches <gcc-patches@gcc.gnu.org>, gfortran <fortran@gcc.gnu.org>
Cc: Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
Subject: Re: [Fortran, Patch] Memory sync after coarray image control statements and assignment
Date: Mon, 14 Dec 2015 19:14:00 -0000 [thread overview]
Message-ID: <566F14FE.2080006@net-b.de> (raw)
In-Reply-To: <CAHqFgjVhx6pcVFEaCT8=9P+vkR=SP-mohZwr+B315N0_41OtKA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
Alessandro Fanfarillo wrote:
> In attachment the patch for gcc5-branch.
Commited as Rev. 231626.
Tobias
> 2015-12-10 10:03 GMT+01:00 Tobias Burnus <tobias.burnus@physik.fu-berlin.de>:
>> Hi Alessandro (off list),
>>
>> On Thu, Dec 10, 2015 at 09:44:16AM +0100, Alessandro Fanfarillo wrote:
>>> Yes, the patch should be applied to GCC 5 too.
>> Can you create a patch? Requires a rediff plus removing the bits which
>> do not exist on GCC 5 - like events.
[-- Attachment #2: commit.diff --]
[-- Type: text/x-patch, Size: 8536 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 231625)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,19 @@
+2015-12-09 Tobias Burnus <burnus@net-b.de>
+ Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
+
+ Backport from mainline.
+ 2015-12-09 Tobias Burnus <burnus@net-b.de>
+ Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
+
+ * trans.c (gfc_allocate_using_lib,gfc_deallocate_with_status):
+ Introducing __asm__ __volatile__ ("":::"memory")
+ after image control statements.
+ * trans-stmt.c (gfc_trans_sync, gfc_trans_event_post_wait,
+ gfc_trans_lock_unlock, gfc_trans_critical): Ditto.
+ * trans-intrinsic.c (gfc_conv_intrinsic_caf_get,
+ conv_caf_send): Introducing __asm__ __volatile__ ("":::"memory")
+ after send, before get and around sendget.
+
2015-12-04 Release Manager
* GCC 5.3.0 released.
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (Revision 231625)
+++ gcc/fortran/trans-intrinsic.c (Arbeitskopie)
@@ -1221,12 +1221,22 @@
/* No overlap possible as we have generated a temporary. */
if (lhs == NULL_TREE)
may_require_tmp = boolean_false_node;
+
+ /* 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);
tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_get, 9,
token, offset, image_index, argse.expr, vec,
dst_var, kind, lhs_kind, may_require_tmp);
gfc_add_expr_to_block (&se->pre, tmp);
-
+
if (se->ss)
gfc_advance_se_ss_chain (se);
@@ -1386,6 +1396,16 @@
{
tree rhs_token, rhs_offset, rhs_image_index;
+ /* 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);
+
caf_decl = gfc_get_tree_for_caf_expr (rhs_expr);
if (TREE_CODE (TREE_TYPE (caf_decl)) == REFERENCE_TYPE)
caf_decl = build_fold_indirect_ref_loc (input_location, caf_decl);
@@ -1401,6 +1421,17 @@
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &lhs_se.post);
gfc_add_block_to_block (&block, &rhs_se.post);
+
+ /* 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);
}
Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c (Revision 231625)
+++ gcc/fortran/trans-stmt.c (Arbeitskopie)
@@ -829,6 +829,17 @@
errmsg, errmsg_len);
gfc_add_expr_to_block (&se.pre, 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 (&se.pre, tmp);
+
if (stat2 != NULL_TREE)
gfc_add_modify (&se.pre, stat2,
fold_convert (TREE_TYPE (stat2), stat));
@@ -931,6 +942,20 @@
fold_convert (integer_type_node, images));
}
+ /* Per F2008, 8.5.1, a SYNC MEMORY is implied by calling the
+ image control statements SYNC IMAGES and SYNC ALL. */
+ if (flag_coarray == GFC_FCOARRAY_LIB)
+ {
+ 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);
+ }
+
if (flag_coarray != GFC_FCOARRAY_LIB)
{
/* Set STAT to zero. */
@@ -1250,6 +1275,17 @@
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);
@@ -1262,9 +1298,19 @@
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);
}
Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (Revision 231625)
+++ gcc/fortran/trans.c (Arbeitskopie)
@@ -739,6 +739,16 @@
TREE_TYPE (pointer), pointer,
fold_convert ( TREE_TYPE (pointer), tmp));
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);
}
@@ -1360,6 +1370,16 @@
token, pstat, errmsg, errlen);
gfc_add_expr_to_block (&non_null, 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 (&non_null, tmp);
+
if (status != NULL_TREE)
{
tree stat = build_fold_indirect_ref_loc (input_location, status);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 231625)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,12 @@
+2015-12-09 Tobias Burnus <burnus@net-b.de>
+ Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
+
+ Backport from mainline.
+ 2015-12-09 Tobias Burnus <burnus@net-b.de>
+ Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
+
+ * gfortran.dg/coarray_40.f90: New.
+
2015-12-14 Martin Jambor <mjambor@suse.cz>
PR ipa/66616
Index: gcc/testsuite/gfortran.dg/coarray_40.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_40.f90 (nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_40.f90 (Arbeitskopie)
@@ -0,0 +1,25 @@
+! { dg-do run }
+! { dg-options "-fcoarray=lib -lcaf_single" }
+!
+! Run-time test for memory consistency
+!
+! Contributed by Deepak Eachempati
+
+program cp_bug
+ implicit none
+ integer :: v1, v2, u[*]
+ integer :: me
+
+ me = this_image()
+
+ u = 0
+ v1 = 10
+
+ v1 = u[me]
+
+ ! v2 should get value in u (0)
+ v2 = v1
+
+ if(v2 /= u) call abort()
+
+end program
prev parent reply other threads:[~2015-12-14 19:14 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
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 [this message]
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=566F14FE.2080006@net-b.de \
--to=burnus@net-b.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--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).