diff mbox

[Fortran-caf,committed] Fix issue with added caf_get, prep for TS18508 collectives

Message ID 535372A1.3010109@net-b.de
State New
Headers show

Commit Message

Tobias Burnus April 20, 2014, 7:09 a.m. UTC
This patch fixes an issues with allocate(..., source=) which is turned 
into an assignment - which got wrongly resolved to "CAF_GET(...) = 
source-expr". Now, the function which adds the intrinsic checks more 
carefully whether an assignment should be done.

In addition, the patch prepares for the support of CO_MIN/CO_MAX/CO_SUM 
by adding a stub implementation to the library. Expect some changes in 
the support as TS18508 is not yet finalized. I will add a version which 
does not support an extra "result" argument but the result will be 
stored in the source (either on all images or with result_image only on 
that image). The additional but optional "result" argument is in the 
current draft, but it looks like it will be dropped.

I have committed the attached patch as Rev. 209535.

In addition, I have merged the trunk into the branch as Rev. 209536.

Tobias
diff mbox

Patch

 gcc/fortran/ChangeLog.fortran-caf |    6 ++++++
 gcc/fortran/resolve.c             |   23 ++++++++++++++++-------
 libgfortran/ChangeLog.fortran-caf |    7 +++++++
 libgfortran/caf/libcaf.h          |    4 ++++
 libgfortran/caf/single.c          |   33 +++++++++++++++++++++++++++++++++
 5 files changed, 66 insertions(+), 7 deletions(-)
Index: gcc/fortran/ChangeLog.fortran-caf
===================================================================
--- gcc/fortran/ChangeLog.fortran-caf	(Revision 209348)
+++ gcc/fortran/ChangeLog.fortran-caf	(Arbeitskopie)
@@ -1,3 +1,9 @@ 
+2014-04-20  Tobias Burnus  <burnus@net-b.de>
+
+	* resolve.c (add_caf_get_intrinsic): Add check whether is is really
+	coindexed.
+	(resolve_allocate_expr): Remove remove_caf_get_intrinsic call.
+
 2014-04-13  Tobias Burnus  <burnus@net-b.de>
 
 	* trans-decl.c (gfc_trans_deferred_vars): Fix bug in
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 209348)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -4732,8 +4732,21 @@  static void
 add_caf_get_intrinsic (gfc_expr *e)
 {
   gfc_expr *wrapper, *tmp_expr;
-  gfc_expr *async = gfc_get_logical_expr (gfc_default_logical_kind, NULL,
-					  false);
+  gfc_expr *async;
+  gfc_ref *ref;
+  int n;
+
+  for (ref = e->ref; ref; ref = ref->next)
+    if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
+      break;
+  if (ref == NULL)
+    return;
+
+  for (n = ref->u.ar.dimen; n < ref->u.ar.dimen + ref->u.ar.codimen; n++)
+    if (ref->u.ar.dimen_type[n] != DIMEN_ELEMENT)
+      return;
+
+  async = gfc_get_logical_expr (gfc_default_logical_kind, NULL, false);
   tmp_expr = XCNEW (gfc_expr);
   *tmp_expr = *e;
   wrapper = gfc_build_intrinsic_call (gfc_current_ns, GFC_ISYM_CAF_GET,
@@ -5045,7 +5058,7 @@  resolve_procedure:
     expression_rank (e);
 
   if (0 && t && gfc_option.coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
-    add_caf_get_intrinsic(e);
+    add_caf_get_intrinsic (e);
 
   return t;
 }
@@ -6709,10 +6722,6 @@  resolve_allocate_expr (gfc_expr *e, gfc_code *code
   if (!gfc_resolve_expr (e))
     goto failure;
 
-  if (e->expr_type == EXPR_FUNCTION && e->value.function.isym
-      && e->value.function.isym->id == GFC_ISYM_CAF_GET)
-    remove_caf_get_intrinsic (e);
-
   /* Make sure the expression is allocatable or a pointer.  If it is
      pointer, the next-to-last reference must be a pointer.  */
 
Index: libgfortran/ChangeLog.fortran-caf
===================================================================
--- libgfortran/ChangeLog.fortran-caf	(Revision 209347)
+++ libgfortran/ChangeLog.fortran-caf	(Arbeitskopie)
@@ -1,3 +1,10 @@ 
+2014-04-20  Tobias Burnus  <burnus@net-b.de>
+
+	* caf/libcaf.h (_gfortran_caf_co_sum, _gfortran_caf_co_min,
+	_gfortran_caf_co_max): New.
+	* caf/single.c (_gfortran_caf_co_sum, _gfortran_caf_co_min,
+	_gfortran_caf_co_max): New.
+
 2014-04-10  Tobias Burnus  <burnus@net-b.de>
 
 	* caf/libcaf.h (_gfortran_caf_get_desc): New.
Index: libgfortran/caf/libcaf.h
===================================================================
--- libgfortran/caf/libcaf.h	(Revision 209347)
+++ libgfortran/caf/libcaf.h	(Arbeitskopie)
@@ -134,4 +134,8 @@  void _gfortran_caf_error_stop_str (const char *, i
      __attribute__ ((noreturn));
 void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
 
+void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
+void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
+void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int);
+
 #endif  /* LIBCAF_H  */
Index: libgfortran/caf/single.c
===================================================================
--- libgfortran/caf/single.c	(Revision 209347)
+++ libgfortran/caf/single.c	(Arbeitskopie)
@@ -345,6 +345,39 @@  _gfortran_caf_send_desc_scalar (caf_token_t token,
 
 
 void
+_gfortran_caf_co_sum (gfc_descriptor_t *source __attribute__ ((unused)),
+		      int result_image __attribute__ ((unused)),
+		      int *stat, char *errmsg __attribute__ ((unused)),
+		      int errmsg_len __attribute__ ((unused)))
+{
+  if (stat)
+    stat = 0;
+}
+
+void
+_gfortran_caf_co_min (gfc_descriptor_t *source __attribute__ ((unused)),
+		      int result_image __attribute__ ((unused)),
+		      int *stat, char *errmsg __attribute__ ((unused)),
+		      int src_len __attribute__ ((unused)),
+		      int errmsg_len __attribute__ ((unused)))
+{
+  if (stat)
+    stat = 0;
+}
+
+void
+_gfortran_caf_co_max (gfc_descriptor_t *source __attribute__ ((unused)),
+		      int result_image __attribute__ ((unused)),
+		      int *stat, char *errmsg __attribute__ ((unused)),
+		      int src_len __attribute__ ((unused)),
+		      int errmsg_len __attribute__ ((unused)))
+{
+  if (stat)
+    stat = 0;
+}
+
+
+void
 _gfortran_caf_sync_all (int *stat,
 			char *errmsg __attribute__ ((unused)),
 			int errmsg_len __attribute__ ((unused)))