freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freepooma-devel] [PATCH, applied] Fix MPI tag overflow.


From: Richard Guenther
Subject: [Freepooma-devel] [PATCH, applied] Fix MPI tag overflow.
Date: Mon, 13 Jun 2005 10:22:27 +0200 (CEST)

This patch (which was applied to both r2 and HEAD) fixed overflow
of MPI tag values generated from TagGenerator.  While the maximum
possible value with MPICH is hard to exceed, LAM has an upper
bound of ~32000, which is easy to overflow.

Richard.


2005-06-13  Richard Guenther  <address@hidden>

        * Tulip/Messaging.h (TagGenerator): Introduce tagMax_m
        member.  Initialize from MPI_TAG_UB MPI attribute.
        Honour this maximum value to also avoid overflow to negative
        values.

Index: Messaging.h
===================================================================
RCS file: /home/rguenth/CVS/pooma-cpt/src/Tulip/Messaging.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Messaging.h 22 Feb 2005 12:32:54 -0000      1.1
+++ Messaging.h 12 Jun 2005 21:14:01 -0000      1.2
@@ -79,6 +79,7 @@
   {
     send_m[0]    = 0;
     receive_m[0] = 0;
+    tagMax_m = 32767;
   }

   TagGenerator(int n)
@@ -90,6 +91,14 @@
         send_m[i]    = 0;
         receive_m[i] = 0;
       }
+    tagMax_m = 32767;
+#if POOMA_MPI
+    int flag;
+    int *val;
+    MPI_Attr_get (MPI_COMM_WORLD, MPI_TAG_UB, (void *)&val, &flag);
+    if (flag)
+      tagMax_m = *val;
+#endif
   }

   int send(int otherContext)
@@ -97,6 +106,8 @@
     PAssert(otherContext >= 0 && otherContext < send_m.size());
     int tag = send_m[otherContext];
     send_m[otherContext]++;
+    if (send_m[otherContext] >= tagMax_m)
+      send_m[otherContext] = 0;
     return tag;
   }

@@ -105,6 +116,8 @@
     PAssert(otherContext >= 0 && otherContext < receive_m.size());
     int tag = receive_m[otherContext];
     receive_m[otherContext]++;
+    if (receive_m[otherContext] >= tagMax_m)
+      receive_m[otherContext] = 0;
     return tag;
   }

@@ -112,6 +125,7 @@

   std::vector<int> send_m;
   std::vector<int> receive_m;
+  int tagMax_m;
 };







reply via email to

[Prev in Thread] Current Thread [Next in Thread]