Fixed several subtle bugs in the converse runtime for convex
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Sat, 23 Nov 1996 02:25:33 +0000 (02:25 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Sat, 23 Nov 1996 02:25:33 +0000 (02:25 +0000)
exemplar.

31 files changed:
src/arch/cm5/conv-mach.h
src/arch/exemplar/conv-mach.csh
src/arch/exemplar/conv-mach.h
src/arch/exemplar/machine.c
src/arch/ncube2/conv-mach.h
src/arch/net-aix-ppc/conv-mach.h
src/arch/net-hp-cc/conv-mach.h
src/arch/net-hp/conv-mach.h
src/arch/net-sol-cc/conv-mach.h
src/arch/net-sol/conv-mach.h
src/arch/net-sun/conv-mach.h
src/arch/paragon-osf/conv-mach.h
src/arch/paragon-sunmos/conv-mach.h
src/arch/sim-hp/conv-mach.h
src/arch/sim-rs6k/conv-mach.h
src/arch/sim-sol/conv-mach.h
src/arch/sim-sun/conv-mach.h
src/arch/sp1/conv-mach.h
src/arch/t3d/conv-mach.h
src/arch/tcp-hp/conv-mach.h
src/arch/tcp-sol/conv-mach.h
src/arch/uth-hp-cc/conv-mach.h
src/arch/uth-hp/conv-mach.h
src/arch/uth-rs6k/conv-mach.h
src/arch/uth-sol-cc/conv-mach.h
src/arch/uth-sol/conv-mach.h
src/arch/uth-sun/conv-mach.h
src/charmc
src/conv-core/converse.h
src/conv-core/cpm.c
src/conv-core/threads.c

index 94e79e61ade49bb2811cdb1b3b8367c943dfecd6..6f595417f9d91f70ddac04804b480e7f20eb1062 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.23  1996-11-08 22:22:54  brunner
+ * Revision 2.24  1996-11-23 02:25:35  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.23  1996/11/08 22:22:54  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
+
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index 7ec1c4141f0e73fece6065c724c33dc7b31988f8..63a0e1092a9ee0a3c856a1c450e17d285b709303 100755 (executable)
 ############################################################################
 
 set CMK_CPP_CHARM='/lib/cpp -P'
-set CMK_CPP_C='echo "Please set CMK_CPP_C" ; exit 1 ; echo '
+set CMK_CPP_C='cc -E '
 set CMK_CXXPP='echo "Convex doesnt support charm++" ; exit 1 ; echo '
 set CMK_LDRO='ld -r -o'
 set CMK_LDRO_WORKS=1
-set CMK_CC='cc'
+set CMK_CC='cc -or none'
 set CMK_CC_RELIABLE='cc'
 set CMK_CC_FASTEST='cc'
 set CMK_CXX='echo "Convex doesnt support charm++" ; exit 1 ; echo '
 set CMK_CF77=''
 set CMK_C_DEBUG='-no -cxdb'
-set CMK_C_OPTIMIZE='-O'
+set CMK_C_OPTIMIZE='-O2'
 set CMK_CXX_DEBUG=''
 set CMK_CXX_OPTIMIZE=''
 set CMK_LD='cc -Wl,+parallel'
index f7df0765b72da39ba5864e65064f329e4793978b..18f6082bd2739af537bbd709402329ec94b7f79a 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.22  1996-11-08 22:22:54  brunner
+ * Revision 2.23  1996-11-23 02:25:36  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.22  1996/11/08 22:22:54  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_STRINGS_USE_STRING_H                           1
 
 #define CMK_THREADS_UNAVAILABLE                            0
-#define CMK_THREADS_USE_ALLOCA                             1
+#define CMK_THREADS_USE_ALLOCA                             0
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               1
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
-#define CMK_TIMER_USE_SPECIAL                              1
-#define CMK_TIMER_USE_TIMES                                0
+#define CMK_TIMER_USE_SPECIAL                              0
+#define CMK_TIMER_USE_TIMES                                1
 
 #define CMK_VECTOR_SEND_USES_COMMON_CODE                        1
 #define CMK_VECTOR_SEND_USES_SPECIAL_CODE                        0
index ea06c5fc6557b405a6f62df24b215ec6eb646b83..d4668914303bb202502072b6c393b1e3fabbaff5 100644 (file)
  * REVISION HISTORY:
  *
  * $Log$
- * Revision 2.20  1996-07-15 20:59:22  jyelon
+ * Revision 2.21  1996-11-23 02:25:36  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.20  1996/07/15 20:59:22  jyelon
  * Moved much timer, signal, etc code into common.
  *
  * Revision 2.19  1995/11/09 22:00:55  gursoy
@@ -81,6 +85,7 @@ static char ident[] = "@(#)$Header$";
 #include <spp_prog_model.h>
 #include <memory.h>
 #include <cps.h>
+#include <math.h>
 #include "converse.h"
 
 
@@ -107,10 +112,10 @@ CpvDeclare(void*, CmiLocalQueue);
 CpvDeclare(int, Cmi_mype);
 CpvDeclare(int, Cmi_numpes);
 
-static barrier_t barrier;
-static barrier_t *barr;
-static int *nthreads;
-static int requested_npe;
+static node_private barrier_t barrier;
+static node_private barrier_t *barr;
+static node_private int *nthreads;
+static node_private int requested_npe;
 
 static void mycpy();
 static void threadInit();
@@ -118,40 +123,43 @@ static void threadInit();
 void *CmiAlloc(size)
 int size;
 {
-char *res;
-res =(char *) memory_class_malloc(size+8,THREAD_PRIVATE_MEM);
-if (res==0) printf("Memory allocation failed.");
-((int *)res)[0]=size;
-return (void *)(res+8);
+  char *res;
+  res =(char *) memory_class_malloc(size+8,THREAD_PRIVATE_MEM);
+  if (res==(char *)0) { memory_class_malloc(size+8,NODE_PRIVATE_MEM); }
+  if (res==(char *)0) { memory_class_malloc(size+8,NEAR_SHARED_MEM); }
+  if (res==(char *)0) { memory_class_malloc(size+8,FAR_SHARED_MEM); }
+  if (res==(char *)0) { CmiError("%d:Memory allocation failed.",CmiMyPe()); exit(1); }
+  ((int *)res)[0]=size;
+  return (void *)(res+8);
 }
 
 int CmiSize(blk)
 void *blk;
 {
-return ((int *)( ((char *) blk) - 8))[0];
+  return ((int *)( ((char *) blk) - 8))[0];
 }
 
 void CmiFree(blk)
 void *blk;
 {
-free( ((char *)blk) - 8);
+  free( ((char *)blk) - 8);
 }
 
 
 void *CmiSvAlloc(size)
 int size;
 {
-char *res;
-res =(char *)memory_class_malloc(size+8,NODE_PRIVATE_MEM);
-if (res==0) printf("Memory allocation failed.");
-((int *)res)[0]=size;
-return (void *)(res+8);
+  char *res;
+  res =(char *)memory_class_malloc(size+8,NEAR_SHARED_MEM);
+  if (res==0) CmiError("Memory allocation failed.");
+  ((int *)res)[0]=size;
+  return (void *)(res+8);
 }
 
 void CmiSvFree(blk)
 char *blk;
 {
-free(blk-8);
+  free(blk-8);
 }
 
 
@@ -201,7 +209,7 @@ char *argv[];
 
     if (requested_npe <= 0)
     {
-       printf("Error: requested number of processors is invalid %d\n",requested_npe);
+       CmiError("Error: requested number of processors is invalid %d\n",requested_npe);
        exit();
     }
 
@@ -221,9 +229,16 @@ char *argv[];
     cps_barrier_alloc(barr);
 
     MsgQueue=(McQueue **)g_malloc(requested_npe*sizeof(McQueue *));
+    if (MsgQueue == (McQueue **)0) {
+       CmiError("Cannot Allocate Memory...\n");
+       exit(1);
+    }
     for(i=0; i<requested_npe; i++) MsgQueue[i] = McQueueCreate();
 
-    cps_ppcall(&request, threadInit ,arg); 
+    if (cps_ppcall(&request, threadInit ,arg) != requested_npe) {
+       CmiError("Cannot created threads...\n");
+       exit(1);
+    } 
     cps_barrier_free(barr);
 
 }
@@ -283,14 +298,14 @@ char *msg;
         char *buf;
 
         buf=(void *)g_malloc(size+8);
-        ((int *)buf)[0]=size;
-        buf += 8;
-
         if(buf==(void *)0)
         {
-                printf("Cannot allocate memory!\n");
+                CmiError("Cannot allocate memory!\n");
                 exit(1);
         }
+        ((int *)buf)[0]=size;
+        buf += 8;
+
 
         mycpy((double *)buf,(double *)msg,size);
         McQueueAddToBack(MsgQueue[destPE],buf); 
@@ -312,7 +327,7 @@ int destPE;
 int size;
 char  *msg;
 {
-    McQueueAddToBack(MsgQueue[destPE],msg);
+        McQueueAddToBack(MsgQueue[destPE],msg); 
 }
 
 void CmiSyncBroadcastFn(size, msg)
@@ -344,23 +359,8 @@ void CmiSyncBroadcastAllFn(size, msg)
 int  size;
 char *msg;
 {
-    void *env;
-    void *buf;
-
     int i;
-    for(i=0; i<CmiNumPes(); i++)
-       if (CmiMyPe() != i) CmiSyncSendFn(i,size,msg);
-
-    buf=(void *)CmiAlloc(size);
-
-    if(buf==(void *)0)
-        {
-                printf("Cannot allocate memory!\n");
-                exit(1);
-        }
-
-    mycpy((double *)buf,(double *)msg,size);
-    FIFO_EnQueue(CpvAccess(CmiLocalQueue),buf);
+    for(i=0; i<CmiNumPes(); i++) CmiSyncSendFn(i,size,msg);
 }
 
 
@@ -419,48 +419,6 @@ static void mycpy(double *dst, double *src, int bytes)
         }
 }
 
-
-
-
-
-/* ********************************************************************** */
-/* For backward compatibility some of the previous functionality retained */
-/* ********************************************************************** */
-
-McTimerInit()
-{
-}
-
-unsigned int McTimer()
-{
-}
-
-int McHostPeNum()
-{
-}
-
-int McMainPeNum()
-{
-        return 0;
-}
-
-McUTimerInit()
-{
-return 0;
-}
-
-unsigned int McUTimer()
-{
-return 0;
-}
-
-McHTimer()
-{
-return 0;
-}
-
-
-
 /* ********************************************************************** */
 /* The following functions are required by the load balance modules       */
 /* ********************************************************************** */
@@ -505,8 +463,9 @@ int p;
 {
     int a,b,n;
 
-    a = (int) floor(sqrt((double)CmiNumPes()));
-    b = (int) ceil( ((double)CmiNumPes() / (double)a) );
+    n = CmiNumPes();
+    a = (int)sqrt((double)n);
+    b = (int) ceil( ((double)n / (double)a) );
 
    
     _MC_numofneighbour = 0;
@@ -584,7 +543,7 @@ unsigned int len;
        blk=(void **)g_malloc(len*sizeof(void *));
        if(blk==(void **)0)
        {
-               printf("Cannot Allocate Memory!\n");
+               CmiError("Cannot Allocate Memory!\n");
                exit(1);
        }
        return blk;
@@ -608,7 +567,7 @@ McQueueCreate()
        queue = (McQueue *) g_malloc(sizeof(McQueue));
        if(queue==(McQueue *)0)
        {
-               printf("Cannot Allocate Memory!\n");
+               CmiError("Cannot Allocate Memory!\n");
                exit(1);
        }
        m_init32(&(queue->sema), &one);
index 67e1e531543addf6865d122ee7ead712c701af84..c9e56e127245b91dd6eb11f2058d27678d9700f0 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.22  1996-11-08 22:22:57  brunner
+ * Revision 2.23  1996-11-23 02:25:37  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.22  1996/11/08 22:22:57  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index ebc5274368a90c6474ea1ef1890c5621000bc33e..58699323c6419daa25b102a25043b6b3e006d6c9 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.23  1996-11-08 22:22:58  brunner
+ * Revision 1.24  1996-11-23 02:25:38  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.23  1996/11/08 22:22:58  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 07643f1d59fc68d0c48bd81c804e715d31d19fee..b65db05b6fd712bd18f7057548a95e159fbfabba 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.10  1996-11-08 22:22:58  brunner
+ * Revision 1.11  1996-11-23 02:25:38  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.10  1996/11/08 22:22:58  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 9b03d14d18f217625e94a788d004d19dc03e4285..64d6ef43c6b97643a323af3f8daba7f4fd683978 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.27  1996-11-08 22:22:57  brunner
+ * Revision 2.28  1996-11-23 02:25:37  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.27  1996/11/08 22:22:57  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 99c28bff60274f74c9e16c36413d15c47bd438d2..d92de23f19a15677e7cce63510665203e7adbd06 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.3  1996-11-08 22:23:00  brunner
+ * Revision 1.4  1996-11-23 02:25:39  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.3  1996/11/08 22:23:00  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 2759ff58db267c93073fffc7d41f7724cb867b36..611b3628b53be8f420aaabe757a5f80664a8f537 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.26  1996-11-08 22:22:59  brunner
+ * Revision 2.27  1996-11-23 02:25:39  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.26  1996/11/08 22:22:59  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 8af27a1104f3937a49d5dd6b9ea56dff0af4a202..ed0079ba81725ee0dc19c72f487ce18d9bb9f044 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.25  1996-11-08 22:23:00  brunner
+ * Revision 2.26  1996-11-23 02:25:40  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.25  1996/11/08 22:23:00  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            1
 #define CMK_TIMER_USE_SPECIAL                              0
index 9b92c21bd3b5d78a20c36c96f12bc02a7d5c015d..b6ae8263a39f06bce659581d68021a5709301552 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.9  1996-11-08 22:23:01  brunner
+ * Revision 1.10  1996-11-23 02:25:40  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.9  1996/11/08 22:23:01  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index 2d17a2c8d1a2b858b13dbc347f1f4e05eb0fa18c..5a1f21b4c3bac709eb24f994d87d400ba350f63b 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.9  1996-11-08 22:23:01  brunner
+ * Revision 1.10  1996-11-23 02:25:40  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.9  1996/11/08 22:23:01  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index 806db943d64db6fab08ecd568dcca92bed0a3ea7..3a01ca761bcbc460351c2d514ceb4b7b49812158 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.14  1996-11-08 22:23:02  brunner
+ * Revision 1.15  1996-11-23 02:25:41  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.14  1996/11/08 22:23:02  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 87db19635a7b667ee2d9ea13a82dbbcf7b2fad60..df21023b8ddbdee87ef19711f768a3a6a7c998e1 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.13  1996-11-08 22:23:04  brunner
+ * Revision 1.14  1996-11-23 02:25:41  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.13  1996/11/08 22:23:04  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index bc16451f91171b4d36b5d3b5b732b75208ca3bee..406f83f475f1d3f034fc45284e1f4e0462637dfc 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.12  1996-11-08 22:23:07  brunner
+ * Revision 1.13  1996-11-23 02:25:42  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.12  1996/11/08 22:23:07  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index e183f5b1fd10010cba5ca889ec9079491cb12266..15076d9cb3f3135ecbcad42cb595c2c6aea4f4ca 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.12  1996-11-08 22:23:07  brunner
+ * Revision 1.13  1996-11-23 02:25:42  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.12  1996/11/08 22:23:07  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 0440f750fcf7a6cbaaba00d597637f8a858d66c8..7747c707d7b2ddaba4e3ab62e8d199617d9ea39e 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.21  1996-11-08 22:23:07  brunner
+ * Revision 2.22  1996-11-23 02:25:43  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.21  1996/11/08 22:23:07  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 1
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index 4e95bd1cef674a6b4945a2cec1d1c6540bac8606..01686aaab8f6988cefe4326d35a23cad54ca4130 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.10  1996-11-08 22:23:09  brunner
+ * Revision 1.11  1996-11-23 02:25:43  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.10  1996/11/08 22:23:09  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              1
index 0fb4108c366eb29b5cd65d68ac0617b060717cb0..a4b55671d45691750ad0e7ae93f3175ff3d8d9a5 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.27  1996-11-08 22:23:09  brunner
+ * Revision 2.28  1996-11-23 02:25:44  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.27  1996/11/08 22:23:09  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 53738455b0f279c7d0440b6a7e3d63a69ef83bf4..53c691ce640c53608ff7cc6e5eb61bbce4407e73 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 2.27  1996-11-08 22:23:09  brunner
+ * Revision 2.28  1996-11-23 02:25:44  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.27  1996/11/08 22:23:09  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index a3a001950b07e1168435252b67b26b967a075b1e..c4b99a9fae96e5654fed09bc00ad1cecd0ef8f4e 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.2  1996-11-08 22:23:11  brunner
+ * Revision 1.3  1996-11-23 02:25:45  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.2  1996/11/08 22:23:11  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 269ecb64c7b9300fb4016e8a4c00b25b1acc6862..8fb8781416b447ed9c6559c579948e9cfe59ffab 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.16  1996-11-08 22:23:10  brunner
+ * Revision 1.17  1996-11-23 02:25:44  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.16  1996/11/08 22:23:10  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 0b766ffe9eb678c7bbbebc54aeb2488924c5e98c..d737864e0e7a4aaf8f4a5381780b2a37c89c099f 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.18  1996-11-08 22:23:12  brunner
+ * Revision 1.19  1996-11-23 02:25:45  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.18  1996/11/08 22:23:12  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 615e754735a922ab3170c16dc7ac190a5ecf03c1..c403596c602057edaf42428a4221fd8ba248cc11 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.3  1996-11-08 22:23:13  brunner
+ * Revision 1.4  1996-11-23 02:25:46  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.3  1996/11/08 22:23:13  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index f28a88807fe9d33ff22ca468acc6a233e2b8a348..ec222d2576740cb6e14016c2a123304894acb9e6 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.18  1996-11-08 22:23:12  brunner
+ * Revision 1.19  1996-11-23 02:25:46  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.18  1996/11/08 22:23:12  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            0
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        1
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index 7390d4439197b513dc4a02729b7475849f3eb147..68d46f97cc3b05a9a190c5c18bf7b0ad2e868bf9 100644 (file)
@@ -8,7 +8,11 @@
  ***************************************************************************
  *
  * $Log$
- * Revision 1.19  1996-11-08 22:23:13  brunner
+ * Revision 1.20  1996-11-23 02:25:47  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.19  1996/11/08 22:23:13  brunner
  * Put _main in for HP-UX CC compilation.  It is ignored according to the
  * CMK_USE_HP_MAIN_FIX flag.
  *
 #define CMK_THREADS_USE_ALLOCA_WITH_HEADER_FILE            1
 #define CMK_THREADS_USE_ALLOCA_WITH_PRAGMA                 0
 #define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
 
 #define CMK_TIMER_USE_GETRUSAGE                            0
 #define CMK_TIMER_USE_SPECIAL                              0
index e7b469ba4104bc029a241ab54a1a87434be97094..5d7e8010bd66e82f54e22eec67b9842612d3711f 100755 (executable)
@@ -694,7 +694,7 @@ if (($LANGUAGE == charm) || ($LANGUAGE == charm++)) then
         ($ECHOCMD ; $CMK_LD $OPTS_LD -o CHARMC-PRE.TMP.xxx -L$CHARMLIB \
                       $BAL_OBJ $OBJECTFILES $LIBRARIES \
                      CHARMC-MOD.TMP.o -lck-core-$EXECMODE \
-                      -lck-cplus-n -lconv-core -lconv-cplus-n -lck-defmain \
+                      -lck-cplus-n -lconv-cplus-n -lconv-core -lck-defmain \
                      $CMK_LIBS -lm)
     else if ($LANGUAGE == charm++) then
        echo '_CK_module_init_fn() {}' > CHARMC-MOD.TMP.c
@@ -702,7 +702,7 @@ if (($LANGUAGE == charm) || ($LANGUAGE == charm++)) then
         ($ECHOCMD ; $CMK_LDXX $OPTS_LDXX -o CHARMC-PRE.TMP.xxx -L$CHARMLIB \
                      $BAL_OBJ $OBJECTFILES $LIBRARIES \
                      CHARMC-MOD.TMP.o -lck-core-$EXECMODE \
-                      -lck-cplus-y -lconv-core -lconv-cplus-y -lck-defmain \
+                      -lck-cplus-y -lconv-cplus-y -lconv-core -lck-defmain \
                      $CMK_LIBS -lm)
     endif
     $CMK_NM CHARMC-PRE.TMP.xxx | csh -fc "$CMK_NM_FILTER" > CHARMC-PRE.TMP.nm
@@ -730,24 +730,24 @@ switch ($LANGUAGE)
         ($ECHOCMD ; $CMK_LD $OPTS_LD -o $OBJECT -L$CHARMLIB \
                       CHARMC-MOD.TMP.o $BAL_OBJ $OBJECTFILES \
                       $LIBRARIES -lck-core-$EXECMODE \
-                      -lck-cplus-n -lconv-core -lconv-cplus-n -lck-defmain \
+                      -lck-cplus-n -lconv-cplus-n -lconv-core -lck-defmain \
                      $CMK_LIBS -lm)
         breaksw
     case "charm++"
         ($ECHOCMD ; $CMK_LDXX $OPTS_LDXX -o $OBJECT -L$CHARMLIB \
                      CHARMC-MOD.TMP.o $BAL_OBJ $OBJECTFILES \
                       $LIBRARIES -lck-core-$EXECMODE \
-                      -lck-cplus-y -lconv-core -lconv-cplus-y -lck-defmain \
+                      -lck-cplus-y -lconv-cplus-y -lconv-core -lck-defmain \
                      $CMK_LIBS -lm)
         breaksw
     case "converse"
         ($ECHOCMD ; $CMK_LD $OPTS_LD -o $OBJECT -L$CHARMLIB \
-                     $OBJECTFILES $LIBRARIES -lconv-core -lconv-cplus-n \
+                     $OBJECTFILES $LIBRARIES -lconv-cplus-n -lconv-core\
                      $CMK_LIBS -lm)
         breaksw
     case "converse++"
         ($ECHOCMD ; $CMK_LDXX $OPTS_LDXX -o $OBJECT -L$CHARMLIB \
-                     $OBJECTFILES $LIBRARIES -lconv-core -lconv-cplus-y \
+                     $OBJECTFILES $LIBRARIES -lconv-cplus-y -lconv-core \
                      $CMK_LIBS -lm)
         breaksw
 endsw
index 6dad1351cdbeda2fee57530486d8341803ddd38f..df1081be47ba673e8b351c062811fd540bf4640f 100644 (file)
  * REVISION HISTORY:
  *
  * $Log$
- * Revision 2.50  1996-11-20 06:45:40  jyelon
+ * Revision 2.51  1996-11-23 02:25:33  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 2.50  1996/11/20 06:45:40  jyelon
  * Repaired rob's HP/C++ mods.
  *
  * Revision 2.49  1996/11/08 22:22:51  brunner
@@ -497,6 +501,19 @@ extern int CthRegister CMK_PROTO((int));
 #endif /* CMK_THREADS_USE_JB_TWEAKING */
 
 
+#if CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR
+#if CMK_PREPROCESSOR_USES_ANSI_STANDARD_CONCATENATION
+CpvExtern(char*,CthData);
+extern int CthRegister CMK_PROTO((int));
+#define CtvDeclare(t,v)         typedef t CtvType##v; CsvDeclare(int,CtvOffs##v);
+#define CtvStaticDeclare(t,v)   typedef t CtvType##v; CsvDeclare(int,CtvOffs##v);
+#define CtvExtern(t,v)          typedef t CtvType##v; CsvDeclare(int,CtvOffs##v);
+#define CtvAccess(v)            (*((CtvType##v *)(CpvAccess(CthData)+CsvAccess(CtvOffs##v))))
+#define CtvInitialize(t,v)      if (CmiMyRank()==0) (CsvAccess(CtvOffs##v)=CthRegister(sizeof(CtvType##v)));
+#endif /* CMK_PREPROCESSOR_USES_ANSI_STANDARD_CONCATENATION */
+#endif /* CMK_THREADS_USE_JB_TWEAKING */
+
+
 
 #ifndef CtvDeclare
 error Barf.
@@ -529,6 +546,7 @@ struct CpmDestinationStruct
 
 CpmDestination CpmSend CMK_PROTO((int pe));
 CpmDestination CpmMakeThread CMK_PROTO((int pe));
+CpmDestination CpmMakeThreadSize CMK_PROTO((int pe, int size));
 CpmDestination CpmEnqueueFIFO CMK_PROTO((int pe));
 CpmDestination CpmEnqueueLIFO CMK_PROTO((int pe));
 CpmDestination CpmEnqueueIFIFO CMK_PROTO((int pe, int prio));
index 8ac9a8bfccc9cf422a3afbe7a5ce403583ae2dea..23d124abccc4de597456b94033af5bfa39ec2987 100644 (file)
@@ -21,18 +21,21 @@ typedef struct CpmDestinationSend
 }
 *CpmDestinationSend;
 
+typedef struct CpmDestinationSend DestinationSend;
+
 void CpmSend1(CpmDestinationSend ctrl, int len, void *msg)
 {
   CpmLSend(ctrl->pe, len, msg);
 }
 
+CpvStaticDeclare(DestinationSend, ctrlSend);
+
 CpmDestination CpmSend(int pe)
 {
-  static struct CpmDestinationSend ctrl;
-  ctrl.envsize = 0;
-  ctrl.sendfn = (CpmSender)CpmSend1;
-  ctrl.pe = pe;
-  return (CpmDestination)&ctrl;
+  CpvAccess(ctrlSend).envsize = 0;
+  CpvAccess(ctrlSend).sendfn = (CpmSender)CpmSend1;
+  CpvAccess(ctrlSend).pe = pe;
+  return (CpmDestination)&CpvAccess(ctrlSend);
 }
 
 /******************************************************************************
@@ -49,6 +52,10 @@ typedef struct CpmDestinationEnq
 }
 *CpmDestinationEnq;
 
+typedef struct CpmDestinationEnq DestinationEnq;
+
+CpvStaticDeclare(DestinationEnq, ctrlEnq);
+
 CpvDeclare(int, CpmEnqueue2_Index);
 
 void CpmEnqueue2(void *msg)
@@ -76,27 +83,29 @@ void *CpmEnqueue1(CpmDestinationEnq ctrl, int len, void *msg)
 
 CpmDestination CpmEnqueue(int pe, int qs, int priobits, int *prioptr)
 {
-  static struct CpmDestinationEnq ctrl;
   int intbits = sizeof(int)*8;
   int prioints = (priobits+intbits-1) / intbits;
-  ctrl.envsize = (3+prioints)*sizeof(int);
-  ctrl.sendfn  = CpmEnqueue1;
-  ctrl.pe = pe; ctrl.qs = qs; ctrl.priobits = priobits; ctrl.prioptr = prioptr;
-  return (CpmDestination)&ctrl;
+  CpvAccess(ctrlEnq).envsize = (3+prioints)*sizeof(int);
+  CpvAccess(ctrlEnq).sendfn  = CpmEnqueue1;
+  CpvAccess(ctrlEnq).pe = pe; CpvAccess(ctrlEnq).qs = qs; 
+  CpvAccess(ctrlEnq).priobits = priobits; CpvAccess(ctrlEnq).prioptr = prioptr;
+  return (CpmDestination)&CpvAccess(ctrlEnq);
 }
 
+CpvStaticDeclare(int, fiprio);
+
 CpmDestination CpmEnqueueIFIFO(int pe, int prio)
 {
-  static int iprio;
-  iprio = prio;
-  return CpmEnqueue(pe, CQS_QUEUEING_IFIFO, sizeof(int)*8, &iprio);
+  CpvAccess(fiprio) = prio;
+  return CpmEnqueue(pe, CQS_QUEUEING_IFIFO, sizeof(int)*8, &CpvAccess(fiprio));
 }
 
+CpvStaticDeclare(int, liprio);
+
 CpmDestination CpmEnqueueILIFO(int pe, int prio)
 {
-  static int iprio;
-  iprio = prio;
-  return CpmEnqueue(pe, CQS_QUEUEING_ILIFO, sizeof(int)*8, &iprio);
+  CpvAccess(liprio) = prio;
+  return CpmEnqueue(pe, CQS_QUEUEING_ILIFO, sizeof(int)*8, &CpvAccess(liprio));
 }
 
 CpmDestination CpmEnqueueBFIFO(int pe, int priobits, int *prioptr)
@@ -134,13 +143,14 @@ void *CpmEnqueueFIFO1(CpmDestinationSend ctrl, int len, void *msg)
   CpmLSend(ctrl->pe, len, msg);
 }
 
+CpvStaticDeclare(DestinationSend, ctrlFIFO);
+
 CpmDestination CpmEnqueueFIFO(int pe)
 {
-  static struct CpmDestinationSend ctrl;
-  ctrl.envsize = sizeof(int);
-  ctrl.sendfn  = CpmEnqueueFIFO1;
-  ctrl.pe = pe;
-  return (CpmDestination)&ctrl;
+  CpvAccess(ctrlFIFO).envsize = sizeof(int);
+  CpvAccess(ctrlFIFO).sendfn  = CpmEnqueueFIFO1;
+  CpvAccess(ctrlFIFO).pe = pe;
+  return (CpmDestination)&CpvAccess(ctrlFIFO);
 }
 
 /******************************************************************************
@@ -168,13 +178,14 @@ void *CpmEnqueueLIFO1(CpmDestinationSend ctrl, int len, void *msg)
   CpmLSend(ctrl->pe, len, msg);
 }
 
+CpvStaticDeclare(DestinationSend, ctrlLIFO);
+
 CpmDestination CpmEnqueueLIFO(int pe)
 {
-  static struct CpmDestinationSend ctrl;
-  ctrl.envsize = sizeof(int);
-  ctrl.sendfn  = CpmEnqueueLIFO1;
-  ctrl.pe = pe;
-  return (CpmDestination)&ctrl;
+  CpvAccess(ctrlLIFO).envsize = sizeof(int);
+  CpvAccess(ctrlLIFO).sendfn  = CpmEnqueueLIFO1;
+  CpvAccess(ctrlLIFO).pe = pe;
+  return (CpmDestination)&CpvAccess(ctrlLIFO);
 }
 
 /******************************************************************************
@@ -189,6 +200,8 @@ void CpmThread3(void *msg)
 {
   int *env = (int *)CpmEnv(msg);
   CpvAccess(CmiHandlerTable)[env[0]](msg);
+  // Had to do Free here... milind
+  CmiFree(msg);
   CthFree(CthSelf()); CthSuspend();
 }
 
@@ -208,13 +221,62 @@ void CpmThread1(CpmDestinationSend ctrl, int len, void *msg)
   CpmLSend(ctrl->pe, len, msg);
 }
 
+CpvStaticDeclare(DestinationSend, ctrlThread);
+
 CpmDestination CpmMakeThread(int pe)
 {
-  static struct CpmDestinationSend ctrl;
-  ctrl.envsize = sizeof(int);
-  ctrl.sendfn = (CpmSender)CpmThread1;
-  ctrl.pe = pe;
-  return (CpmDestination)&ctrl;
+  CpvAccess(ctrlThread).envsize = sizeof(int);
+  CpvAccess(ctrlThread).sendfn = (CpmSender)CpmThread1;
+  CpvAccess(ctrlThread).pe = pe;
+  return (CpmDestination)&CpvAccess(ctrlThread);
+}
+
+/******************************************************************************
+ *
+ * Control for thread-creation with size parameter
+ *
+ *****************************************************************************/
+
+CpvDeclare(int, CpmThreadSize2_Index);
+
+typedef struct CpmDestinationThreadSize
+{ 
+  void *(*sendfn)();
+  int envsize;
+  int pe;
+  int size;
+}
+*CpmDestinationThreadSize;
+
+typedef struct CpmDestinationThreadSize DestinationThreadSize;
+
+void CpmThreadSize2(void *msg)
+{
+  int *env = (int *)CpmEnv(msg);
+  CthThread t;
+  CmiGrabBuffer(&msg);
+  t = CthCreate(CpmThread3, msg, env[1]);
+  CthSetStrategyDefault(t); CthAwaken(t);
+}
+
+void CpmThreadSize1(CpmDestinationThreadSize ctrl, int len, void *msg)
+{
+  int *env = (int *)CpmEnv(msg);
+  env[0] = CmiGetHandler(msg);
+  env[1] = ctrl->size;
+  CmiSetHandler(msg, CpvAccess(CpmThreadSize2_Index));
+  CpmLSend(ctrl->pe, len, msg);
+}
+
+CpvStaticDeclare(DestinationThreadSize, ctrlThreadSize);
+
+CpmDestination CpmMakeThreadSize(int pe, int size)
+{
+  CpvAccess(ctrlThreadSize).envsize = 2*sizeof(int);
+  CpvAccess(ctrlThreadSize).sendfn = (CpmSender)CpmThreadSize1;
+  CpvAccess(ctrlThreadSize).pe = pe;
+  CpvAccess(ctrlThreadSize).size = size;
+  return (CpmDestination)&CpvAccess(ctrlThreadSize);
 }
 
 /******************************************************************************
@@ -227,11 +289,21 @@ void CpmModuleInit()
 {
   CpvInitialize(int, CpmThread2_Index);
   CpvAccess(CpmThread2_Index) = CmiRegisterHandler(CpmThread2);
+  CpvInitialize(int, CpmThreadSize2_Index);
+  CpvAccess(CpmThreadSize2_Index) = CmiRegisterHandler(CpmThreadSize2);
   CpvInitialize(int, CpmEnqueueFIFO2_Index);
   CpvAccess(CpmEnqueueFIFO2_Index) = CmiRegisterHandler(CpmEnqueueFIFO2);
   CpvInitialize(int, CpmEnqueueLIFO2_Index);
   CpvAccess(CpmEnqueueLIFO2_Index) = CmiRegisterHandler(CpmEnqueueLIFO2);
   CpvInitialize(int, CpmEnqueue2_Index);
   CpvAccess(CpmEnqueue2_Index) = CmiRegisterHandler(CpmEnqueue2);
+  CpvInitialize(DestinationSend, ctrlSend);
+  CpvInitialize(DestinationEnq, ctrlEnq);
+  CpvInitialize(DestinationSend, ctrlFIFO);
+  CpvInitialize(DestinationSend, ctrlLIFO);
+  CpvInitialize(DestinationSend, ctrlThread);
+  CpvInitialize(DestinationThreadSize, ctrlThreadSize);
+  CpvInitialize(int, fiprio);
+  CpvInitialize(int, liprio);
 }
 
index 2717e533bdc2739adaac04f58c04f561a88954b4..ea4786ad45f9f607e7da25b5b2a1fe07442f3f3e 100644 (file)
  * REVISION HISTORY:
  *
  * $Log$
- * Revision 1.24  1996-10-24 20:51:50  milind
+ * Revision 1.25  1996-11-23 02:25:34  milind
+ * Fixed several subtle bugs in the converse runtime for convex
+ * exemplar.
+ *
+ * Revision 1.24  1996/10/24 20:51:50  milind
  * Removed the additional token after one #endif.
  *
  * Revision 1.23  1996/07/15 21:00:49  jyelon
@@ -653,6 +657,240 @@ int size;
 
 #endif
 
+/*****************************************************************************
+ *
+ * threads: implementation CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR
+ *
+ * This threads implementation saves and restores state using setjmp
+ * and longjmp, and it creates new states by doing a setjmp and then
+ * twiddling the contents of the jmp_buf.  It uses a heuristic to find
+ * the places in the jmp_buf it needs to adjust to change the stack
+ * pointer.  It sometimes works.  It has the advantage that it doesn't
+ * require alloca.
+ *
+ ****************************************************************************/
+
+#if CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <sys/types.h>
+
+#define STACKSIZE (32768)
+#define SLACK     256
+
+CpvDeclare(char*,CthData);
+
+typedef struct { jmp_buf jb; } jmpb;
+
+typedef struct CthThreadStruct
+{
+  char cmicore[CmiMsgHeaderSizeBytes]; /* So we can enqueue them */
+  jmp_buf    jb;
+  CthVoidFn  fn;
+  void      *arg;
+  CthVoidFn  awakenfn;
+  CthThFn    choosefn;
+  char      *data;
+  int        datasize;
+  double     stack[1];
+}ThreadStruct;
+
+
+CpvStaticDeclare(jmp_buf,thread_launching);
+CpvStaticDeclare(CthThread,thread_current);
+CpvStaticDeclare(CthThread,thread_exiting);
+CpvStaticDeclare(int,thread_growsdown);
+CpvStaticDeclare(int,thread_datasize);
+CpvStaticDeclare(int,thread_jb_offsets)[10];
+CpvStaticDeclare(int,thread_jb_count);
+
+#define ABS(a) (((a) > 0)? (a) : -(a) )
+
+int CthImplemented()
+    { return 1; }
+
+static void CthInitSub1(jmpb *bufs, int *frames, int n)
+{
+  double d;
+  frames[n] = (int)(&d);
+  setjmp(bufs[n].jb);
+  if (n==0) return;
+  CthInitSub1(bufs, frames, n-1);
+}
+
+static void CthInitSub2()
+{
+  if (setjmp(CpvAccess(thread_launching))) {
+    (CpvAccess(thread_current)->fn)(CpvAccess(thread_current)->arg);
+    exit(1);
+  }
+}
+
+void CthInit()
+{
+  int frames[2];
+  jmpb bufs[2];
+  int i, j, delta, size, *p0, *p1;
+
+  CpvAccess(thread_datasize)=1;
+  CpvAccess(thread_current)=(CthThread)CmiAlloc(sizeof(struct CthThreadStruct));
+  CpvAccess(thread_current)->fn=0;
+  CpvAccess(thread_current)->arg=0;
+  CpvAccess(thread_current)->data=0;
+  CpvAccess(thread_current)->datasize=0;
+  CpvAccess(thread_current)->awakenfn = 0;
+  CpvAccess(thread_current)->choosefn = 0;
+
+  /* analyze the activation record. */
+  CthInitSub1(bufs, frames, 1);
+  CthInitSub2();
+  CpvAccess(thread_growsdown) = (frames[0] < frames[1]);
+  size = (sizeof(jmpb)/sizeof(int));
+  delta = frames[0]-frames[1];
+  p0 = (int *)(bufs+0);
+  p1 = (int *)(bufs+1);
+  CpvAccess(thread_jb_count) = 0;
+  for (i=0; i<size; i++) {
+    if (CpvAccess(thread_jb_count)==10) goto fail;
+    if ((p0[i]-p1[i])==delta) {
+      CpvAccess(thread_jb_offsets)[CpvAccess(thread_jb_count)++] = i;
+      ((int *)(&CpvAccess(thread_launching)))[i] -= (int)(frames[1]);
+    }
+  }
+  if (CpvAccess(thread_jb_count) == 0) goto fail;
+  return;
+fail:
+  CmiPrintf("Thread initialization failed.\n");
+  exit(1);
+}
+
+CthThread CthSelf()
+{
+  return CpvAccess(thread_current);
+}
+
+static void CthTransfer(t)
+CthThread t;
+{
+  CpvAccess(thread_current) = t;
+  CpvAccess(CthData) = t->data;
+  longjmp(t->jb, 1);
+}
+
+void CthFixData(t)
+CthThread t;
+{
+  if (t->data == 0) {
+    t->datasize = CpvAccess(thread_datasize);
+    t->data = (char *)malloc(CpvAccess(thread_datasize));
+    return;
+  }
+  if (t->datasize != CpvAccess(thread_datasize)) {
+    t->datasize = CpvAccess(thread_datasize);
+    t->data = (char *)realloc(t->data, t->datasize);
+    return;
+  }
+}
+
+static void CthFreeNow(t)
+CthThread t;
+{
+  if (t->data) free(t->data); 
+  CmiFree(t);
+}
+
+void CthResume(t)
+CthThread t;
+{
+  int i;
+  if (t == CpvAccess(thread_current)) return;
+  CthFixData(t);
+  if ((setjmp(CpvAccess(thread_current)->jb))==0)
+    CthTransfer(t);
+  if (CpvAccess(thread_exiting))
+    { CthFreeNow(CpvAccess(thread_exiting)); CpvAccess(thread_exiting)=0; }
+}
+
+CthThread CthCreate(fn, arg, size)
+CthVoidFn fn; void *arg; int size;
+{
+  CthThread  result; int i, sp;
+  if (size==0) size = STACKSIZE;
+  result = (CthThread)CmiAlloc(sizeof(struct CthThreadStruct) + size);
+  sp = ((int)(result->stack));
+  sp += (CpvAccess(thread_growsdown)) ? (size - SLACK) : SLACK;
+  result->fn = fn;
+  result->arg = arg;
+  result->awakenfn = 0;
+  result->choosefn = 0;
+  result->data = 0;
+  result->datasize = 0;
+  memcpy(&(result->jb), &CpvAccess(thread_launching), sizeof(CpvAccess(thread_launching)));
+  for (i=0; i<CpvAccess(thread_jb_count); i++)
+    ((int *)(&(result->jb)))[CpvAccess(thread_jb_offsets)[i]] += sp;
+  return result;
+}
+
+void CthFree(t)
+CthThread t;
+{
+  if (t==CpvAccess(thread_current)) {
+    CpvAccess(thread_exiting) = t;
+  } else CthFreeNow(t);
+}
+
+static void CthNoStrategy()
+{
+  CmiPrintf("Called CthAwaken or CthSuspend before calling CthSetStrategy.\n");
+  exit(1);
+}
+
+void CthSuspend()
+{
+  CthThread next;
+  if (CpvAccess(thread_current)->choosefn == 0) CthNoStrategy();
+  next = CpvAccess(thread_current)->choosefn();
+  CthResume(next);
+}
+
+void CthAwaken(th)
+CthThread th;
+{
+  if (th->awakenfn == 0) CthNoStrategy();
+  th->awakenfn(th);
+}
+
+void CthSetStrategy(t, awkfn, chsfn)
+CthThread t;
+CthVoidFn awkfn;
+CthThFn chsfn;
+{
+  t->awakenfn = awkfn;
+  t->choosefn = chsfn;
+}
+
+void CthYield()
+{
+  CthAwaken(CpvAccess(thread_current));
+  CthSuspend();
+}
+
+int CthRegister(size)
+int size;
+{
+  int result;
+  int align = 1;
+  while (size>align) align<<=1;
+  CpvAccess(thread_datasize) = (CpvAccess(thread_datasize)+align-1) & ~(align-1);
+  result = CpvAccess(thread_datasize);
+  CpvAccess(thread_datasize) += size;
+  CthFixData(CpvAccess(thread_current));
+  CpvAccess(CthData) = CpvAccess(thread_current)->data;
+  return result;
+}
+
+#endif
 /*****************************************************************************
  *
  * threads: implementation CMK_THREADS_USE_EATSTACK