This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] add co_reduce to libcaf_single


Looking through the stashed patches, I realized a pending (unsubmitted) patch, showing that both a test case for CO_REDUCE was missing and that libcaf_single didn't include co_reduce.

This patch adds them.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

[Still to do for co_reduce: Checking whether any recent changes to the coarray draft requires changes to that feature. I think there were changes to co_reduce.]

Tobias

PS: For GCC 5, I really should complete the coarray support: add LOCKING as missing F2008 feature (basic support only; currently its pretending to always succeed), catch at compile time unsupported features (rather than to fail at run time with wrong results) plus adding vector support in libcaf_single.
2014-12-31  Tobias Burnus  <burnus@net-b.de>

	* caf/single.c (_gfortran_caf_co_reduce): New function.
	* caf/libcaf.h (_gfortran_caf_co_reduce): New prototype.

2014-12-31  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/coarray/collectives_4.f90: New.

Index: libgfortran/caf/libcaf.h
===================================================================
--- libgfortran/caf/libcaf.h	(Revision 219126)
+++ libgfortran/caf/libcaf.h	(Arbeitskopie)
@@ -110,6 +110,8 @@ void _gfortran_caf_co_broadcast (gfc_descriptor_t
 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);
+void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
+			      int, int, int *, char *, int, int);
 
 void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
                         caf_vector_t *, gfc_descriptor_t *, int, int, bool);
Index: libgfortran/caf/single.c
===================================================================
--- libgfortran/caf/single.c	(Revision 219126)
+++ libgfortran/caf/single.c	(Arbeitskopie)
@@ -254,6 +254,21 @@ _gfortran_caf_co_max (gfc_descriptor_t *a __attrib
 }
 
 
+void
+_gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)),
+                        void * (*opr) (void *, void *)
+                               __attribute__ ((unused)),
+                        int opr_flags __attribute__ ((unused)),
+                        int result_image __attribute__ ((unused)),
+                        int *stat, char *errmsg __attribute__ ((unused)),
+                        int a_len __attribute__ ((unused)),
+                        int errmsg_len __attribute__ ((unused)))
+ {
+   if (stat)
+     *stat = 0;
+ }
+
+
 static void
 assign_char4_from_char1 (size_t dst_size, size_t src_size, uint32_t *dst,
 			 unsigned char *src)
Index: gcc/testsuite/gfortran.dg/coarray/collectives_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray/collectives_4.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/coarray/collectives_4.f90	(Arbeitskopie)
@@ -0,0 +1,24 @@
+! { dg-do run }
+!
+! CO_REDUCE
+!
+implicit none (type, external)
+intrinsic :: co_reduce
+integer :: stat
+integer :: i4, i4_2, i
+
+i4 = 21 * this_image()
+i4_2 = 21
+do i = 2, num_images()
+  i4_2 = i4_2 * 21 * i
+end do
+call co_reduce(i4, op_i4, stat=stat)
+if (stat /= 0) call abort()
+if (i4_2 /= i4) call abort()
+
+contains
+  pure integer function op_i4(a,b)
+    integer, value :: a, b
+    op_i4 = a * b
+  end function op_i4
+end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]