Added Origin2000 version.
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 28 Mar 1997 17:38:22 +0000 (17:38 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 28 Mar 1997 17:38:22 +0000 (17:38 +0000)
src/arch/origin2000/conv-mach.csh [new file with mode: 0755]
src/arch/origin2000/conv-mach.h [new file with mode: 0644]
src/arch/origin2000/machine.c [new file with mode: 0644]
src/arch/origin2000/spantree.c [new file with mode: 0644]

diff --git a/src/arch/origin2000/conv-mach.csh b/src/arch/origin2000/conv-mach.csh
new file mode 100755 (executable)
index 0000000..37e1df7
--- /dev/null
@@ -0,0 +1,47 @@
+############################################################################
+# RCS INFORMATION:
+#
+#      $RCSfile$
+#      $Author$        $Locker$                $State$
+#      $Revision$      $Date$
+#
+############################################################################
+# DESCRIPTION:
+#
+############################################################################
+# REVISION HISTORY:
+#
+#
+############################################################################
+
+set CMK_CPP_CHARM='/usr/lib/cpp '
+set CMK_CPP_C='cc -E -64 '
+set CMK_LDRO='ld -r -o'
+set CMK_LDRO_WORKS=0
+set CMK_CC='cc  -w -64 '
+set CMK_CC_RELIABLE='cc  -w -64 '
+set CMK_CC_FASTEST='cc  -w -64 '
+set CMK_CXX='CC -w -64 '
+set CMK_CXXPP='CC -E -w -64 '
+set CMK_CF77=''
+set CMK_C_DEBUG='-g'
+set CMK_C_OPTIMIZE='-O'
+set CMK_CXX_DEBUG='-g'
+set CMK_CXX_OPTIMIZE='-O'
+set CMK_LD='cc -w -64 '
+set CMK_LDXX='CC -w -64 '
+set CMK_LD77=''
+set CMK_M4='m4'
+set CMK_SUF='o'
+set CMK_AR='ar cq'
+set CMK_RANLIB='true'
+set CMK_LIBS=' '
+set CMK_SEQ_LIBS=' '
+set CMK_SEQ_CC='cc -w -64 '
+set CMK_SEQ_LD='cc -w -64 '
+set CMK_SEQ_CXX='CC -w -64 '
+set CMK_SEQ_LDXX='CC -w -64 '
+set CMK_NM='nm'
+set CMK_NM_FILTER="grep '|GLOB |' | sed -e 's/.*|//'"
+set CMK_CPP_SUFFIX="i"
+set CMK_XLATPP='charmxlat++ -w '
diff --git a/src/arch/origin2000/conv-mach.h b/src/arch/origin2000/conv-mach.h
new file mode 100644 (file)
index 0000000..0898982
--- /dev/null
@@ -0,0 +1,162 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *   $RCSfile$
+ *   $Author$       $Locker$        $State$
+ *   $Revision$     $Date$
+ *
+ ***************************************************************************
+ *
+ * $Log$
+ * Revision 1.1  1997-03-28 17:38:23  milind
+ * Added Origin2000 version.
+ *
+ * Revision 1.2  1997/03/25 23:09:09  milind
+ * Got threads to work on 64-bit irix. Had to add JB_TWEAKING_ORIGIN flag to
+ * all the conv-mach.h files. Also, _PAGESZ was undefined on irix. Added
+ * code to memory.c to make it a static variable.
+ *
+ * Revision 1.1  1997/03/19 21:45:27  milind
+ * net-irix-64 bit bersion. Not tested yet.
+ *
+ * Revision 1.3  1997/02/13 09:31:45  jyelon
+ * Updated for new main/ConverseInit structure.
+ *
+ * Revision 1.2  1997/02/08 14:10:19  jyelon
+ * Correcting bugs in network version.
+ *
+ * Revision 1.1  1997/01/28 16:26:42  milind
+ * Added net-irix version. Had to fix the charm++ translator for that.
+ * Also, threads are currently not supported on net-irix.
+ * Added a test program to measure scheduling overhead for both
+ * normal as well as threaded entry methods.
+ *
+ * Revision 2.28  1997/01/17 15:50:26  jyelon
+ * Minor adjustments to deal with recent changes to Common code.
+ *
+ * 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.
+ *
+ * Revision 2.25  1996/10/24 19:40:26  milind
+ * Added CMK_IS_HETERO to all the net-all versions.
+ *
+ * Revision 2.24  1996/08/08 20:16:53  jyelon
+ * *** empty log message ***
+ *
+ * Revision 2.23  1996/07/16 17:23:37  jyelon
+ * Renamed a flag.
+ *
+ * Revision 2.22  1996/07/16 05:20:41  milind
+ * Added CMK_VECTOR_SEND
+ *
+ * Revision 2.21  1996/07/15  20:58:27  jyelon
+ * Flags now use #if, not #ifdef.  Also cleaned up a lot.
+ *
+ *
+ **************************************************************************/
+
+#ifndef _CONV_MACH_H
+#define _CONV_MACH_H
+
+#define CMK_ASYNC_NOT_NEEDED                               1
+#define CMK_ASYNC_USE_FIOASYNC_AND_FIOSETOWN               0
+#define CMK_ASYNC_USE_FIOASYNC_AND_SIOCSPGRP               0
+#define CMK_ASYNC_USE_FIOSSAIOSTAT_AND_FIOSSAIOOWN         0
+#define CMK_ASYNC_USE_F_SETFL_AND_F_SETOWN                 0
+
+#define CMK_CMIDELIVERS_USE_COMMON_CODE                    1
+#define CMK_CMIDELIVERS_USE_SPECIAL_CODE                   0
+
+#define CMK_CMIPRINTF_IS_A_BUILTIN                         0
+#define CMK_CMIPRINTF_IS_JUST_PRINTF                       1
+
+#define CMK_COMMHANDLE_IS_AN_INTEGER                       0
+#define CMK_COMMHANDLE_IS_A_POINTER                        1
+
+#define CMK_CSDEXITSCHEDULER_IS_A_FUNCTION                 0
+#define CMK_CSDEXITSCHEDULER_SET_CSDSTOPFLAG               1
+
+#define CMK_DEFAULT_MAIN_USES_COMMON_CODE                  1
+
+#define CMK_FIX_HP_CONNECT_BUG                             0
+
+#define CMK_IS_HETERO                                      0
+
+#define CMK_MACHINE_NAME                                   "origin2000"
+
+#define CMK_MALLOC_USE_GNU_MALLOC                          1
+#define CMK_MALLOC_USE_OS_BUILTIN                          0
+
+#define CMK_MSG_HEADER_SIZE_BYTES                          4
+#define CMK_MSG_HEADER_BLANK_SPACE                         0
+
+#define CMK_PREPROCESSOR_CANNOT_DO_CONCATENATION           0
+#define CMK_PREPROCESSOR_USES_ANSI_STANDARD_CONCATENATION  1
+
+#define CMK_PROTOTYPES_FAIL                                0
+#define CMK_PROTOTYPES_WORK                                1
+
+#define CMK_RSH_IS_A_COMMAND                               0
+#define CMK_RSH_NOT_NEEDED                                 1
+#define CMK_RSH_USE_REMSH                                  0
+
+#define CMK_SHARED_VARS_ORIGIN                             1
+#define CMK_SHARED_VARS_EXEMPLAR                           0
+#define CMK_SHARED_VARS_UNAVAILABLE                        0
+#define CMK_SHARED_VARS_UNIPROCESSOR                       0
+#define CMK_SHARED_VARS_SUN_THREADS                        0
+
+#define CMK_SIGHOLD_IS_A_BUILTIN                           0
+#define CMK_SIGHOLD_NOT_NEEDED                             1
+#define CMK_SIGHOLD_USE_SIGMASK                            0
+
+#define CMK_SIGNAL_NOT_NEEDED                              1
+#define CMK_SIGNAL_USE_SIGACTION                           0
+#define CMK_SIGNAL_USE_SIGACTION_WITH_RESTART              0
+
+#define CMK_SIZE_T                                         unsigned long
+
+#define CMK_STATIC_PROTO_FAILS                             0
+#define CMK_STATIC_PROTO_WORKS                             1
+
+#define CMK_STRERROR_IS_A_BUILTIN                          1
+#define CMK_STRERROR_USE_SYS_ERRLIST                       0
+
+#define CMK_STRINGS_USE_OWN_DECLARATIONS                   0
+#define CMK_STRINGS_USE_STRINGS_H                          0
+#define CMK_STRINGS_USE_STRING_H                           1
+
+#define CMK_THREADS_REQUIRE_ALLOCA_H                       0
+#define CMK_THREADS_REQUIRE_PRAGMA_ALLOCA                  0
+#define CMK_THREADS_REQUIRE_NO_CPV                         0
+
+#define CMK_THREADS_UNAVAILABLE                            0
+#define CMK_THREADS_USE_ALLOCA                             0
+#define CMK_THREADS_USE_JB_TWEAKING                        0
+#define CMK_THREADS_USE_JB_TWEAKING_EXEMPLAR               0
+#define CMK_THREADS_USE_JB_TWEAKING_ORIGIN                 1
+
+#define CMK_TIMER_USE_GETRUSAGE                            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
+
+#define CMK_WAIT_NOT_NEEDED                                0
+#define CMK_WAIT_USES_SYS_WAIT_H                           1
+#define CMK_WAIT_USES_WAITFLAGS_H                          0
+
+#define CMK_WHEN_PROCESSOR_IDLE_BUSYWAIT                   1
+#define CMK_WHEN_PROCESSOR_IDLE_USLEEP                     0
+
+#define CMK_USE_HP_MAIN_FIX                                0
+#define CMK_DONT_USE_HP_MAIN_FIX                           1
+
+#endif
+
diff --git a/src/arch/origin2000/machine.c b/src/arch/origin2000/machine.c
new file mode 100644 (file)
index 0000000..bf95f4a
--- /dev/null
@@ -0,0 +1,496 @@
+#include <sys/types.h>
+#include <sys/sysmp.h>
+#include <sys/sysinfo.h>
+#include <sys/prctl.h>
+#include <sys/pda.h>
+#include <ulocks.h>
+#include <math.h>
+#include "converse.h"
+
+usptr_t *arena;
+static barrier_t *barr;
+
+extern void *FIFO_Create(void);
+extern void FIFO_EnQueue(void *, void *);
+
+#define BLK_LEN  512
+typedef struct {
+  usema_t  *sema;
+  void     **blk;
+  unsigned int blk_len;
+  unsigned int first;
+  unsigned int len;
+  unsigned int maxlen;
+} McQueue;
+
+static McQueue *McQueueCreate(void);
+static void McQueueAddToBack(McQueue *queue, void *element);
+static void *McQueueRemoveFromFront(McQueue *queue);
+static McQueue **MsgQueue;
+#define g_malloc(s)  usmalloc(s,arena)
+#define g_free(p)    usfree(p,arena)
+
+
+CpvDeclare(void*, CmiLocalQueue);
+CpvDeclare(int, Cmi_mype);
+CpvDeclare(int, Cmi_numpes);
+
+static int nthreads;
+static int requested_npe;
+
+static void threadInit(void *arg);
+
+CpvDeclare(int, membusy);
+
+void CmiMemLock() {CpvAccess(membusy)=1;}
+void CmiMemUnlock() {CpvAccess(membusy)=0;}
+
+void *CmiAlloc(int size)
+{
+  char *res;
+  res =(char *) malloc(size+8);
+  if (res==(char *)0) { 
+    CmiError("%d:Memory allocation failed.",CmiMyPe()); 
+    abort();
+  }
+  ((int *)res)[0]=size;
+  return (void *)(res+8);
+}
+
+int CmiSize(void *blk)
+{
+  return ((int *)( ((char *) blk) - 8))[0];
+}
+
+void CmiFree(void *blk)
+{
+  free( ((char *)blk) - 8);
+}
+
+
+void *CmiSvAlloc(int size)
+{
+  char *res;
+  res =(char *) usmalloc(size+8,arena);
+  if (res==0) {
+    CmiError("Memory allocation failed.");
+    abort();
+  }
+  ((int *)res)[0]=size;
+  return (void *)(res+8);
+}
+
+void CmiSvFree(blk)
+char *blk;
+{
+  usfree(blk-8, arena);
+}
+
+
+int CmiAsyncMsgSent(CmiCommHandle msgid)
+{
+  return 0;
+}
+
+
+typedef struct {
+  void       *argv;
+  CmiStartFn fn;
+  int        argc;
+  int        npe;
+  int        mype;
+  int        usched;
+  int        initret;
+} USER_PARAMETERS;
+
+USER_PARAMETERS usrparam;
+
+void ConverseInit(int argc, char **argv, CmiStartFn fn, int usched, int initret)
+{
+  int i;
+  i =  0;
+  requested_npe = 0; 
+  while (argv[i] != 0) {
+    if (strcmp(argv[i], "+p") == 0) {
+      sscanf(argv[i+1], "%d", &requested_npe);
+      break;
+    } else {
+      if (sscanf(argv[i], "+p%d", &requested_npe) == 1) break;
+    }
+    i++;
+  }
+
+  if (requested_npe <= 0)
+  {
+    CmiError("Error: requested number of processors is invalid %d\n",
+              requested_npe);
+    abort();
+  }
+
+  usconfig(CONF_INITUSERS, requested_npe+1);
+  usconfig(CONF_ARENATYPE, US_SHAREDONLY);
+  if(usconfig(CONF_INITSIZE,  16<<20)==(-1)) {
+    CmiPrintf("Cannot set size of arena\n");
+    abort();
+  }
+  arena = usinit("/dev/zero");
+  if(arena == (usptr_t *) NULL) {
+    CmiError("Cannot allocate arena\n");
+    abort();
+  }
+  barr = new_barrier(arena);
+  init_barrier(barr);
+  nthreads = requested_npe;
+
+  usrparam.argc = argc;
+  usrparam.argv = argv;
+  usrparam.npe = requested_npe;
+  usrparam.fn = fn;
+  usrparam.initret = initret;
+  usrparam.usched = usched;
+
+  MsgQueue=(McQueue **)g_malloc(requested_npe*sizeof(McQueue *));
+  if (MsgQueue == (McQueue **)0) {
+    CmiError("Cannot Allocate Memory...\n");
+    abort();
+  }
+  for(i=0; i<requested_npe; i++) 
+    MsgQueue[i] = McQueueCreate();
+
+  for(i=0; i<requested_npe; i++) {
+    usrparam.mype = i;
+    sproc(threadInit, PR_SFDS, (void *)&usrparam);
+  }
+  for(i=0;i<requested_npe;i++)
+    wait(0);
+}
+
+static void threadInit(void *arg)
+{
+  USER_PARAMETERS *usrparam;
+  usrparam = (USER_PARAMETERS *) arg;
+
+  CpvInitialize(int, Cmi_mype);
+  CpvInitialize(int, Cmi_numpes);
+  CpvInitialize(void*, CmiLocalQueue);
+
+  CpvAccess(Cmi_mype)  = usrparam->mype;
+  CpvAccess(Cmi_numpes) =  usrparam->npe;
+#ifdef DEBUG
+  printf("thread %d/%d started \n", CmiMyPe(), CmiNumPes());
+#endif
+
+  ConverseCommonInit(usrparam->argv);
+  CthInit(usrparam->argv);
+  neighbour_init(CpvAccess(Cmi_mype));
+  CpvAccess(CmiLocalQueue) = (void *) FIFO_Create();
+  CmiSpanTreeInit();
+  CmiTimerInit();
+  usadd(arena);
+  if (usrparam->initret==0) {
+    usrparam->fn(usrparam->argc, usrparam->argv);
+    if (usrparam->usched==0) CsdScheduler(-1);
+    ConverseExit();
+  }
+}
+
+
+void ConverseExit(void)
+{
+  barrier(barr, nthreads);
+}
+
+
+CmiDeclareArgs()
+{
+}
+
+
+void *CmiGetNonLocal()
+{
+  return McQueueRemoveFromFront(MsgQueue[CmiMyPe()]);
+}
+
+
+void CmiSyncSendFn(int destPE, int size, char *msg)
+{
+  char *buf;
+
+  buf=(void *)g_malloc(size+8);
+  if(buf==(void *)0) {
+    CmiError("Cannot allocate memory of size %d!\n", size);
+    abort();
+  }
+  ((int *)buf)[0]=size;
+  buf += 8;
+
+#ifdef DEBUG
+  printf("Message of size %d allocated\n", CmiSize(buf));
+#endif
+  memcpy(buf,msg,size);
+  McQueueAddToBack(MsgQueue[destPE],buf); 
+}
+
+
+CmiCommHandle CmiAsyncSendFn(int destPE, int size, char *msg)
+{
+  CmiSyncSendFn(destPE, size, msg); 
+  return 0;
+}
+
+
+void CmiFreeSendFn(int destPE, int size, char *msg)
+{
+  if (CpvAccess(Cmi_mype)==destPE) {
+    FIFO_EnQueue(CpvAccess(CmiLocalQueue),msg);
+  } else {
+    CmiSyncSendFn(destPE, size, msg);
+    CmiFree(msg);
+  }
+}
+
+void CmiSyncBroadcastFn(int size, char *msg)
+{
+  int i;
+  for(i=0; i<CmiNumPes(); i++)
+    if (CmiMyPe() != i) CmiSyncSendFn(i,size,msg);
+}
+
+CmiCommHandle CmiAsyncBroadcastFn(int size, char *msg)
+{
+  CmiSyncBroadcastFn(size, msg);
+  return 0;
+}
+
+void CmiFreeBroadcastFn(int size, char *msg)
+{
+  CmiSyncBroadcastFn(size,msg);
+  CmiFree(msg);
+}
+
+void CmiSyncBroadcastAllFn(int size, char *msg)
+{
+  int i;
+  for(i=0; i<CmiNumPes(); i++) 
+    CmiSyncSendFn(i,size,msg);
+}
+
+
+CmiCommHandle CmiAsyncBroadcastAllFn(int size, char *msg)
+{
+  CmiSyncBroadcastAllFn(size, msg);
+  return 0; 
+}
+
+
+void CmiFreeBroadcastAllFn(int size, char *msg)
+{
+  int i;
+  for(i=0; i<CmiNumPes(); i++) {
+    if(CmiMyPe() != i) {
+      CmiSyncSendFn(i,size,msg);
+    }
+  }
+  FIFO_EnQueue(CpvAccess(CmiLocalQueue),msg);
+}
+
+void CmiNodeBarrier()
+{
+  barrier(barr,nthreads);
+}
+
+/* ********************************************************************** */
+/* The following functions are required by the load balance modules       */
+/* ********************************************************************** */
+
+static int _MC_neighbour[4]; 
+static int _MC_numofneighbour;
+
+long CmiNumNeighbours(int node)
+{
+  if (node == CmiMyPe() ) 
+   return  _MC_numofneighbour;
+  else 
+   return 0;
+}
+
+
+CmiGetNodeNeighbours(int node, int *neighbours)
+{
+  int i;
+
+  if (node == CmiMyPe() )
+    for(i=0; i<_MC_numofneighbour; i++) 
+      neighbours[i] = _MC_neighbour[i];
+}
+
+
+int CmiNeighboursIndex(int node, int neighbour)
+{
+  int i;
+
+  for(i=0; i<_MC_numofneighbour; i++)
+    if (_MC_neighbour[i] == neighbour) return i;
+  return(-1);
+}
+
+
+static neighbour_init(int p)
+{
+  int a,b,n;
+
+  n = CmiNumPes();
+  a = (int)sqrt((double)n);
+  b = (int) ceil( ((double)n / (double)a) );
+
+   
+  _MC_numofneighbour = 0;
+   
+  /* east neighbour */
+  if( (p+1)%b == 0 )
+    n = p-b+1;
+  else {
+    n = p+1;
+    if(n>=CmiNumPes()) 
+      n = (a-1)*b; /* west-south corner */
+  }
+  if(neighbour_check(p,n) ) 
+    _MC_neighbour[_MC_numofneighbour++] = n;
+
+  /* west neigbour */
+  if( (p%b) == 0) {
+    n = p+b-1;
+  if(n >= CmiNumPes()) 
+    n = CmiNumPes()-1;
+  } else
+    n = p-1;
+  if(neighbour_check(p,n) ) 
+    _MC_neighbour[_MC_numofneighbour++] = n;
+
+  /* north neighbour */
+  if( (p/b) == 0) {
+    n = (a-1)*b+p;
+    if(n >= CmiNumPes()) 
+      n = n-b;
+  } else
+    n = p-b;
+  if(neighbour_check(p,n) ) 
+    _MC_neighbour[_MC_numofneighbour++] = n;
+    
+  /* south neighbour */
+  if( (p/b) == (a-1) )
+    n = p%b;
+  else {
+    n = p+b;
+    if(n >= CmiNumPes()) 
+      n = n%b;
+  } 
+  if(neighbour_check(p,n) ) 
+    _MC_neighbour[_MC_numofneighbour++] = n;
+}
+
+static neighbour_check(int p, int n)
+{
+    int i; 
+    if(n==p) 
+      return 0;
+    for(i=0; i<_MC_numofneighbour; i++) 
+      if (_MC_neighbour[i] == n) return 0;
+    return 1; 
+}
+
+/* ****************************************************************** */
+/*    The following internal functions implements FIFO queues for     */
+/*    messages. These queues are shared among threads                 */
+/* ****************************************************************** */
+
+static void ** AllocBlock(unsigned int len)
+{
+  void ** blk;
+
+  blk=(void **)g_malloc(len*sizeof(void *));
+  if(blk==(void **)0) {
+    CmiError("Cannot Allocate Memory!\n");
+    abort();
+  }
+  return blk;
+}
+
+static void 
+SpillBlock(void **srcblk, void **destblk, unsigned int first, unsigned int len)
+{
+  memcpy(destblk, &srcblk[first], (len-first)*sizeof(void *));
+  memcpy(&destblk[len-first],srcblk,first*sizeof(void *));
+}
+
+McQueue * McQueueCreate(void)
+{
+  McQueue *queue;
+
+  queue = (McQueue *) g_malloc(sizeof(McQueue));
+  if(queue==(McQueue *)0) {
+    CmiError("Cannot Allocate Memory!\n");
+    abort();
+  }
+  queue->sema = usnewsema(arena, 1);
+  usinitsema(queue->sema, 1);
+  queue->blk = AllocBlock(BLK_LEN);
+  queue->blk_len = BLK_LEN;
+  queue->first = 0;
+  queue->len = 0;
+  queue->maxlen = 0;
+  return queue;
+}
+
+void McQueueAddToBack(McQueue *queue, void *element)
+{
+#ifdef DEBUG
+  printf("[%d] Waiting for lock\n",CmiMyPe());
+#endif
+  uspsema(queue->sema);
+#ifdef DEBUG
+  printf("[%d] Acquired lock\n",CmiMyPe());
+#endif
+  if(queue->len==queue->blk_len) {
+    void **blk;
+
+    queue->blk_len *= 3;
+    blk = AllocBlock(queue->blk_len);
+    SpillBlock(queue->blk, blk, queue->first, queue->len);
+    g_free(queue->blk);
+    queue->blk = blk;
+    queue->first = 0;
+  }
+  queue->blk[(queue->first+queue->len++)%queue->blk_len] = element;
+  if(queue->len>queue->maxlen)
+    queue->maxlen = queue->len;
+  usvsema(queue->sema);
+#ifdef DEBUG
+  printf("[%d] released lock\n",CmiMyPe());
+#endif
+}
+
+
+void * McQueueRemoveFromFront(McQueue *queue)
+{
+  void *element;
+  void *localmsg = (void *) 0;
+  uspsema(queue->sema);
+  element = (void *) 0;
+  if(queue->len) {
+    element = queue->blk[queue->first++];
+    queue->first = (queue->first+queue->blk_len)%queue->blk_len;
+    queue->len--;
+  }
+  usvsema(queue->sema);
+  if(element) {
+#ifdef DEBUG
+    printf("[%d] received message of size %d\n", CmiMyPe(), CmiSize(element));
+#endif
+    localmsg = CmiAlloc(CmiSize(element));
+    memcpy(localmsg, element, CmiSize(element));
+    g_free((char *)element-8);
+  }
+  return localmsg;
+}
diff --git a/src/arch/origin2000/spantree.c b/src/arch/origin2000/spantree.c
new file mode 100644 (file)
index 0000000..69bd68c
--- /dev/null
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 1.1  1997-03-28 17:38:25  milind
+ * Added Origin2000 version.
+ *
+ * Revision 2.6  1995/10/27 21:45:35  jyelon
+ * Changed CmiNumPe --> CmiNumPes
+ *
+ * Revision 2.5  1995/10/25  19:56:05  jyelon
+ * Changed CmiSyncSendFn --> CmiSyncSend
+ *
+ * Revision 2.4  1995/10/19  18:18:24  jyelon
+ * added "converse.h"
+ *
+ * Revision 2.3  1995/09/29  09:50:07  jyelon
+ * CmiGet-->CmiDeliver, added protos, etc.
+ *
+ * Revision 2.2  1995/09/20  15:12:09  sanjeev
+ * CmiSpanTreeChild -> CmiSpanTreeChildren
+ *
+ * Revision 2.1  1995/06/09  21:22:00  gursoy
+ * Cpv macros moved to converse
+ *
+ * Revision 2.0  1995/06/08  16:35:12  gursoy
+ * Reorganized directory structure
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+/* This file contains all the spanning tree functions */
+#include <converse.h>
+
+
+#define MAXSPAN    4          /* The maximum permitted span on 
+                                each node of the spanning tree */
+
+CmiSpanTreeInit()
+{
+}
+
+
+int CmiSpanTreeParent(node)
+int node;
+{
+    if (node == 0)
+         return -1;
+    else return ((node - 1) / MAXSPAN);   /* integer division */
+}
+
+int CmiSpanTreeRoot()
+{
+    return 0;
+}
+
+void CmiSpanTreeChildren(node, children)
+int node, *children;
+{
+    int i;
+
+    for (i = 1; i <= MAXSPAN ; i++)
+       if (MAXSPAN * node + i < CmiNumPes())
+            children[i-1] = node * MAXSPAN + i;
+       else children[i-1] = -1;
+}
+
+
+int CmiNumSpanTreeChildren(node)
+int node;
+{
+    if ((node + 1) * MAXSPAN < CmiNumPes())
+         return MAXSPAN;
+    else if (node * MAXSPAN + 1 >= CmiNumPes())
+        return 0;
+    else return ((CmiNumPes() - 1) - node * MAXSPAN);
+}
+
+CmiSendToSpanTreeLeaves(size, msg)
+int size;
+char * msg;
+{
+    int node;
+
+    for (node = (CmiNumPes() - 2) / MAXSPAN;   /* integer division */
+        node < CmiNumPes(); node++)
+        CmiSyncSend(node, size, msg);
+}
+