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, Fortra] Add STAT_STOPPED_IMAGE to SYC ALL/SYNC IMAGES


Hello,

I'd like to submit the attached patch. This patch was just discussed in the gfortran list. It fixes a couple of TODO items in the MPI library. It is a simple patch.

libgfortran/ChangeLog

2011-07-07 Daniel Carrera <dcarrera@gmail.com>

	* mpi.c (_gfortran_caf_sync_all): Add STAT_STOPPED_IMAGE as a
	possible status value.
	(_gfortran_caf_sync_images): Ditto.


Cheers, Daniel. -- I'm not overweight, I'm undertall.
Index: libgfortran/caf/mpi.c
===================================================================
--- libgfortran/caf/mpi.c	(revision 175973)
+++ libgfortran/caf/mpi.c	(working copy)
@@ -179,35 +179,44 @@ _gfortran_caf_deregister (void **token _
 void
 _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
 {
-  /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used?  */
-  int ierr = MPI_Barrier (MPI_COMM_WORLD);
+  int ierr;
+
+  if (unlikely(caf_is_finalized))
+    ierr = STAT_STOPPED_IMAGE;
+  else
+    ierr = MPI_Barrier (MPI_COMM_WORLD);
 
   if (stat)
     *stat = ierr;
 
-  if (ierr)
+  if (ierr) 
     {
-      const char msg[] = "SYNC ALL failed";
+      char msg[30];
+      int len;
+
+      if (caf_is_finalized)
+	len = snprintf (msg, 30, "ERROR: Image %d is stopped", caf_this_image);
+      else
+	len = snprintf (msg, 30, "SYNC ALL failed");
+
       if (errmsg_len > 0)
 	{
-	  int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
-						      : (int) sizeof (msg);
+	  len = (len > errmsg_len) ? errmsg_len : len;
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
 	}
       else
 	{
-	  fprintf (stderr, "SYNC ALL failed\n");
+	  fprintf (stderr, "%s\n", msg);
 	  error_stop (ierr);
 	}
     }
 }
 
-
 /* SYNC IMAGES. Note: SYNC IMAGES(*) is passed as count == -1 while
    SYNC IMAGES([]) has count == 0. Note further that SYNC IMAGES(*)
-   is not equivalent to SYNC ALL. */
+   is not equivalent to SYNC ALL.  */
 void
 _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
 			   int errmsg_len)
@@ -243,25 +252,34 @@ _gfortran_caf_sync_images (int count, in
     }
 
   /* Handle SYNC IMAGES(*).  */
-  /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used?  */
-  ierr = MPI_Barrier (MPI_COMM_WORLD);
+  if (unlikely(caf_is_finalized))
+    ierr = STAT_STOPPED_IMAGE;
+  else
+    ierr = MPI_Barrier (MPI_COMM_WORLD);
+
   if (stat)
     *stat = ierr;
 
-  if (ierr)
+  if (ierr) 
     {
-      const char msg[] = "SYNC IMAGES failed";
+      char msg[30];
+      int len;
+
+      if (caf_is_finalized)
+	len = snprintf (msg, 30, "ERROR: Image %d is stopped", caf_this_image);
+      else
+	len = snprintf (msg, 30, "SYNC IMAGES failed");
+      
       if (errmsg_len > 0)
 	{
-	  int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
-						      : (int) sizeof (msg);
+	  len = (len > errmsg_len) ? errmsg_len : len;
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
 	}
       else
 	{
-	  fprintf (stderr, "SYNC IMAGES failed\n");
+	  fprintf (stderr, "%s\n", msg);
 	  error_stop (ierr);
 	}
     }

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