Reorganized directory structure
authorRobert Brunner <rbrunner@uiuc.edu>
Fri, 2 Jun 1995 17:24:13 +0000 (17:24 +0000)
committerRobert Brunner <rbrunner@uiuc.edu>
Fri, 2 Jun 1995 17:24:13 +0000 (17:24 +0000)
49 files changed:
src/charmc [new file with mode: 0755]
src/ck-core/acc.c [new file with mode: 0644]
src/ck-core/acc.h [new file with mode: 0644]
src/ck-core/boc.c [new file with mode: 0644]
src/ck-core/boc.doc [new file with mode: 0755]
src/ck-core/c++interface.h [new file with mode: 0644]
src/ck-core/chare.h [new file with mode: 0644]
src/ck-core/ck.c [new file with mode: 0644]
src/ck-core/ck.doc [new file with mode: 0755]
src/ck-core/ckdefs.h [new file with mode: 0644]
src/ck-core/common.c [new file with mode: 0644]
src/ck-core/common.h [new file with mode: 0644]
src/ck-core/communication.h [new file with mode: 0644]
src/ck-core/condsend.c [new file with mode: 0644]
src/ck-core/condsend.h [new file with mode: 0644]
src/ck-core/const.h [new file with mode: 0644]
src/ck-core/dagger.h [new file with mode: 0644]
src/ck-core/default-main.c [new file with mode: 0644]
src/ck-core/dtable.h [new file with mode: 0644]
src/ck-core/env_macros.h [new file with mode: 0644]
src/ck-core/globals.c [new file with mode: 0644]
src/ck-core/globals.h [new file with mode: 0644]
src/ck-core/init.c [new file with mode: 0644]
src/ck-core/init.doc [new file with mode: 0755]
src/ck-core/main.c [new file with mode: 0644]
src/ck-core/main.doc [new file with mode: 0755]
src/ck-core/memstuff.c [new file with mode: 0644]
src/ck-core/mono.c [new file with mode: 0644]
src/ck-core/mono.h [new file with mode: 0644]
src/ck-core/msg_macros.h [new file with mode: 0644]
src/ck-core/prio_macros.h [new file with mode: 0644]
src/ck-core/pseudo.doc [new file with mode: 0755]
src/ck-core/rdonly.c [new file with mode: 0644]
src/ck-core/register.c [new file with mode: 0644]
src/ck-core/stat.c [new file with mode: 0644]
src/ck-core/stat.h [new file with mode: 0644]
src/ck-core/sys_macros.h [new file with mode: 0644]
src/ck-core/table.h [new file with mode: 0644]
src/ck-core/tbl.c [new file with mode: 0644]
src/ck-core/tbl.h [new file with mode: 0644]
src/ck-core/trans_decls.h [new file with mode: 0644]
src/ck-core/trans_defs.h [new file with mode: 0644]
src/ck-core/trans_externs.h [new file with mode: 0644]
src/ck-core/user_macros.h [new file with mode: 0644]
src/ck-core/vid.c [new file with mode: 0644]
src/ck-core/vid.doc [new file with mode: 0755]
src/ck-core/vid.h [new file with mode: 0644]
src/ck-core/wrtone.c [new file with mode: 0644]
src/ck-core/wrtone.h [new file with mode: 0644]

diff --git a/src/charmc b/src/charmc
new file mode 100755 (executable)
index 0000000..b3b9315
--- /dev/null
@@ -0,0 +1,584 @@
+#!/bin/csh -f
+############################################################################
+# RCS INFORMATION:
+#
+#       $RCSfile$
+#       $Author$      $Locker$              $State$
+#       $Revision$        $Date$
+#
+############################################################################
+# DESCRIPTION:
+#
+############################################################################
+# REVISION HISTORY:
+#
+############################################################################
+
+
+##############################################################################
+#
+# Initialize the main controlling variables, then setup error handler
+#
+##############################################################################
+
+set OPTS_CC=
+set OPTS_CPLUS=
+set OPTS_LD=
+set OPTS_CPP=
+set FILES=
+set OBJECTFILES=
+set LIBRARIES=
+set CONVERSE=
+onintr failure
+
+##############################################################################
+#
+# The following section attempts to locate charm.
+#
+##############################################################################
+
+set ORIGDIR=$cwd
+
+# Try to find charm root by looking in directory where charmc is
+
+if ($?CHARMROOT == 0) then
+    set SCRIPT=$0
+    if ($SCRIPT:h != $SCRIPT:t) then
+        cd $SCRIPT:h
+        set SCRIPT=$SCRIPT:t
+    else
+        foreach dir ($path)
+            if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
+                cd $dir
+                break
+            endif
+        end
+    endif
+    while (x`find $SCRIPT -type l -print` == x$SCRIPT)
+        set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
+        if ($SCRIPT:h != $SCRIPT:t) then
+            cd $SCRIPT:h
+            set SCRIPT=$SCRIPT:t
+        endif
+    end
+    cd ..
+    set CHARMROOT=`pwd`
+    if (! -e $CHARMROOT/include/conv-mach.csh) unset CHARMROOT
+    if (! -e $CHARMROOT/lib/libckn-core-notrace.a) unset CHARMROOT
+endif
+
+# Give an error message
+
+if ($?CHARMROOT == 0) then
+    echo ''
+    echo 'Error - cannot find the charm directories.'
+    echo ''
+    echo 'Normally, charmc and the other charm scripts automatically'
+    echo 'locate the charm directory, using the following strategy:'
+    echo ''
+    echo '  Step 1. It looks in the directory specified in $CHARMROOT.'
+    echo ''
+    echo '  Step 2. It looks in the directory from which charmc was run.'
+    echo ''
+    echo '  Step 3. It looks in every directory in your $PATH'
+    echo ''
+    echo 'If it searches all these places, and doesnt find the charm'
+    echo 'files, it will give up.'
+    echo ''
+    goto failure
+    endif
+endif
+
+##############################################################################
+#
+# Parse the arguments
+#
+# Don't do any analysis in here, just the parsing.
+#
+##############################################################################
+
+
+set argindex=1
+while ($argindex <= $#argv)
+    set arg=$argv[$argindex]
+    @ argindex = $argindex + 1
+
+    switch ($arg)
+        case "-machine"
+            set MACHTYPE=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-language"
+            set LANGUAGE=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+       case "-balance"
+            set BALANCE=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-queue"
+            set QUEUE=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-memory"
+            echo "Warning: -memory currently not being dealt with."
+            @ argindex = $argindex + 1
+            breaksw
+
+       case "-execmode"
+            set EXECMODE=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-verbose"
+            set VERBOSE=1
+            breaksw
+
+        case "-save"
+            set SAVE=1
+            breaksw
+
+        case "-cc"
+            set OVERRIDE_CC=( $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-c++"
+            set OVERRIDE_CPLUS=( $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-ld"
+            set OVERRIDE_LD=( $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-cc-option"
+            set OPTS_CC=( $OPTS_CC $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-c++-option"
+            set OPTS_CPLUS=( $OPTS_CPLUS $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-purify"
+            set PURIFY = yes
+            breaksw
+
+        case "-ld-option"
+            set OPTS_LD=( $OPTS_LD $argv[$argindex] )
+            @ argindex = $argindex + 1
+            breaksw
+
+        case "-c":
+            set NOLINK=1
+            breaksw
+
+       case "-o":
+            set OBJECT=$argv[$argindex]
+            @ argindex = $argindex + 1
+            breaksw
+
+       case "-modules":
+           set MOD_LIST = $argv[$argindex]
+           @ argindex = $argindex + 1
+           breaksw
+
+       case "-module_file":
+           set MOD_FILE = $argv[$argindex]
+           @ argindex = $argindex + 1
+           breaksw
+
+        case "-D*"
+            set OPTS_CPP=( $OPTS_CPP "$arg" )
+            set OPTS_CC=( $OPTS_CC "$arg" )
+            set OPTS_CPLUS=( $OPTS_CPLUS "$arg" )
+            breaksw
+
+        case "-I*"
+            set OPTS_CPP=( $OPTS_CPP "$arg" )
+            set OPTS_CC=( $OPTS_CC "$arg" )
+            set OPTS_CPLUS=( $OPTS_CPLUS "$arg" )
+            breaksw
+
+        case "-L*"
+            set OPTS_CC=( $OPTS_CC "$arg" )
+            set OPTS_CPLUS=( $OPTS_CPLUS "$arg" )
+            set OPTS_LD=( $OPTS_LD "$arg" )
+            breaksw
+
+        case "-g"
+            set OPTS_CC=( $OPTS_CC $arg )
+            set OPTS_CPLUS=( $OPTS_CPLUS $arg )
+            set OPTS_LD=( $OPTS_LD $arg )
+            breaksw
+
+        case "-O*"
+            set OPTS_CC=( $OPTS_CC $arg )
+            set OPTS_CPLUS=( $OPTS_CPLUS $arg )
+            breaksw
+
+        case "-l*"
+            set LIBRARIES=( $LIBRARIES $arg )
+            breaksw
+
+        case "-s"
+            set OPTS_LD=( $OPTS_LD $arg )
+            breaksw
+
+        case "-*"
+            echo "passing unrecognized option $arg to all compilers and linkers"
+            set OPTS_CC=( $OPTS_CC $arg )
+            set OPTS_CPLUS=( $OPTS_CPLUS $arg )
+            set OPTS_LD=( $OPTS_LD $arg )
+           set OPTS_CPP=( $OPTS_CPP $arg )
+            breaksw
+
+        case "*.*"
+            set FILES=( $FILES "$arg" )
+            breaksw
+        
+        default:
+            echo "Unrecognized argument $arg"
+            goto failure
+
+    endsw
+end
+
+##############################################################################
+#
+# Check for valid choice of MACHTYPE, and change CHARMROOT if necessary.
+#
+##############################################################################
+
+if ($?MACHTYPE) then
+    if (-d $CHARMROOT/$MACHTYPE) then
+       set CHARMROOT=$CHARMROOT/$MACHTYPE
+    else
+       if (-d $CHARMROOT/../$MACHTYPE) then
+           set CHARMROOT=$CHARMROOT/../$MACHTYPE
+       else
+           echo 'error - there is no installed charm for "'$MACHTYPE'"'
+           goto failure
+       endif
+    endif
+endif
+
+##############################################################################
+#
+# Load machine-specific configuration data, then handle overrides to it.
+#
+##############################################################################
+
+source $CHARMROOT/include/conv-mach.csh
+
+if ($?OVERRIDE_CC) then
+    set CMK_CC[1]=""
+    set CMK_CC = ( $OVERRIDE_CC $CMK_CC )
+endif
+
+if ($?OVERRIDE_CPLUS) then
+    set CMK_CXX[1]=""
+    set CMK_CXX = ( $OVERRIDE_CPLUS $CMK_CXX )
+endif
+
+if ($?OVERRIDE_LD) then
+    set CMK_LD[1]=""
+    set CMK_LD = ( $OVERRIDE_LD $CMK_LD )
+endif
+
+if ($?OVERRIDE_LD) then
+    set CMK_LDXX[1]=""
+    set CMK_LDXX = ( $OVERRIDE_LD $CMK_LDXX )
+endif
+
+##############################################################################
+#
+# Check for valid choice of LANGUAGE
+#
+##############################################################################
+
+if ($?LANGUAGE == 0) set LANGUAGE=charm
+
+switch ($LANGUAGE)
+    case "charm"
+       set LIBCPLUS=cplus-n
+       set LOADER=($CMK_LD)
+        breaksw
+    case "charm++"
+        set LIBCPLUS=cplus-y
+       set LOADER=($CMK_LDXX)
+        breaksw
+    default:
+        echo "charmc: Unrecognized choice of language $LANGUAGE"
+endsw
+
+##############################################################################
+#
+# Check for valid choice of EXECMODE
+# Check for valid choice of QUEUE
+# Check for valid choice of BALANCE
+#
+##############################################################################
+
+if ($?EXECMODE == 0) set EXECMODE=notrace
+
+if (-e $CHARMROOT/lib/libckn-core-$EXECMODE.a) then
+   set LIBCLASS=ckn
+else
+   if (-e $CHARMROOT/lib/libckd-core-$EXECMODE.a) then
+      set LIBCLASS=ckd
+   else
+      echo "charmc : No such execmode $EXECMODE"
+      (cd $CHARMROOT/lib ; ls -al libck?-core-*)
+      goto failure
+   endif
+endif
+
+if ($?QUEUE == 0) set QUEUE=fifo
+
+if (! -e $CHARMROOT/lib/libconv-qs-$QUEUE.a) then
+   echo "No queue strategy $QUEUE"
+   echo "current choices are:
+   (cd $CHARMROOT/lib ; ls -al libconv-qs-*)
+   goto failure
+endif
+
+if ($?BALANCE == 0) set BALANCE=rand
+
+if (! -e $CHARMROOT/lib/lib${LIBCLASS}-ldb-$BALANCE.a) then
+   echo "charmc : Unknown load balancer $BALANCE"
+   (cd $CHARMROOT/lib ; ls -al lib${LIBCLASS}-ldb-*)
+   goto failure
+endif
+
+##############################################################################
+#
+# Check for compatibility among BALANCE, QUEUE, and EXECMODE
+#
+##############################################################################
+
+# Check that execmode is compatible with queue and balance
+
+if ($EXECMODE == replay) then
+    if ($?QUEUE == 0) set QUEUE=replay
+    if ($?BALANCE == 0) set BALANCE=replay
+    if ($QUEUE != replay) then
+        echo "Ignoring -queue $QUEUE, incompatible with -execmode replay"
+    endif
+    if ($BALANCE != replay) then
+        echo "Ignoring -balance $BALANCE, incompatible with -execmode replay"
+    endif
+    set QUEUE=replay
+    set BALANCE=replay
+endif
+
+if ( $BALANCE == btok ) then
+    if ( ($QUEUE != bfifo) && ($QUEUE != bstack) ) then
+        echo "WARNING : btok strategy needs bfifo or bstack queueing strategy"
+    endif
+endif
+
+##############################################################################
+#
+# Compile all specified files
+#
+# All temporary files named *.TMP.* for easy cleanup.
+#
+##############################################################################
+
+cd $ORIGDIR
+
+foreach FILE ($FILES)
+  set BASE=$FILE:r
+  set TMP=$BASE:t.TMP
+  if ($?OBJECT == 0) set OBJECT=$BASE:t
+  if (${BASE}.o != $FILE) then
+      echo "compiling $FILE."
+      /bin/rm -f $BASE.o $BASE.f.o
+  endif
+  switch ($FILE)
+    case "*.p"
+      if ($?VERBOSE) echo "$CMK_CPP $OPTS_CPP -I$CHARMROOT/include $BASE.p > $TMP.cpp"
+      $CMK_CPP $OPTS_CPP -I$CHARMROOT/include $BASE.p > $TMP.cpp
+      if ($?VERBOSE) echo "$CHARMROOT/bin/charmfilter < $TMP.cpp | $CMK_M4 > $TMP.space"
+      $CHARMROOT/bin/charmfilter < $TMP.cpp | $CMK_M4 > $TMP.space
+      if ($?VERBOSE) echo "$CHARMROOT/bin/charmxlat $TMP.space $TMP.c"
+      $CHARMROOT/bin/charmxlat $TMP.space $TMP.c
+      if ($status) goto failure
+      if ($?VERBOSE) echo "$CMK_CC $OPTS_CC -I$CHARMROOT/include -c $TMP.c -o $TMP.o"
+      $CMK_CC $OPTS_CC -I$CHARMROOT/include -c $TMP.c -o $TMP.o
+      if ($status) goto failure
+      if ($?NOLINK) then
+          if ($?VERBOSE) echo "/bin/mv $TMP.o $BASE.o"
+          /bin/mv $TMP.o $BASE.o
+      else
+          set OBJECTFILES=( $OBJECTFILES $TMP.o )
+      endif
+      breaksw
+    case "*.P"
+      echo 'extern "C" {' > $TMP.P.c
+      echo '#include <stdio.h>' >> $TMP.P.c
+      echo '}' >> $TMP.P.c
+      echo '#line 1 "'$BASE.P'"' >> $TMP.P.c
+      /bin/cat $BASE.P >> $TMP.P.c
+      if ($?VERBOSE) echo "$CMK_CPP $OPTS_CPP -I$CHARMROOT/include $TMP.P.c > $TMP.cpp"
+      $CMK_CPP $OPTS_CPP -I$CHARMROOT/include $TMP.P.c > $TMP.cpp
+      if ($?VERBOSE) echo "$CHARMROOT/bin/charmfilter++ $TMP.cpp | $CMK_M4 > $TMP.space"
+      $CHARMROOT/bin/charmfilter++ $TMP.cpp | $CMK_M4 > $TMP.space
+      if ($?VERBOSE) echo "$CHARMROOT/bin/charmxlat++ $TMP.space $TMP.C"
+      $CHARMROOT/bin/charmxlat++ $TMP.space $TMP.C
+      if ($status) goto failure
+      if ($?VERBOSE) echo "$CMK_CXX $OPTS_CPLUS -I$CHARMROOT/include $TMP.C -o $TMP.o"
+      $CMK_CXX $OPTS_CPLUS -I$CHARMROOT/include $TMP.C -o $TMP.o
+      if ($status) goto failure
+      if ($?NOLINK) then
+        if ($?VERBOSE) echo "/bin/mv $TMP.o $BASE.o"
+        /bin/mv $TMP.o $BASE.o
+      else
+        set OBJECTFILES=( $OBJECTFILES $TMP.o )
+      endif
+      breaksw
+    case "*.c"
+      if ($?VERBOSE) echo "$CMK_CC $OPTS_CC -I$CHARMROOT/include -c $BASE.c -o $BASE.o"
+      $CMK_CC $OPTS_CC -I$CHARMROOT/include -c $BASE.c -o $BASE.o
+      if ($status) goto failure
+      if ($?NOLINK == 0) then
+        if ($?VERBOSE) echo "/bin/mv $BASE.o $TMP.o"
+        /bin/mv $BASE.o $TMP.o
+        set OBJECTFILES=( $OBJECTFILES $TMP.o )
+      endif
+      breaksw
+    case "*.C"
+      if ($?VERBOSE) echo "$CMK_CXX $OPTS_CPLUS -I$CHARMROOT/include $BASE.c -o $BASE.o"
+      $CMK_CXX $OPTS_CPLUS -I$CHARMROOT/include $BASE.C -o $BASE.o
+      if ($status) goto failure
+      if ($?NOLINK == 0) then
+        if ($?VERBOSE) echo "/bin/mv $BASE.o $TMP.o"
+        /bin/mv $BASE.o $TMP.o
+        set OBJECTFILES=( $OBJECTFILES $TMP.o )
+      endif
+      breaksw
+    case "*.f"
+    case "*.F"
+    case "*.fc"
+    case "*.FC"
+      echo "charmc: I'm not yet smart enough to compile $FILE"
+      goto failure
+    case "*.o"
+      set OBJECTFILES=( $OBJECTFILES $BASE.o )
+      breaksw
+    default:
+      echo "file with unrecognized extension $FILE"
+      goto failure
+  endsw
+end
+
+
+##############################################################################
+#
+# Create module_init_fn.o
+#
+##############################################################################
+
+if ($?NOLINK) goto success
+
+if (-e module-init-fn.c) mv module-init-fn.c module-init-fn.bak
+
+if (( $?MOD_LIST == 0) && ( $?MOD_FILE )) then
+  if (! -e $MOD_FILE) then
+    echo 'No such module file '$MOD_FILE
+    goto failure
+  endif
+  set MOD_LIST=(`cat $MOD_FILE`)
+endif
+
+if (( $?MOD_LIST == 0) && ( -e module.list )) then
+  set MOD_LIST=(`cat module.list`)
+endif
+
+if ( $?MOD_LIST ) then
+    echo Modules: $MOD_LIST
+    echo " " > module-init-fn.c
+    foreach i ( $MOD_LIST)
+      echo 'extern void _CK_'$i'_init();' >> module-init-fn.c
+    end
+    echo '_CK_module_init_fn()' >> module-init-fn.c
+      echo '{' >> module-init-fn.c
+    foreach i ( $MOD_LIST)
+      echo '      _CK_'$i'_init();' >> module-init-fn.c
+    end
+    echo '}' >> module-init-fn.c
+    $CMK_CC $OPTS_CC -c module-init-fn.c
+    set OBJECTFILES = ($OBJECTFILES module-init-fn.o)
+else
+    echo 'Note: no module list specified.'
+endif
+
+##############################################################################
+#
+# Link
+#
+##############################################################################
+
+link:
+
+echo "linking $OBJECT with -language $LANGUAGE"
+
+set LIBRARIES = ($LIBRARIES \
+       -l${LIBCLASS}-core-$EXECMODE \
+       -l${LIBCLASS}-ldb-$BALANCE \
+       -l${LIBCLASS}-$LIBCPLUS \
+       -lconv-core \
+       -lconv-qs-$QUEUE \
+       $CMK_LIBS -lm)
+
+if ($?MAINOBJ) then
+   set OBJECTFILES=($MAINOBJ $OBJECTFILES)
+else
+   set LIBRARIES=(-l${LIBCLASS}-defmain $LIBRARIES)
+endif
+
+if ($?VERBOSE) echo "$LOADER $OPTS_LD -o $OBJECT $OBJECTFILES -L$CHARMROOT/lib $LIBRARIES"
+$LOADER $OPTS_LD -o $OBJECT $OBJECTFILES -L$CHARMROOT/lib $LIBRARIES
+if ($status) goto failure
+
+if (-e $CHARMROOT/bin/conv-host) then
+    /bin/rm -f conv-host
+    /bin/ln -s $CHARMROOT/bin/conv-host conv-host
+endif
+
+goto success
+
+########################################################################
+#
+# Clean up files and exit
+#
+########################################################################
+
+
+success:
+    set STATUS=0
+    goto end
+
+failure:
+    echo 'charmc: aborting.'
+    set STATUS=1
+    goto end
+
+end:
+    if ($?SAVE == 0) then
+        foreach FILE ($FILES)
+            set BASE=$FILE:r
+            set TMP=$BASE:t.TMP
+            /bin/rm -f $TMP.P.c $TMP.C $TMP.cpp $TMP.space $TMP.o
+            /bin/rm -f $TMP.c $TMP.c.0.h $TMP.c.1.h $TMP.c.2.h $BASE:t.headers
+        end
+    endif
+    exit ($STATUS)
diff --git a/src/ck-core/acc.c b/src/ck-core/acc.c
new file mode 100644 (file)
index 0000000..8f14892
--- /dev/null
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:55:22  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/12/01  23:57:49  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:39:00  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "acc.h"
+
+void *GetAccMsgPtr() ;
+extern void * CPlus_CallAccInit() ;
+extern void * CPlus_GetAccMsgPtr() ;
+extern void CPlus_CallCombineFn() ;
+extern void CPlus_SetAccId() ;
+
+CollectValue(bocnum, EP, CID)
+int bocnum;
+int EP;
+ChareIDType *CID;
+{
+       ACC_COLLECT_MSG *msg;
+
+       msg = (ACC_COLLECT_MSG *) CkAllocMsg(sizeof(ACC_COLLECT_MSG));
+       msg->EP = EP; 
+       msg->cid = *CID;
+       if (CmiMyPe() == 0)
+               ACC_CollectFromNode_Fn(msg, GetBocDataPtr(bocnum)); 
+       else
+               GeneralSendMsgBranch(ACC_CollectFromNode_EP, msg,
+                       0, IMMEDIATEcat, BocMsg, bocnum);
+}
+
+
+ACC_CollectFromNode_Fn(msg, mydata)
+ACC_COLLECT_MSG *msg;
+ACC_DATA *mydata;
+{
+       int i;
+       DummyMsg *tmsg;
+
+       if (mydata->AlreadyDone)
+               CmiPrintf("***ERROR*** Accumulation already done\n");   
+       else
+       {
+               mydata->EP = msg->EP;
+               mydata->CID = msg->cid;
+               tmsg = (DummyMsg *) CkAllocMsg(sizeof(DummyMsg));
+               mydata->AlreadyDone = 1;
+               GeneralBroadcastMsgBranch(ACC_LeafNodeCollect_EP, tmsg,
+                       IMMEDIATEcat, BroadcastBocMsg,
+                       ((BOC_BLOCK *) mydata - 1)->boc_num);
+       }
+}
+
+
+
+
+ACC_LeafNodeCollect_Fn(msg, mydata)
+DummyMsg *msg;
+ACC_DATA *mydata;
+{
+
+       if (CmiNumSpanTreeChildren(mydata->Penum) == 0)
+       {
+               if (mydata->Penum == CmiSpanTreeRoot())
+                       SendMsg(mydata->EP,  GetAccMsgPtr(mydata),
+                               &(mydata->CID)); 
+               else
+               {
+TRACE(CmiPrintf("[%d] ACC_NodeCollect : Sent message to parent\n",
+       CmiMyPe()));
+                       mydata->Penum = CmiSpanTreeParent(mydata->Penum);
+                       GeneralSendMsgBranch(ACC_InteriorNodeCollect_EP, 
+                                       GetAccMsgPtr(mydata), mydata->Penum,
+                                       IMMEDIATEcat, BocMsg,
+                                       ((BOC_BLOCK *) mydata - 1)->boc_num);
+               }
+       }
+}
+
+
+
+ACC_InteriorNodeCollect_Fn(msg, mydata)
+char *msg;
+ACC_DATA *mydata;
+{
+
+       if ( IsCharmPlusPseudo(mydata->id) ) 
+               CPlus_CallCombineFn(mydata->dataptr,msg) ;
+       else 
+               (*(PseudoTable[mydata->id].pseudo_type.acc.combinefn))(mydata->dataptr, msg);
+       mydata->NumChildren--;
+       if (mydata->NumChildren <= 0)
+       {
+               if (mydata->Penum == CmiSpanTreeRoot())
+                       SendMsg(mydata->EP, GetAccMsgPtr(mydata),
+                               &(mydata->CID)); 
+               else
+               {
+TRACE(CmiPrintf("[%d] ACC_NodeCollect : Sent message to parent\n",
+               CmiMyPe()));
+                       mydata->Penum = CmiSpanTreeParent(mydata->Penum);
+                       GeneralSendMsgBranch(ACC_InteriorNodeCollect_EP, 
+                                       GetAccMsgPtr(mydata), mydata->Penum,
+                                       IMMEDIATEcat, BocMsg,
+                                       ((BOC_BLOCK *) mydata - 1)->boc_num);
+               }
+       }
+}
+
+
+AccIDType CreateAcc(id, initmsg, ReturnEP, ReturnID)
+int id;
+void *initmsg;
+EntryPointType ReturnEP;
+ChareIDType *ReturnID;
+{
+       ChareNumType boc;
+       ENVELOPE *envelope = (ENVELOPE *) ENVELOPE_UPTR(initmsg);
+
+       SetEnv_other_id(envelope, id);
+TRACE(CmiPrintf("[%d] CreateAcc: id=%d\n", CmiMyPe(), id));
+       boc = GeneralCreateBoc(sizeof(ACC_DATA), ACC_BranchInit_EP,
+                        initmsg, ReturnEP, ReturnID);
+TRACE(CmiPrintf("[%d] CreateAcc: boc = %d\n", CmiMyPe(), (AccIDType ) boc));
+       return((AccIDType) boc);
+}
+
+
+ACC_BranchInit_Fn(msg, mydata)
+void *msg;
+ACC_DATA *mydata; 
+{
+       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
+       int id = GetEnv_other_id(env);
+
+TRACE(CmiPrintf("[%d] ACC_BranchInit : id = %d\n", CmiMyPe(), id));
+
+       mydata->id = id; 
+       mydata->AlreadyDone = 0;
+       mydata->Penum = CmiMyPe();
+       mydata->NumChildren = CmiNumSpanTreeChildren(mydata->Penum) ;   
+
+       if ( IsCharmPlusPseudo(id) ) {
+           mydata->dataptr = CPlus_CallAccInit(id, msg) ;
+           CPlus_SetAccId(mydata->dataptr,MyBocNum(mydata)) ;
+       }
+       else 
+           mydata->dataptr = (void *) (*(PseudoTable[id].initfn))(NULL, msg);
+
+TRACE(CmiPrintf("[%d] ACC_BranchInit : NumChildren = %d\n",
+       CmiMyPe(),  mydata->NumChildren));
+}
+
+AccAddSysBocEps()
+{
+       EpTable[ACC_CollectFromNode_EP] = ACC_CollectFromNode_Fn;
+       EpTable[ACC_LeafNodeCollect_EP] = ACC_LeafNodeCollect_Fn;
+       EpTable[ACC_InteriorNodeCollect_EP] = ACC_InteriorNodeCollect_Fn;
+       EpTable[ACC_BranchInit_EP] = ACC_BranchInit_Fn;
+}
+
+
+void * _CK_9GetAccDataPtr(accdata)
+ACC_DATA * accdata; 
+{
+       return(accdata->dataptr);
+}
+
+
+FUNCTION_PTR _CK_9GetAccumulateFn(accdata)
+ACC_DATA * accdata; 
+{
+       return(PseudoTable[accdata->id].pseudo_type.acc.addfn);
+}
+
+
+void * GetAccMsgPtr(mydata)
+ACC_DATA *mydata ;
+{
+/* In Charm++, the dataptr points to the accumulator object, and the
+   actual data (in the form of a message as for Charm) is a field inside 
+   the object, which is accessed through the _CK_GetMsgPtr() generated
+   by the translator */
+       if ( IsCharmPlusPseudo(mydata->id) ) 
+               return(CPlus_GetAccMsgPtr(mydata->dataptr)) ;
+       else
+               return(mydata->dataptr) ;       
+}
+
diff --git a/src/ck-core/acc.h b/src/ck-core/acc.h
new file mode 100644 (file)
index 0000000..8eab194
--- /dev/null
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:24:27  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:09  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*      Authors: Wayne Fenton, Balkrishna Ramkumar, Vikram A. Saletore    */
+/*                    Amitabh B. Sinha  and  Laxmikant V. Kale            */
+/*              (C) Copyright 1990 The Board of Trustees of the           */
+/*                          University of Illinois                        */
+/*                           All Rights Reserved                          */
+/*                                                                        */
+/**************************************************************************/
+
+typedef int AccIDType;
+
+typedef struct {
+       int id;
+       int Penum;
+       char *dataptr;
+       int AlreadyDone;
+       ChareIDType CID;
+       int NumChildren;
+       EntryPointType EP;
+} ACC_DATA;
+
+typedef struct {
+       ChareIDType cid;
+       EntryPointType EP;      
+} ACC_COLLECT_MSG;
+
+FUNCTION_PTR _CK_9GetAccumulateFn();
+void * _CK_9_GetAccDataPtr();
diff --git a/src/ck-core/boc.c b/src/ck-core/boc.c
new file mode 100644 (file)
index 0000000..fc338f3
--- /dev/null
@@ -0,0 +1,549 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.8  1995/05/09  20:04:52  milind
+ * Corrected the SP1 fboc bug.
+ *
+ * Revision 1.7  1995/04/23  20:52:27  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.6  1995/04/13  20:52:44  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.5  1995/03/25  18:24:18  sanjeev
+ * ,
+ *
+ * Revision 1.4  1995/03/24  16:41:50  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.3  1995/03/17  23:36:38  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.2  1994/12/01  23:55:42  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:52  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+
+#define MAXBOC 15
+
+typedef struct msg_element {
+        int ref;
+        int size;
+        void *msg;
+        ChareNumType ep;
+        struct msg_element *next;
+} MSG_ELEMENT;
+
+typedef struct bocdata_queue_element {
+       ChareNumType bocNum;
+       void *dataptr;
+       struct bocdata_queue_element *next;
+} BOCDATA_QUEUE_ELEMENT;
+
+typedef struct bocid_message_count {
+       int count;
+       ChareNumType bocnum;
+       ChareIDType ReturnID;
+       EntryPointType ReturnEP;
+       struct bocid_message_count *next;
+} BOCID_MESSAGE_COUNT;
+
+int number_dynamic_boc = 1;
+MSG_ELEMENT * DynamicBocMsgList; 
+BOCDATA_QUEUE_ELEMENT *BocDataTable[MAXBOC];
+BOCID_MESSAGE_COUNT *BocIDMessageCountTable[MAXBOC];
+
+InitializeDynamicBocMsgList()
+{
+       DynamicBocMsgList = (MSG_ELEMENT *) NULL;
+}
+
+InitializeBocDataTable()
+{
+       int i;
+
+       for (i=0; i<MAXBOC; i++)
+               BocDataTable[i] = (BOCDATA_QUEUE_ELEMENT *) NULL;
+}
+
+InitializeBocIDMessageCountTable()
+{
+       int i;
+
+       for (i=0; i<MAXBOC; i++)
+               BocIDMessageCountTable[i] = (BOCID_MESSAGE_COUNT *) NULL;
+}
+
+GetDynamicBocMsg(ref, msg, ep, size)
+int ref;
+void **msg;
+ChareNumType *ep;
+int *size;
+{
+       MSG_ELEMENT * previous = NULL;
+       MSG_ELEMENT * temp = DynamicBocMsgList; 
+       
+       while (temp != NULL)
+       {
+               if (temp->ref == ref)
+               {
+                       *msg = temp->msg;
+                       *ep = temp->ep;
+                       *size = temp->size;
+
+TRACE(CmiPrintf("[%d] GetDynamicBocMsg: ref=%d, ep=%d, size=%d\n",
+               CmiMyPe(), ref, temp->ref, temp->size)); 
+       
+                       if (previous == NULL)
+                               DynamicBocMsgList = temp->next; 
+                       else
+                               previous->next = temp->next;
+                       CmiFree(temp);
+                       return;
+               }
+               else
+               {
+                       previous = temp;
+                       temp = temp->next;
+               }
+       }
+       CmiPrintf("[%d] *** ERROR *** Could not locate return address for dynamic creation %d.\n", CmiMyPe(), ref);
+}
+
+
+void * GetBocDataPtr(bocNum)
+ChareNumType bocNum;
+{
+       int index;
+       BOCDATA_QUEUE_ELEMENT *element;
+
+
+       index = bocNum % MAXBOC;
+       element = BocDataTable[index];
+
+TRACE(CmiPrintf("[%d] GetBocDataPtr: bocNum=%d, index=%d, element=0x%x\n",
+                CmiMyPe(), bocNum, index, element));
+
+       while (element != NULL)
+       {
+               if (element->bocNum == bocNum)
+                       return(element->dataptr);
+               else
+                       element = element->next;
+       }
+       CmiPrintf("[%d] *** ERROR *** Unable to locate BOC %d data ptr.\n",
+               CmiMyPe(),  bocNum);
+}
+
+
+
+BOCID_MESSAGE_COUNT * GetBocIDMessageCount(bocnum)
+ChareNumType bocnum;
+{
+       int index;
+       BOCID_MESSAGE_COUNT *element;
+
+       index = bocnum % MAXBOC;
+       element = BocIDMessageCountTable[index];
+       while (element != NULL)
+       {
+               if (element->bocnum == bocnum)
+                       return(element);
+               else    
+                       element = element->next;
+       }
+       TRACE(CmiPrintf("[%d] *** ERROR *** Incorrect boc number %d in GetBocIDMessageCount\n", 
+                       CmiMyPe(), bocnum));
+       return(NULL);
+}
+
+SetDynamicBocMsg(msg,ep,size)
+void *msg;
+ChareNumType ep;
+int size;
+{
+       MSG_ELEMENT * new; 
+       
+       new = (MSG_ELEMENT *) CmiAlloc(sizeof(MSG_ELEMENT));
+       new->ref = number_dynamic_boc++;
+       new->msg = msg;
+       new->ep = ep;
+       new->size = size;
+       new->next = DynamicBocMsgList; 
+       DynamicBocMsgList = new; 
+
+TRACE(CmiPrintf("[%d] SetDynamicBocMsg: ref=%d, ep=%d, size=%d\n",
+       CmiMyPe(), new->ref, new->ep, new->size));
+
+       return (new->ref);
+}
+
+SetBocDataPtr(bocNum, ptr)
+ChareNumType bocNum;
+void *ptr;
+{
+       int index;
+       BOCDATA_QUEUE_ELEMENT *new;
+       BOCDATA_QUEUE_ELEMENT *element;
+
+
+       index = bocNum % MAXBOC;
+       new = (BOCDATA_QUEUE_ELEMENT *) CmiAlloc(sizeof(BOCDATA_QUEUE_ELEMENT));
+       CkMemError(new);
+       new->bocNum = bocNum;
+       new->dataptr = ptr;
+       element = BocDataTable[index];
+       new->next = element;    
+       BocDataTable[index] = new;
+
+TRACE(CmiPrintf("[%d] SetBocDataPtr: bocNum=%d, index=%d, new=0x%x\n",
+                CmiMyPe(), bocNum, index, new));
+}
+
+
+BOCID_MESSAGE_COUNT * SetBocIDMessageCount(bocnum, count, ReturnEP, ReturnID)
+ChareNumType bocnum;
+int count;
+EntryPointType ReturnEP;
+ChareIDType *ReturnID;
+{
+       int index;
+       BOCID_MESSAGE_COUNT *new, *element;
+
+       index = bocnum % MAXBOC;
+       new = (BOCID_MESSAGE_COUNT *) CmiAlloc(sizeof(BOCID_MESSAGE_COUNT));
+       CkMemError(new);
+       new->bocnum = bocnum;
+       new->count = count;
+       new->ReturnEP = ReturnEP;
+       if (ReturnID != NULL) 
+               new->ReturnID = *ReturnID;
+       element = BocIDMessageCountTable[index];
+       new->next = element;
+       BocIDMessageCountTable[index] = new;
+       return(new);
+}
+
+
+
+
+BOC_BLOCK * CreateBocBlock(sizeData)
+int sizeData;
+{
+       BOC_BLOCK *p;
+
+       p =  (BOC_BLOCK *) CmiAlloc( sizeof(BOC_BLOCK) + sizeData );
+       CkMemError(p);
+       return(p);
+}
+
+
+
+ChareNumType GeneralCreateBoc(SizeData, Entry, Msg, ReturnEP, ReturnID)
+int SizeData;
+EntryNumType Entry;
+void *Msg;
+EntryNumType ReturnEP;
+ChareIDType *ReturnID;
+{
+       ENVELOPE *env ;
+
+TRACE(CmiPrintf("[%d] GeneralCreateBoc: SizeData=%d, Entry=%d, ReturnEP=%d\n",
+               CmiMyPe(), SizeData, Entry, ReturnEP));
+
+       env = (ENVELOPE *) ENVELOPE_UPTR(Msg);
+       SetEnv_category(env, USERcat);
+       SetEnv_destPeFixed(env, 1);
+       SetEnv_destPE(env, (ALL_NODES_EXCEPT_ME));
+
+       if ((CmiMyPe() == 0)  || InsideDataInit)
+       {
+               SetEnv_sizeData(env, SizeData);
+               SetEnv_boc_num(env, ++currentBocNum);
+               SetEnv_EP(env, Entry);
+       }
+       if (InsideDataInit)
+       /* static boc creation */
+       {
+               int executing_boc_num; 
+
+               SetEnv_msgType(env, BocInitMsg);
+               trace_creation(GetEnv_msgType(env), Entry, env);
+               CkCheck_and_BroadcastNoFree(env, Entry);
+               /* env becomes the usrMsg, hence should not be freed by us */
+               executing_boc_num = ProcessBocInitMsg(env);
+               if (ReturnEP >= 0)
+               {
+                       ChareNumType *msg;
+
+                       msg = (ChareNumType *)
+                                CkAllocMsg(sizeof(ChareNumType));
+                       *msg = currentBocNum;
+                       SendMsg(ReturnEP, msg, ReturnID); 
+               }
+               return(currentBocNum);
+       }
+       else
+       /* dynamic boc creation */
+       {
+               if (CmiMyPe() == 0)
+               {
+                       BOCID_MESSAGE_COUNT *element;
+
+                       element = SetBocIDMessageCount(currentBocNum, 
+                                       CmiNumSpanTreeChildren(CmiMyPe()),
+                                       ReturnEP, ReturnID);
+                       SetEnv_msgType(env, DynamicBocInitMsg);
+
+                       trace_creation(GetEnv_msgType(env), Entry, env);
+                       CkCheck_and_BroadcastNoFree(env, Entry);
+
+                       CmiSetHandler(env,CallProcessMsg_Index) ;
+                       CsdEnqueue(env);
+                       QDCountThisCreation(Entry, USERcat, DynamicBocInitMsg, CmiNumPe());
+
+TRACE(CmiPrintf("[%d] GeneralCreateBoc: bocdata=0x%x\n", CmiMyPe(), element));
+               }
+               else
+               {
+                       DYNAMIC_BOC_REQUEST_MSG *msg;
+                                       
+                       msg = (DYNAMIC_BOC_REQUEST_MSG *) 
+                               CkAllocMsg(sizeof(DYNAMIC_BOC_REQUEST_MSG));
+                       msg->source = CmiMyPe();
+                       msg->ep = ReturnEP;
+                       msg->id = *ReturnID;
+                       msg->ref = SetDynamicBocMsg(Msg, Entry, SizeData);
+
+                       GeneralSendMsgBranch(OtherCreateBoc_EP, msg,
+                               0, IMMEDIATEcat, BocMsg,
+                               DynamicBocNum);
+               }
+       }
+}
+
+MyBocNum(mydata)
+void *mydata;
+{
+       BOC_BLOCK * boc_block = (BOC_BLOCK * ) ((char *) mydata - sizeof(BOC_BLOCK));
+
+       return(boc_block->boc_num);
+}
+
+MyBranchID(pChareID, mydata)
+ChareIDType *pChareID;
+void *mydata;
+{
+       SetID_onPE((*pChareID), CmiMyPe());
+       SetID_isBOC((*pChareID), 1);
+       SetID_boc_num((*pChareID), MyBocNum(mydata));
+}
+
+GeneralSendMsgBranch(ep, msg, destPe, category, type, bocnum)
+EntryPointType ep;
+void *msg;
+PeNumType destPe;
+MsgCategories category;
+MsgTypes type;
+ChareNumType bocnum;
+{
+       ENVELOPE *env;
+
+       env  = ENVELOPE_UPTR(msg);
+
+       SetEnv_destPE(env, destPe);
+       SetEnv_category(env, category);
+       SetEnv_msgType(env, type);
+       SetEnv_destPeFixed(env, 1);
+       SetEnv_boc_num(env, bocnum);
+       SetEnv_EP(env, ep);
+
+TRACE(CmiPrintf("[%d] GeneralSend: type=%d, msgType=%d\n",
+               CmiMyPe(), type, GetEnv_msgType(env)));
+
+       if (bocnum >= NumSysBoc)
+               nodebocMsgsCreated++;
+
+
+       trace_creation(GetEnv_msgType(env), ep, env);
+       CkCheck_and_Send(env, ep);
+       QDCountThisCreation(ep, category, type, 1);
+}
+
+
+
+GeneralBroadcastMsgBranch(ep, msg, category, type, bocnum)
+EntryPointType ep;
+void *msg;
+MsgCategories category;
+MsgTypes type;
+ChareNumType bocnum;
+{
+       ENVELOPE *env;
+
+       env = ENVELOPE_UPTR(msg);
+
+       SetEnv_destPE(env, ALL_NODES);
+       SetEnv_category(env, category);
+       SetEnv_msgType(env, type);
+       SetEnv_destPeFixed(env, 1);
+       SetEnv_boc_num(env, bocnum);
+       SetEnv_EP(env, ep);
+
+TRACE(CmiPrintf("[%d] GeneralBroadcast: type=%d, msgType=%d\n",
+               CmiMyPe(), type, GetEnv_msgType(env)));
+
+       if (bocnum >= NumSysBoc)
+               nodebocMsgsCreated+=CmiNumPe();
+
+       trace_creation(GetEnv_msgType(env), ep, env);
+       CkCheck_and_BroadcastAll(env, ep); /* Asynchronous broadcast */
+       QDCountThisCreation(ep, category, type, CmiNumPe());
+}
+
+
+RegisterDynamicBocInitMsg(bocnumptr, mydata)
+ChareNumType *bocnumptr;
+void *mydata;
+{
+       ChareNumType *msg;
+       int mype = CmiMyPe();
+       BOCID_MESSAGE_COUNT  * bocdata = GetBocIDMessageCount(*bocnumptr);
+
+TRACE(CmiPrintf("[%d] RegisterDynamicBoc: bocnum=%d, bocdata=0x%x\n",
+                CmiMyPe(), *bocnumptr, bocdata));
+       if (bocdata == NULL)
+               bocdata = SetBocIDMessageCount(*bocnumptr,
+                               CmiNumSpanTreeChildren(mype), -1, NULL);
+       bocdata->count--;
+
+       if (bocdata->count < 0)
+       {
+               msg = (ChareNumType *) CkAllocMsg(sizeof(ChareNumType));
+               *msg = *bocnumptr;
+
+               if (mype == 0)
+               {
+                       if (bocdata->ReturnEP >= 0)
+                               SendMsg(bocdata->ReturnEP, msg,
+                                       &bocdata->ReturnID);
+               }
+               else
+                       GeneralSendMsgBranch(RegisterDynamicBocInitMsg_EP, msg,
+                               CmiSpanTreeParent(mype), IMMEDIATEcat, BocMsg,
+                               DynamicBocNum);
+       }
+}
+
+
+OtherCreateBoc(msg, mydata)
+DYNAMIC_BOC_REQUEST_MSG *msg;
+char *mydata;
+{
+       DYNAMIC_BOC_NUM_MSG *tmsg;
+        BOCID_MESSAGE_COUNT *element;
+
+        element = SetBocIDMessageCount(++currentBocNum,
+                                        CmiNumSpanTreeChildren(CmiMyPe()),
+                                        msg->ep, &(msg->id));
+       tmsg = (DYNAMIC_BOC_NUM_MSG *) CkAllocMsg(sizeof(DYNAMIC_BOC_NUM_MSG)); 
+       tmsg->boc = currentBocNum;
+       tmsg->ref = msg->ref;
+
+TRACE(CmiPrintf("[%d] OtherCreateBoc: boc=%d, ref=%d\n",
+       CmiMyPe(), tmsg->boc, tmsg->ref));
+
+       GeneralSendMsgBranch(InitiateDynamicBocBroadcast_EP, tmsg,
+                                msg->source, IMMEDIATEcat, BocMsg,
+                                DynamicBocNum);
+}
+
+InitiateDynamicBocBroadcast(msg, mydata)
+DYNAMIC_BOC_NUM_MSG *msg;
+char *mydata;
+{
+       int size;
+       void *tmsg;
+        ENVELOPE * env;
+       ChareNumType ep;
+
+       GetDynamicBocMsg(msg->ref, &tmsg, &ep, &size); 
+
+TRACE(CmiPrintf("[%d] InitiateDynamicBocBroadcast: ref=%d, boc=%d, ep=%d, size=%d\n",
+               CmiMyPe(), msg->ref, msg->boc, ep, size));
+
+        env = (ENVELOPE *) ENVELOPE_UPTR(tmsg);
+        SetEnv_category(env, USERcat);
+        SetEnv_destPeFixed(env, 1);
+        SetEnv_destPE(env, (ALL_NODES_EXCEPT_ME));
+        SetEnv_sizeData(env, size);
+        SetEnv_boc_num(env, msg->boc);
+        SetEnv_EP(env, ep);
+        SetEnv_msgType(env, DynamicBocInitMsg);
+
+       trace_creation(GetEnv_msgType(env), ep, env);
+        CkCheck_and_BroadcastAll(env, ep);
+
+        QDCountThisCreation(ep, USERcat, DynamicBocInitMsg,CmiNumPe());
+
+}
+
+DynamicBocInit()
+{
+       BOC_BLOCK *bocBlock;
+
+       /* Create a dummy block */
+       bocBlock = (BOC_BLOCK *) CreateBocBlock(sizeof(int));
+       bocBlock->boc_num = DynamicBocNum;
+       SetBocDataPtr(DynamicBocNum, (void *) (bocBlock + 1));
+}
+
+
+DynamicAddSysBocEps()
+{
+       EpTable[RegisterDynamicBocInitMsg_EP] = RegisterDynamicBocInitMsg;
+       EpTable[OtherCreateBoc_EP] = OtherCreateBoc;
+       EpTable[InitiateDynamicBocBroadcast_EP] = 
+                               InitiateDynamicBocBroadcast;
+}
+
+
+
+
+
+
+ChareNumType CreateBoc(id, Entry, Msg, ReturnEP, ReturnID)
+int id;
+EntryNumType Entry;
+void *Msg;
+EntryNumType ReturnEP;
+ChareIDType *ReturnID;
+{
+       if ( IsCharmPlus(Entry) )
+               return GeneralCreateBoc(id, Entry, Msg, ReturnEP, ReturnID);
+       else
+               return GeneralCreateBoc(ChareSizesTable[id], Entry, Msg,
+                                                       ReturnEP, ReturnID);
+}
+
diff --git a/src/ck-core/boc.doc b/src/ck-core/boc.doc
new file mode 100755 (executable)
index 0000000..6c49093
--- /dev/null
@@ -0,0 +1,20 @@
+       The file node_boc.c contains the functions pertaining to 
+branch office chares. Also included are some of the broadcast and
+initialization functions.
+
+       The following procedures appear in this file :
+               1. NodeSysBocInit
+               2. HostSysBocInit
+               3. CreateBoc
+               4. BroadcastCount
+               5. BroadcastMsgBranch
+               6. SendMsgBranch        
+
+       NodeSysBocInit and HostSysBocInit are the functions that 
+initialize the branches of the system branch office chares.
+       CreateBoc is used to create the data areas for the branches of
+ user branch office chares.
+       Both the Broadcasts work similarly. The important point to
+node is that the machines broadcast does not involve sending a message
+to oneself; these messages are enqueued in the local queue, from
+which messages are picked up by the NodePumpMsgs in ck.
diff --git a/src/ck-core/c++interface.h b/src/ck-core/c++interface.h
new file mode 100644 (file)
index 0000000..2e471fc
--- /dev/null
@@ -0,0 +1,259 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.6  1995/05/04  22:11:15  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.4  1994/12/10  19:00:55  sanjeev
+ * added extern decls for register fns
+ *
+ * Revision 1.3  1994/12/02  00:01:57  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:31:26  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:49  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+#ifndef C_PLUS_INTERFACE_H
+#define C_PLUS_INTERFACE_H
+
+/*  #define BASE_EP_NUM 0x00008001     */
+
+#define NULL_EP -1
+
+typedef int MAGIC_NUMBER_TYPE ;
+
+extern "C" void CollectValue(int, int, ChareIDType *) ;
+extern "C" void * MonoValue(int) ;
+
+class _CK_Object ;
+
+/* EPTYPE is no longer used  : SANJEEV, Jan 5
+ * EPTYPE is a pointer to a member function of a chare 
+ * typedef void (_CK_Object::*EPTYPE)(void *) ;  
+ */
+
+class _CK_Object {  /* Top level chare object at root of chare hierarchy */
+public:
+       ChareIDType thishandle ;   
+       /* This is put in by the translator for use by Charm */
+
+       _CK_Object() {}
+
+       _CK_Object(MAGIC_NUMBER_TYPE magic) {
+               SetID_onPE(thishandle, CmiMyPe());
+               SetID_isVID(thishandle, 0);
+               SetID_isBOC(thishandle, 0);
+       
+               SetID_chare_magic_number(thishandle,(int)magic) ;
+               SetID_chareBlockPtr(thishandle, ((CHARE_BLOCK *)this));
+       }
+
+/*     virtual void CallEP(EPTYPE EpPtr, void *msg)
+ *      {
+ *              (this->*EpPtr)(msg) ;
+ *      }
+ *
+ *     virtual void SwitchEP(int EpIndex, void * msg) = 0 ; 
+ */
+} ;
+
+
+
+class _CK_BOC : public _CK_Object {  /* top level BOC object */
+
+public:
+       int _CK_MyBocNum ;  /* BocNum of this instance of the BOC */
+       int thishandle ;  /* also stores BocNum */
+
+       _CK_BOC() {}
+       _CK_BOC(MAGIC_NUMBER_TYPE mn) : _CK_Object(mn) {}
+
+       void setBocNum(int num) {
+               thishandle = _CK_MyBocNum = num ;
+       }
+
+/*     virtual void SwitchEP(int EpIndex, void * msg) = 0 ;   */
+} ;
+
+
+class _CK_Accumulator { /* top level Accumulator object */
+
+public:
+       int _CK_MyId ;
+
+       virtual void * _CK_GetMsgPtr() = 0 ;
+
+       virtual void _CK_Combine(void *) = 0 ;
+
+       void CollectValue(int EpNum, ChareIDType cid)
+       {
+               ::CollectValue(_CK_MyId, EpNum, &cid) ; 
+               /* in node_acc.c */
+       }
+} ;
+
+class _CK_Monotonic { /* top level Monotonic object */
+
+public:
+       int _CK_MyId ;
+
+       virtual void * _CK_GetMsgPtr() = 0 ;
+
+       virtual void _CK_SysUpdate(void *) = 0 ;  /* called by system */
+} ;
+
+
+
+/* EPFnType is a pointer to a _CK_call_Chare_EP() function */
+typedef void (*EPFnType)(void *, _CK_Object *) ;
+
+/* CHAREFNTYPE is a pointer to a _CK_create_ChareName() function */
+typedef _CK_Object * (*CHAREFNTYPE)(MAGIC_NUMBER_TYPE) ;
+
+/* BOCFNTYPE is a pointer to a _CK_create_BocName() function */
+typedef _CK_BOC * (*BOCFNTYPE)(void) ;
+
+/* ACCFNTYPE is a pointer to a _CK_create_AccName() function */
+typedef void * (*ACCFNTYPE)(void *) ;
+
+/* ALLOCFNTYPE is a pointer to a _CK_alloc_MsgName() function */
+typedef void * (*ALLOCFNPTR)(int, int, int*, int) ;
+
+/*
+struct argc_argv {
+    int argc ;
+    char **argv ;
+} ;
+*/
+
+
+/* this is the handle of the main chare, used in place of MainChareID */
+extern ChareIDType mainhandle ;
+extern ChareIDType NULL_HANDLE ;
+
+
+/* These are the external definitions for all Charm calls */
+
+/* This is generated by the translator function */
+extern int _CK_FindLocalID(int *, int *, int, int) ;
+
+/* These are C++ runtime system functions */
+/*
+extern void CPlus_MyChareID(ChareIDType *) ;
+extern void CPlus_MainChareID(ChareIDType *) ;
+extern void CPlus_MyBranchID(ChareIDType *, int) ;
+*/
+extern void CPlus_ChareExit() ;
+
+/* These are C runtime system functions */
+
+extern "C" int registerMsg(char *name, FUNCTION_PTR allocf, FUNCTION_PTR packf, FUNCTION_PTR unpackf, int size) ;
+
+extern "C" int registerBocEp(char *name, FUNCTION_PTR epFunc , int epType , int msgIndx, int chareIndx) ;
+
+extern "C" int registerEp(char *name, FUNCTION_PTR epFunc , int epType , int msgIndx, int chareIndx) ;
+
+extern "C" int registerChare(char *name, int dataSz, FUNCTION_PTR createfn) ;
+
+extern "C" int registerFunction(FUNCTION_PTR fn) ;
+
+extern "C" int registerMonotonic(char *name , FUNCTION_PTR initfn, FUNCTION_PTR updatefn , int language) ;
+
+extern "C" int registerTable(char *name , FUNCTION_PTR initfn, FUNCTION_PTR hashfn) ;
+
+extern "C" int registerAccumulator(char *name , FUNCTION_PTR initfn, FUNCTION_PTR addfn, FUNCTION_PTR combinefn , int language) ;
+
+extern "C" int registerReadOnlyMsg() ;
+
+extern "C" void registerReadOnly(int size , FUNCTION_PTR fnCopyFromBuffer, FUNCTION_PTR fnCopyToBuffer) ;
+
+extern "C" void registerMainChare(int m, int ep , int type) ;
+
+
+
+extern "C" void * GenericCkAlloc(int, int, int) ;
+extern "C" void * VarSizeCkAlloc(int, int, int, int[]) ;
+extern "C" void * CmiAllocPackBuffer(void *, int) ;
+extern "C" int CreateBoc(int, int, void *, int, ChareIDType *) ;
+extern "C" void CreateChare(int, int, void *, ChareIDType *, int) ;
+extern "C" int CreateAcc(int, void *, int, ChareIDType *) ;
+extern "C" int CreateMono(int, void *, int, ChareIDType *) ;
+extern "C" void CkExit() ;
+extern "C" void CkFreeMsg(void *) ;
+extern "C" void CmiFree(void *) ;
+extern "C" int CmiNumPe() ;
+extern "C" int CmiMyPe() ;
+extern "C" void GeneralSendMsgBranch(int, void *, int, char, int, int) ;
+extern "C" void GeneralBroadcastMsgBranch(int, void *, char, int, int) ;
+extern "C" void SendMsg(int, void *, ChareIDType *) ;
+extern "C" void *GetBocDataPtr(int) ;
+extern "C" void SetBocDataPtr(int, _CK_BOC *) ;
+extern "C" double CmiTimer() ;
+extern "C" int CmiSpanTreeRoot() ;
+extern "C" int CmiNumSpanTreeChildren(int) ;
+extern "C" int CmiSpanTreeParent(int) ;
+extern "C" void CmiSpanTreeChild(int node, int *children) ;
+
+extern "C" void VidSend(CHARE_BLOCK *, PeNumType, VID_BLOCK *) ;
+// extern "C" void RegisterDynamicBocInitMsg(int *) ;
+// extern "C" void OtherCreateBoc(void *) ;
+extern "C" void SendNodeStatistics() ;
+extern "C" void close_log() ;
+extern "C" void PrintStsFile(char *) ;
+extern "C" void trace_creation(int, int, ENVELOPE *) ;
+extern "C" void trace_begin_execute(ENVELOPE *) ;
+extern "C" void trace_end_execute(int, int, int) ;
+
+extern "C" int CPlus_GetMagicNumber(_CK_Object *) ;
+extern "C" void CPlus_StartQuiescence(int, ChareIDType) ;
+// extern "C" void _CK_CallCharmInit(_CK_Object *, argc_argv *) ;
+
+/*
+extern "C" _CK_Object * _CK_SwitchChare(int, int) ;
+extern "C" void _CK_SwitchBOC(int, int) ;
+extern "C" void * _CK_SwitchAcc(int, void *) ;
+extern "C" void * _CK_SwitchMono(int, void *) ;
+*/
+
+extern "C" void * _CK_9GetAccDataPtr(void *) ;
+extern "C" void * _CK_9GetMonoDataPtr(void *) ;
+extern "C" void _CK_BroadcastMono(void *, int) ;
+
+/* this is no longer needed for VarSize 
+extern "C" int _CK_3GetSizeOfMsg(void *) ;
+*/
+
+extern "C" void * CkPriorityPtr(void *) ;
+extern "C" ENVELOPE *CkCopyEnv(ENVELOPE *) ;
+
+/* DONT put these here else even system code will get modified !! */
+/*****
+#define MyChareID CPlus_MyChareID
+#define MainChareID CPlus_MainChareID
+#define MyBranchID CPlus_MyBranchID
+#define ChareExit CPlus_ChareExit
+******/
+
+#endif
diff --git a/src/ck-core/chare.h b/src/ck-core/chare.h
new file mode 100644 (file)
index 0000000..b29a734
--- /dev/null
@@ -0,0 +1,100 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.8  1995/04/23  21:23:15  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.7  1995/04/23  21:18:53  sanjeev
+ * put #include converse.h
+ *
+ * Revision 1.6  1995/04/23  00:52:14  sanjeev
+ * moved #define _CK_VARSIZE_UNIT 8 from conv-mach.h to chare.h
+ *
+ * Revision 1.5  1995/04/02  00:48:28  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.4  1995/03/17  23:37:34  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1995/03/12  17:09:29  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.2  1994/11/11  05:24:13  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:06  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+#include "converse.h"
+#include "conv-mach.h"
+#include "const.h"
+#include "common.h"
+#include "env_macros.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifdef DEBUG
+#define TRACE(p) p
+#else
+#define TRACE(p)
+#endif
+
+#define NO_PACK                0
+#define UNPACKED       1
+#define PACKED         2
+
+
+
+/* ---------------- the message declarations follow  ----------------------*/
+
+
+/* DYNAMIC_BOC_INIT */
+typedef struct {
+        int ref;
+        int source;
+        ChareNumType ep;
+        ChareIDType id;
+} DYNAMIC_BOC_REQUEST_MSG;
+
+typedef struct {
+       ChareNumType boc;
+       int ref;
+} DYNAMIC_BOC_NUM_MSG;
+
+
+typedef struct bocinit_queue{
+       void **block;
+       short block_len;
+       short first;
+       short length;
+} BOCINIT_QUEUE;
+/**** end changes by Milind *****/
+
+typedef struct dummymsg {
+       int x;
+} DummyMsg;
+
+
+/* include macros for bit vector priorities */
+#include "msg_macros.h"
+#include "prio_macros.h"
+#include "sys_macros.h"
+#include "communication.h"
diff --git a/src/ck-core/ck.c b/src/ck-core/ck.c
new file mode 100644 (file)
index 0000000..74c5dab
--- /dev/null
@@ -0,0 +1,505 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.13  1995/05/04  22:02:40  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.12  1995/04/23  20:52:58  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.11  1995/04/23  14:27:44  brunner
+ * Now includes converse.h, to get declaration of sysDone
+ *
+ * Revision 1.10  1995/04/14  21:05:01  milind
+ * Changed HostPeNum to NumPe
+ *
+ * Revision 1.9  1995/04/13  20:53:15  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.8  1995/04/02  00:47:39  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.7  1995/03/25  18:24:05  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.6  1995/03/24  16:41:38  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/03/17  23:36:25  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.4  1994/12/01  23:55:30  sanjeev
+ * interop stuff
+ *
+ * Revision 1.3  1994/11/18  20:33:53  narain
+ * Changed CkExit() into CkEndCharm and CkExit() with CkExit only setting the
+ * value of sysDone to 1. (CkExit messages now have encoded sequence numbers
+ *   - Sanjeev and Narain
+ *
+ * Revision 1.2  1994/11/09  21:43:18  sanjeev
+ * printf consts
+ *
+ * Revision 1.1  1994/11/03  17:38:49  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+#include "converse.h"
+
+#include <varargs.h>
+
+extern void *FIFO_Create();
+
+int num_exits =0;
+
+/* 
+  How does this work?
+
+  CkExits send on a message with an iteration number whose value is num_exits
+  CkEndCharm send -1 in the message ..
+
+  To prevent the sending of two messages for a particular CkExit or CkEndCharm,
+    *  the static variable done makes sure that only one CkEndCharm is done
+    *  the seq number in the message should equal the value of num_exits for
+       a CkExit to be processed (thus no two CkExits with the same seq number
+       are processed
+
+  The scheme is necessitated by the possibility of use of more than one 
+  "DoCharm()" (now Scheduler()) and CkExits in each of them.
+
+  The control flow - Any processor calling CkExit or CkEndCharm sends a 
+  BroadcastExitMessage to node 0 which broadcasts to ExitMessage on all 
+  processors.
+
+  ExitMessage handles CkExit and CkEndCharm requests differently.
+
+*/
+
+CkExit()
+{
+       int *msg;
+
+       msg = (int *) CkAllocMsg(sizeof(int));
+       CkMemError(msg);
+       *msg = num_exits;
+
+       GeneralSendMsgBranch(StatBroadcastExitMessage_EP,
+                       msg, 0, USERcat,  BocMsg, StatisticBocNum);
+}
+
+
+EndCharm()
+{
+       CkEndCharm();
+       CsdScheduler(-1);
+}
+
+
+CkEndCharm()
+{
+       int *msg;
+
+       msg = (int *) CkAllocMsg(sizeof(int));
+       CkMemError(msg);
+       *msg = -1;
+
+       GeneralSendMsgBranch(StatBroadcastExitMessage_EP,
+                       msg, 0, USERcat,  BocMsg, StatisticBocNum);
+}
+
+BroadcastExitMessage(usr, data)
+void *usr, *data;
+{
+/*
+   This function is executed only on node 0 - corresponds to 
+                 StatBroadcastExitMessage_EP
+*/
+       int *msg;
+       static int done = 0;
+       
+TRACE(CmiPrintf("[%d] BroadcastExitMessage: sending out message to everybody.\n",
+CmiMyPe()))
+;
+
+       if (*((int *)usr) == -1) /* For CkEndCharm */
+        {
+              if(done) 
+                   return;
+             else
+                   done = 1;
+       }
+       else                     /* For CkExit */
+        {
+             if(*((int *)usr) < num_exits)
+                     return;
+             num_exits++;
+       }
+       
+       msg = (int *) CkAllocMsg(sizeof(int));
+       CkMemError(msg);
+       *msg = *((int *)usr);
+       GeneralBroadcastMsgBranch(StatExitMessage_EP, msg, 
+                       USERcat, BroadcastBocMsg, StatisticBocNum);
+       disable_sys_msgs = 1;
+}
+
+ExitMessage(usr, data)
+void *usr, *data;
+{
+        if(*((int *)usr) == -1) /* If the user called CkEndCharm */
+       {
+           /*
+             if (CmiMyPe() != 0) CmiFlushPrintfs();
+           */
+           SendNodeStatistics();
+           send_log();
+           if (CmiMyPe() != 0 &&  (RecdPerfMsg && RecdStatMsg)) ExitNode();
+       }
+       else /* If the user called CkExit */
+       {
+             CsdExitScheduler();
+             if(CmiMyPe())
+                  num_exits++;
+       }
+}
+
+
+/* This is what you do before you exit the main node */
+ExitNode()
+{
+       char *msg;
+       ENVELOPE *env;
+
+TRACE(CmiPrintf("[%d] ExitNode: RecdPerfMsg=%d, RecdStatMsg=%d\n", CmiMyPe(),
+RecdPerfMsg, RecdStatMsg));
+       close_log();
+       if (CmiMyPe() == 0)
+       {
+               /* First print out statistics. */
+               PrintOutStatistics();
+       }
+
+       /* Complete the loop */ 
+        CsdExitScheduler();
+}
+
+
+ChareExit()
+{
+       SetID_chare_magic_number(currentChareBlock->selfID,-1) ;
+       CmiFree(currentChareBlock);
+}
+
+
+SendNodeStatistics()
+{
+       /*NodeCollectStatistics(NULL, NULL);*/
+       (*(EpTable[StatData_EP])) (NULL,NULL);
+}
+
+
+void * CreateChareBlock(sizeData)
+int sizeData;
+{
+       char *p;
+
+       p = (char *) CmiAlloc( sizeof(CHARE_BLOCK) + sizeData );
+       CkMemError(p);
+       return((void *) p);
+}
+
+
+
+IsChareLocal(chareid)
+ChareIDType * chareid;
+{
+       if (GetID_onPE((*chareid)) == CmiMyPe()) return 1;
+       return 0;
+}
+
+void *GetChareDataPtr(chareid)
+ChareIDType * chareid;
+{
+       return ((CHARE_BLOCK *) GetID_chareBlockPtr((*chareid))) + 1;
+}
+
+MyChareID(pChareID)
+ChareIDType * pChareID;
+{
+       SetID_onPE((*pChareID), CmiMyPe());
+       SetID_isVID((*pChareID), 0);
+       SetID_isBOC((*pChareID), 0);
+
+       SetID_chare_magic_number((*pChareID), 
+           GetID_chare_magic_number(currentChareBlock->selfID));
+       SetID_chareBlockPtr((*pChareID), currentChareBlock);
+
+       TRACE(CmiPrintf("[%d] MyChareID: onPE=%d, isBOC=%d, id_magic=%d, current_magic=%d, id_ptr=0x%x, current_ptr=0x%x\n",
+           CmiMyPe(), GetID_onPE((*pChareID)),
+           GetID_isBOC((*pChareID)), 
+           GetID_chare_magic_number((*pChareID)),
+           GetID_chare_magic_number(currentChareBlock->selfID),
+           GetID_chareBlockPtr((*pChareID)),
+           currentChareBlock));
+}
+
+
+/* Deleted already commented out MyParentID function : SANJEEV May 24, 93 */
+
+MainChareID(pChareID)
+ChareIDType * pChareID;
+{
+       SetID_onPE((*pChareID), 0);
+       SetID_isVID((*pChareID), 0);
+       SetID_isBOC((*pChareID), 0);
+
+       if (CmiMyPe() == 0)
+               SetID_chare_magic_number((*pChareID),
+                   GetID_chare_magic_number(mainChareBlock->selfID));
+       else
+               SetID_chare_magic_number((*pChareID), mainChare_magic_number);
+       SetID_chareBlockPtr((*pChareID), mainChareBlock);
+}
+
+
+
+/* this is the general CreateChare call: all the user level CreateChare
+   calls are mapped to this call: they include 
+
+       CreateChare(Charename, Entry, Msg, [vid [,destPE]]) 
+
+   If vid is NULL_VID it is a CreateChare call ("without ID"). 
+   if DestPe is NULL_PE  then it may go to any destination node
+   if DestPe is ALL_NODES then the message is to be broadcast
+   if DestPe is ALL_NODES_EXCEPT_ME then the message is to be broadcast
+   to all nodes except myself.
+   if DestPe is >= 0 then the message is bound for a valid destination
+
+*/
+
+CreateChare(id, Entry, Msg, vid, DestPe)
+int id;
+EntryNumType Entry;
+void *Msg;
+ChareIDType *vid;
+int DestPe;
+{
+       ENVELOPE * env;
+       VID_BLOCK * vidblock;
+       int DataSize ;
+
+       if ( IsCharmPlus(Entry) )
+               DataSize = id ;
+       else
+               DataSize =  ChareSizesTable[id];
+
+       TRACE(CmiPrintf("[%d] CreateChare: Entry=%d\n", CmiMyPe(), Entry));
+
+       nodecharesCreated++;
+       env = ENVELOPE_UPTR(Msg);
+
+       SetEnv_category(env, USERcat);
+       SetEnv_msgType(env, NewChareMsg);
+       SetEnv_sizeData(env, DataSize);
+       SetEnv_onPE(env, CmiMyPe());
+       SetEnv_EP(env, Entry);
+
+       TRACE(CmiPrintf("[%d] CreateChare: cat=%d, type=%d, size=%d, pe=%d, EP=%d\n",
+           CmiMyPe(), GetEnv_category(env), GetEnv_msgType(env),
+           GetEnv_sizeData(env), GetEnv_onPE(env),
+           GetEnv_EP(env)));
+
+       if (vid != NULL_VID)
+       {
+               vidblock   = (VID_BLOCK *)  CmiAlloc(sizeof(VID_BLOCK));
+               CkMemError(vidblock);
+               vidblock->vidPenum = -1;
+               vidblock->info_block.vid_queue = (void *) FIFO_Create();
+               SetID_isBOC((*vid), 0);
+               SetID_isVID((*vid), 1);
+               SetID_onPE((*vid), CmiMyPe());
+               SetID_vidBlockPtr((*vid),  (struct vid_block *) vidblock);
+
+               SetEnv_isVID(env, 1);
+               SetEnv_vidBlockPtr(env, (int) vidblock);
+       }
+       else
+       {
+               SetEnv_isVID(env, 0);
+               SetEnv_vidBlockPtr(env, NULL);
+       }
+
+       TRACE(CmiPrintf("[%d] CreateChare: isVID=%d, vid=0x%x\n",
+           CmiMyPe(), GetEnv_isVID(env), 
+           vid));
+
+       TRACE(CmiPrintf("[%d] CreateChare: category=%d, msgType=%d, ep=%d\n",
+           CmiMyPe(), GetEnv_category(env), 
+           GetEnv_msgType(env), GetEnv_EP(env)));
+
+
+       QDCountThisCreation(Entry, USERcat, NewChareMsg, 1);
+
+
+       /********************  SANJEEV May 24, 93 **************************/
+       /* The Ldb_NewChare_FromLocal, FIFO_EnQueue, and CkCheck_and_Send
+   calls were moved inside this if-then-else  */
+
+       trace_creation(GetEnv_msgType(env), Entry, env);
+       if (DestPe == NULL_PE)
+       {
+               /* Currently set to local PE, */
+               SetEnv_destPE(env, CmiMyPe());
+               SetEnv_destPeFixed(env, 0);
+               if (numPe > 1)
+                       Ldb_NewChare_FromLocal(env);
+               else {
+                       CmiSetHandler(env,CallProcessMsg_Index) ;
+                       CsdEnqueue(env);
+               }
+       }
+       else
+       {
+               SetEnv_destPE(env, DestPe);
+               SetEnv_destPeFixed(env, 1);
+               CkCheck_and_Send(env, Entry);
+       }
+
+}
+
+
+
+SendMsg(Entry, Msg, pChareID)
+int Entry;
+void * Msg;
+ChareIDType * pChareID;
+{
+       ENVELOPE * env;
+
+       TRACE(CmiPrintf("[%d] SendMsg: onPE=%d, isBOC=%d\n",
+           CmiMyPe(), GetID_onPE((*pChareID)),
+           GetID_isBOC((*pChareID))));
+       TRACE(CmiPrintf("[%d] SendMsg: isVID=%d\n",
+           CmiMyPe(), GetID_isVID((*pChareID))));
+
+       if (GetID_isBOC((*pChareID)))
+               GeneralSendMsgBranch(Entry, Msg, 
+                   GetID_onPE((*pChareID)), USERcat, BocMsg, GetID_boc_num((*pChareID)));
+       else
+       {
+               nodeforCharesCreated++;
+               env = ENVELOPE_UPTR(Msg);
+               SetEnv_destPE(env,    GetID_onPE((*pChareID)));
+               SetEnv_msgType(env,   ForChareMsg);
+               SetEnv_destPeFixed(env, 1);
+               if (!GetID_isVID((*pChareID)))
+               {
+                       SetEnv_category(env, USERcat);
+                       SetEnv_chareBlockPtr(env, (int)
+                           GetID_chareBlockPtr((*pChareID)));
+                       SetEnv_chare_magic_number(env,
+                           GetID_chare_magic_number((*pChareID)));
+                       QDCountThisCreation(Entry, USERcat, ForChareMsg, 1);
+               }
+               else 
+               {
+                       SetEnv_category(env, IMMEDIATEcat);
+                       SetEnv_msgType(env, VidMsg);
+                       SetEnv_vidEP(env, VidQueueUpInVidBlock_EP);
+                       SetEnv_vidBlockPtr(env, (int) GetID_vidBlockPtr((*pChareID)));
+                       QDCountThisCreation(GetEnv_vidEP(env), IMMEDIATEcat, VidMsg, 1);
+               }
+
+               SetEnv_EP(env, Entry);
+
+               TRACE(CmiPrintf("[%d] SendMsg: id_chareBlockPtr=0x%x, env_chareBlockPtr=0x%x\n",
+                   CmiMyPe(), GetID_chareBlockPtr((*pChareID)), GetEnv_chareBlockPtr(env)));
+
+               TRACE(CmiPrintf("[%d] SendMsg: magic=%d, category=%d, msgType=%d, EP=%d\n",
+                   CmiMyPe(), GetEnv_chare_magic_number(env),
+                   GetEnv_category(env), GetEnv_msgType(env), GetEnv_EP(env)));
+
+               if ((GetID_isVID((*pChareID))) && (GetEnv_destPE(env) == CmiMyPe()))
+               {
+                       trace_creation(VidMsg, GetEnv_vidEP(env), env);
+                       CmiSetHandler(env,CallProcessMsg_Index) ;
+                       CsdEnqueue(env);
+               }
+               else
+               {
+                       trace_creation(GetEnv_msgType(env), Entry, env);
+                       CkCheck_and_Send(env, Entry);
+               }
+
+               TRACE(CmiPrintf("[%d] Done with SendMsg.\n", CmiMyPe()));
+
+       }
+}
+
+
+
+
+int CkPrioritySize(priority, branch_bits)
+PVECTOR        *priority;
+int    branch_bits;
+{
+       int vectorLength;
+
+       vectorLength = ((*priority) >> 24) + branch_bits;
+
+       if ( vectorLength > 24 )
+               return( (((vectorLength - 25) >> 5) + 2) << 2 );
+       else
+               return (4);
+}
+
+
+
+/*****************************************************************/
+/** Gets reference number.                                     **/
+/*****************************************************************/
+GetRefNumber(msg)
+void *msg;
+{
+       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
+
+       return GetEnv_ref(env);
+}
+
+
+/*****************************************************************/
+/** Sets reference number.                                     **/
+/*****************************************************************/
+SetRefNumber(msg, number)
+void *msg;
+int number;
+{
+       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
+
+       SetEnv_ref(env, number);
+}
+
+
+void *CkPriorityPtr(usrptr)
+void *usrptr;
+{
+       return PRIORITY_UPTR(usrptr);
+}
+
diff --git a/src/ck-core/ck.doc b/src/ck-core/ck.doc
new file mode 100755 (executable)
index 0000000..fdf647f
--- /dev/null
@@ -0,0 +1,20 @@
+       node_ck.c contains the basic Chare Kernel calls 
+       The basic Chare Kernel calls include CreateChare, SendMsg,
+CkExit, MyChareID, CkPrintf, CkScanf and many others. 
+       CreateChare calls result in a message being created of type
+NEW_CHARE. Its sent to the load balancer, unless the user requests
+for it to be created on any specific processor, which (load balancer)
+sends it out to the correct node.
+       SendMsg also results in the creation of a message of type
+FOR_CHARE_MSG, but since the destination of the message is fixed
+by the addres of the chare to which it is destined no load balancing
+is needed.
+       CkExit results in the sending of a message to node 0, which
+broadcasts to all other nodes to terminate. These nodes terminate
+after sending back their statistical information to node 0. Node 0
+terminates after receiving messages from all other nodes.
+       For CkScanf the format is coded as a character string and sent
+to the host process, which uses the character format and does
+the actual scanf and then sends back the scanned input as a character
+string to node 0. 
+       All other calls are straightforward.
diff --git a/src/ck-core/ckdefs.h b/src/ck-core/ckdefs.h
new file mode 100644 (file)
index 0000000..a0a4fa8
--- /dev/null
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/04/23  21:21:52  sanjeev
+ * added #include converse.h
+ *
+ * Revision 1.4  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.3  1994/12/02  00:02:01  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:31:08  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:30  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#include "converse.h"
+#include "conv-mach.h"
+#include "common.h"
+#include "const.h"
+#define PROGRAMVARS
+#include "trans_defs.h"
+#include "trans_decls.h"
+#undef PROGRAMVARS
+#include "acc.h"
+#include "mono.h"
+#include "prio_macros.h"
+#include "user_macros.h"
+
+#define BranchCall(x)          x
+#define PrivateCall(x)         x
+
+
+#define _CK_Find               TblFind
+#define _CK_Delete             TblDelete
+#define _CK_Insert             TblInsert
+#define _CK_MyBocNum           MyBocNum
+#define _CK_CreateBoc          CreateBoc
+#define _CK_CreateAcc          CreateAcc
+#define _CK_CreateMono         CreateMono
+#define _CK_CPlus_CreateAcc    CPlus_CreateAcc
+#define _CK_CPlus_CreateMono   CPlus_CreateMono
+#define _CK_CreateChare                CreateChare
+#define _CK_MyBranchID         MyBranchID
+#define _CK_MonoValue          MonoValue
+
+/* The rest are for use by the CHARM++ translator */ 
+#define CPrintf                 CmiPrintf
+#define CScanf                  CmiScanf
+#define CMyPeNum                CmiMyPe
+#define CharmExit               CkExit
+
+#define CMaxPeNum               CmiNumPe
+#define CNumSpanTreeChildren    CmiNumSpanTreeChildren
+#define CSpanTreeChild         CmiSpanTreeChild
+#define CSpanTreeParent         CmiSpanTreeParent
+#define CSpanTreeRoot           CmiSpanTreeRoot
+
+#define CStartQuiescence       CPlus_StartQuiescence
+
+#define CFunctionNameToRef     FunctionNameToRef
+#define CFunctionRefToName     FunctionRefToName
+
+#define CPriorityPtr           PRIORITY_UPTR
+#define CPrioritySize          CkPrioritySize
+
+#ifndef NULL
+#define NULL 0
+#endif
diff --git a/src/ck-core/common.c b/src/ck-core/common.c
new file mode 100644 (file)
index 0000000..b134dc2
--- /dev/null
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/02  00:46:58  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.2  1995/03/12  17:09:12  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.1  1994/11/03  17:38:35  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+
+
+/**********************************************************************/
+/* This is perhaps the most crucial function in the entire system.    
+Everything that a message does depends on these. To avoid computing
+various offsets again and again, they have been made into variables,
+computed only once at initialization. Any changes made to the layout
+of the message must be reflected here. */
+/**********************************************************************/
+InitializeMessageMacros()
+{
+/* The message format is as follows :
+        -------------------------------------
+        | env | ldb | pad | user | priority |
+        -------------------------------------
+*/
+
+
+#define ENVELOPE_SIZE sizeof(ENVELOPE)
+
+/* count everything except the padding, then add the padding if needed */ 
+       HEADER_SIZE = ENVELOPE_SIZE + LDB_ELEM_SIZE ;
+
+       if (HEADER_SIZE%8 == 0)
+               PAD_SIZE = 0;
+       else {
+                       PAD_SIZE = 8 - (HEADER_SIZE%8);
+               HEADER_SIZE += PAD_SIZE;
+       }
+
+       /********************* ENVELOPE **************************************/
+
+       _CK_Env_To_Usr = ENVELOPE_SIZE + LDB_ELEM_SIZE + PAD_SIZE ;
+
+
+       /******************** LDB ********************************************/
+
+       _CK_Ldb_To_Usr = LDB_ELEM_SIZE + PAD_SIZE ;
+
+
+       /******************* USR *********************************************/
+
+       _CK_Usr_To_Env = -(ENVELOPE_SIZE + LDB_ELEM_SIZE + PAD_SIZE) ;
+       _CK_Usr_To_Ldb = -(LDB_ELEM_SIZE + PAD_SIZE);
+}      
diff --git a/src/ck-core/common.h b/src/ck-core/common.h
new file mode 100644 (file)
index 0000000..8c56e2b
--- /dev/null
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/23  21:23:04  sanjeev
+ * added _CK_VARSIZE_UNIT defn
+ *
+ * Revision 1.2  1994/11/11  05:31:33  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:40:00  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#ifndef COMMON_H
+#define COMMON_H
+
+#define _CK_VARSIZE_UNIT 8
+
+/*** These are the typedefs needed by the user ***/
+typedef unsigned int    PVECTOR;
+
+typedef int            PeNumType;
+typedef int            EntryPointType;
+typedef int            EntryNumType;
+typedef int            ChareNumType;
+typedef int            ChareNameType;
+typedef int            MsgTypes;
+typedef int            MsgCategories;
+typedef int            START_LOOP;
+typedef void           FUNC();
+typedef int            (*FUNCTION_PTR)();   /* defines FUNCTION_PTR as a 
+                                               pointer to functions */
+typedef FUNCTION_PTR   *FNPTRTYPE;
+typedef int            FunctionRefType;
+typedef int            WriteOnceID;    
+
+typedef struct chare_id_type  {
+  int tag1; /** This contains: pe, isBOC **/
+  union chareboc {
+       int chare_magic_number;
+       ChareNumType boc_num;
+  } chare_boc;
+  union idblock{
+       struct chare_block  * chareBlockPtr;
+       struct vid_block * vidBlockPtr;
+  } id_block;
+} ChareIDType;
+
+
+typedef struct boc_block {
+  ChareNumType boc_num;             /* boc instance number */
+  double dummy;  /* to pad this struct to one word length */
+} BOC_BLOCK;
+
+
+typedef struct chare_block { 
+ ChareIDType selfID;
+ int dataSize;
+ double dummy;
+} CHARE_BLOCK ;  
+
+typedef struct vid_block {
+  PeNumType vidPenum;
+  int chare_magic_number;
+  union infoblock {
+       struct fifo_queue * vid_queue;
+       CHARE_BLOCK      * chareBlockPtr;
+  } info_block;
+} VID_BLOCK;
+
+#endif
diff --git a/src/ck-core/communication.h b/src/ck-core/communication.h
new file mode 100644 (file)
index 0000000..50fdf7e
--- /dev/null
@@ -0,0 +1,130 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.10  1995/04/24  20:06:06  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.9  1995/04/24  19:52:44  sanjeev
+ * Changed CkAsyncSend to Cmi
+ * Changed CkAsyncSend to CmiSyncSend in CkSend()
+ *
+ * Revision 1.8  1995/04/23  21:02:26  sanjeev
+ * Removed Core...
+ *
+ * Revision 1.7  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.6  1995/03/25  18:25:47  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/03/24  16:42:38  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.4  1995/03/17  23:37:42  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1995/03/12  17:09:37  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.2  1994/11/11  05:31:23  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:45  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#define UNPACK(envelope) if (GetEnv_isPACKED(envelope) == PACKED) \
+{ \
+        void *unpackedUsrMsg; \
+        void *usrMsg = USER_MSG_PTR(envelope); \
+        (*(MsgToStructTable[GetEnv_packid(envelope)].unpack)) \
+                (usrMsg, &unpackedUsrMsg); \
+        if (usrMsg != unpackedUsrMsg) \
+        /* else unpacked in place */ \
+        { \
+                int temp_i; \
+                int temp_size; \
+                char *temp1, *temp2; \
+                /* copy envelope */ \
+                temp1 = (char *) envelope; \
+                temp2 = (char *) ENVELOPE_UPTR(unpackedUsrMsg); \
+                temp_size = (char *) usrMsg - temp1; \
+                for (temp_i = 0; temp_i<temp_size; temp_i++) \
+                        *temp2++ = *temp1++; \
+                CmiFree(envelope); \
+                envelope = ENVELOPE_UPTR(unpackedUsrMsg); \
+        } \
+        SetEnv_isPACKED(envelope, UNPACKED); \
+}
+
+
+#define PACK(env)      if (GetEnv_isPACKED(env) == UNPACKED) \
+        /* needs packing and not already packed */ \
+        { \
+               int size; \
+               char *usermsg, *packedmsg; \
+                /* make it +ve to connote a packed msg */ \
+                SetEnv_isPACKED(env, PACKED); \
+                usermsg = USER_MSG_PTR(env); \
+                (*(MsgToStructTable[GetEnv_packid(env)].pack)) \
+                        (usermsg, &packedmsg, &size); \
+                if (usermsg != packedmsg) \
+                        env = ENVELOPE_UPTR(packedmsg); \
+        }\
+
+
+
+#define CkCheck_and_Send(env,Entry) { \
+       if ( GetEnv_destPE(env) == CmiMyPe()) { \
+               CmiSetHandler(env,CallProcessMsg_Index) ; \
+                CsdEnqueue(env); \
+       } \
+        else \
+               CkSend(GetEnv_destPE(env), env); \
+       }
+
+/* NOTE : The CmiSize call below is required because the 
+   msg size might change after packing */
+
+#define CkSend(pe,env) \
+{ \
+       LdbFillBlock(env); \
+       PACK(env); \
+       CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+       CmiSyncSend(pe,CmiSize(env),env); \
+       CmiFree(env) ; \
+}
+
+
+#define CkCheck_and_Broadcast(env,Entry) { \
+        LdbFillBlock(env); PACK(env); \
+        CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+       CmiSyncBroadcast(CmiSize(env),env); \
+       CmiFree(env) ; \
+        }
+
+#define CkCheck_and_BroadcastNoFree(env,Entry) { \
+        LdbFillBlock(env); PACK(env); \
+        CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+       CmiSyncBroadcast(CmiSize(env),env); UNPACK(env);  \
+        }
+
+#define CkCheck_and_BroadcastAll(env,Entry) { \
+        LdbFillBlock(env); PACK(env); \
+        CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+       CmiSyncBroadcastAllAndFree(CmiSize(env),env);\
+        }
diff --git a/src/ck-core/condsend.c b/src/ck-core/condsend.c
new file mode 100644 (file)
index 0000000..1c54b9a
--- /dev/null
@@ -0,0 +1,610 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/23  00:46:38  sanjeev
+ * changed STATIC to static
+ *
+ * Revision 1.2  1995/04/13  20:53:29  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.1  1994/11/03  17:39:05  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "const.h"
+#include "chare.h"
+#include "globals.h"
+#include "condsend.h"
+
+/***************************************************************************
+ This file contains functions pertaining to conditional sends. The functions
+ in this file are:
+***************************************************************************/
+
+/********************** the user may call these functions *********************/
+void SendMsgOnCondition(); /* call param function. If 1, send msg          */
+void CallBocOnCondition(); /* call boc function. It handles situation         */
+void SendMsgAfter();       /* put time in heap, TimerChecks will send msg     */
+void CallBocAfter();       /* ditto, TimerChecks will call boc functin        */
+
+/********************* these are private to the CK ***************************/
+void SendMsgIfCondArises();
+void CallBocIfCondArises();
+void RaiseCondition();
+int  NoDelayedMsgs();
+void PeriodicChecks();     /* performs checks on various conditions           */
+void TimerChecks();        /* check list of times against current, act acdngly*/
+void CondSendInit();       /* initialize the data structures */
+
+/********************** These are private to this file ************************/
+void InsertInHeap();       /* self-explanatory                                */
+void RemoveFromHeap();     /* ditto                                           */
+void SwapHeapEntries();    /* ditto                                           */
+unsigned int LowestTime();/* returns the lowest time in the heap            */
+
+
+/**** these variables are local to this file but are persistant *****/
+static int numRaiseCondArryElts = NUMSYSCONDARISEELTS;/* init to # of system cnds */
+static HeapIndexType         timerHeap[MAXTIMERHEAPENTRIES + 1];
+static CondArrayEltType         condChkArray[MAXCONDCHKARRAYELTS];
+static IfCondArisesArrayEltType ifCondArisesArray[MAXIFCONDARISESARRAYELTS];
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:  In this function we just create data structure to hold our information
+       and add it to the  condChkArray. Later, in PeriodicChecks, it will
+       check each condition, and if true, then it will send the corresponding
+       message. 
+***************************************************************************/
+void SendMsgOnCondition(cond_fn, entry, msgToSend, size, pChareID)
+FUNCTION_PTR   cond_fn;
+int            entry;
+void           *msgToSend;
+int            size;
+ChareIDType    *pChareID;
+{
+ChareDataEntry *newEntry;
+
+if((newEntry = (ChareDataEntry *) CmiAlloc(sizeof(ChareDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    return;
+    }
+else {
+    newEntry->cond_fn   = cond_fn;   /* fill up the data record */
+    newEntry->entry     = entry;
+    newEntry->msg       = msgToSend;
+    newEntry->size      = size;
+    newEntry->chareID   = *pChareID;
+    condChkArray[numCondChkArryElts].theData      = (void *) newEntry;
+    condChkArray[numCondChkArryElts++].bocOrChare = ITSACHARE;
+    }
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   just like SendMsgOnCondition, execpt that we are dealing with a 
+        boc function call.
+***************************************************************************/
+void CallBocOnCondition(fn_ptr, bocNum)
+FUNCTION_PTR fn_ptr;
+int bocNum;
+{
+BocDataEntry *newEntry;
+
+if((newEntry = (BocDataEntry *) CmiAlloc(sizeof(BocDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    return;
+    }
+else {
+    newEntry->bocNum   = bocNum;
+    newEntry->fn_ptr   = fn_ptr;;
+
+    condChkArray[numCondChkArryElts].theData      = (void *) newEntry;
+    condChkArray[numCondChkArryElts++].bocOrChare = ITSABOC;
+    }
+}
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info: We  just place the information into the linked list in the
+      ifCondArisesArry that corresponds to the condID (ie this value
+      is just an index into the array. Later, if the condition arises,
+      then a call to RaiseCondition will set a flag in the array elts.
+      Then, when PeriodicChecks is executed, it will check to see if
+      the flag is set on any of the array elts, and if so, it will send
+      a message (or call a boc function if CallBocIfCondArises was called)
+      for each element on the linked list.
+***************************************************************************/
+void SendMsgIfCondArises(condNum,ep,msgToSend,size,pChareID)
+int         condNum;
+int         ep;
+void        *msgToSend;
+int         size;
+ChareIDType *pChareID;
+{ 
+ChareDataEntry *newEntry;
+LinkRec        *theLink, *listPtr,*lockStpPtr;
+
+if((newEntry = (ChareDataEntry *) CmiAlloc(sizeof(ChareDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    return;
+    }
+if((theLink = (LinkRec *) CmiAlloc(sizeof(LinkRec))) == NULL) {
+    CkMemError(theLink);
+    return;
+    }
+newEntry->entry     = ep;
+newEntry->msg       = msgToSend;
+newEntry->size      = size;
+newEntry->chareID   = *pChareID;        /* fill up our data structure   */
+
+theLink->theData    = (void *) newEntry;
+theLink->bocOrChare = ITSACHARE;
+theLink->next       = NULL;
+listPtr = ifCondArisesArray[condNum].dataListPtr; /* put entry into list */
+if(listPtr == NULL)
+    ifCondArisesArray[condNum].dataListPtr = theLink;
+else {
+    lockStpPtr = listPtr->next;
+    while(lockStpPtr != NULL) {
+        listPtr = lockStpPtr;
+        lockStpPtr = lockStpPtr->next;
+        }
+    listPtr->next  = theLink;
+    }
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:  The same as SendMsgIfCondArises (see above description) except that
+       we would later like a boc function to be called.
+***************************************************************************/
+void CallBocIfCondArises(condNum, fn_ptr, bocNum)
+int          condNum;
+FUNCTION_PTR fn_ptr;
+int          bocNum;
+{
+BocDataEntry *newEntry;
+LinkRec      *theLink,*listPtr,*lockStpPtr;
+
+if((newEntry = (BocDataEntry *) CmiAlloc(sizeof(BocDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    return;
+    }
+if((theLink = (LinkRec *) CmiAlloc(sizeof(LinkRec))) == NULL) {
+    CkMemError(theLink);
+    return;
+    }
+newEntry->fn_ptr    = fn_ptr;               /* fill in the new data structure */
+newEntry->bocNum    = bocNum;
+
+theLink->theData    = (void *) newEntry;    /* set up the linked list info */
+theLink->next       = NULL;
+theLink->bocOrChare = ITSABOC;
+listPtr = ifCondArisesArray[condNum].dataListPtr; /* put entry into list */
+if(listPtr == NULL)
+    ifCondArisesArray[condNum].dataListPtr = theLink;
+else {
+    lockStpPtr = listPtr->next;
+    while(lockStpPtr != NULL) {
+        listPtr = lockStpPtr;
+        lockStpPtr = lockStpPtr->next;
+        }
+    listPtr->next  = theLink;
+    }
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+***************************************************************************/
+void RaiseCondition(condNum)
+int condNum;
+{
+ifCondArisesArray[condNum].isCondRaised = 1;
+}
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info: This function sets up a data structure and enters it into a heap of time
+      values so that after a pre-determined amount of time passes (ie the 
+      amount specified in the deltaT parameter, a msg will be sent. At this
+      point we just fill the data structure, add deltaT to the current time
+      and put this value into the heap. Later, the routine TimerChecks will
+      compare the then current time against those values in the heap. If the
+      specified time has past, then the message in the data structure will
+      be sent.
+     
+***************************************************************************/
+void SendMsgAfter(deltaT, entry, msgToSend, size, pChareID)
+unsigned int  deltaT;
+int             entry;
+void            *msgToSend;
+int             size;
+ChareIDType     *pChareID;
+{
+unsigned int tPrime, currT;
+ChareDataEntry *newEntry;
+
+if((newEntry = (ChareDataEntry *) CmiAlloc(sizeof(ChareDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    }
+else {
+    currT  = CkTimer();                    /* get current time */
+    tPrime = currT + deltaT;               /* add delta to detrmn what tme */
+                                           /* to actually send the message */
+    newEntry->entry     = entry;
+    newEntry->msg       = msgToSend;
+    newEntry->size      = size;
+    newEntry->chareID   = *pChareID;        /* fill up our data structure   */
+    TRACE(CmiPrintf("SendMsgAfter: currT[%d] Will sendmsg [%d]\n",currT,tPrime));
+    InsertInHeap(tPrime, ITSACHARE,  newEntry); /* insert into tmr hp */
+    }
+} 
+
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   This routine is again exactly the same as SendmsgAfter, except
+        that when the time elapses and TimerChecks notices, then it will
+        call the boc function, and not send a msg.
+
+***************************************************************************/
+void CallBocAfter(fn_ptr,bocNum,deltaT)
+FUNCTION_PTR   fn_ptr;
+int            bocNum; 
+unsigned int deltaT;
+{
+unsigned int tPrime, currT;
+BocDataEntry *newEntry;
+
+if((newEntry = (BocDataEntry *) CmiAlloc(sizeof(BocDataEntry))) == NULL) {
+    CkMemError(newEntry);
+    }
+else {
+    currT            = CkTimer();
+    tPrime           = currT + deltaT;
+    newEntry->bocNum = bocNum;  
+    newEntry->fn_ptr = fn_ptr;  
+    TRACE(CmiPrintf("CallBocAfter nd[%d] tPrime[%d] boc[%d]\n",
+             CmiMyPe(),tPrime,bocNum));
+    InsertInHeap(tPrime, ITSABOC, newEntry);
+    } 
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   This routine does some time-related checks, ie those tasks that are
+        to be executed after a certain delay, are taken care of here. We
+        go through the heap, looking at entries with the smallest time values
+        first. If the mentioned time has already past, then we either send
+        the corresponding msg or call the boc function, whichever is applicable.
+        We then remove the element from the heap. We continue this procedure
+        until either the smallest mentioned time hasn't arrived yet, or we
+        exhaust the elements in the heap.
+
+***************************************************************************/
+void TimerChecks()
+{
+unsigned int currTime;
+int            index;
+ChareDataEntry *chareData;
+BocDataEntry   *bocData;
+
+currTime = CkTimer();
+
+       /*TRACE(CmiPrintf("(TimerChecks nd[%d]), currT [%d] #in hp[%d]\n",
+             CmiMyPe(),currTime,numHeapEntries));*/
+
+while ((numHeapEntries > 0) && (LowestTime(&index) < currTime)) {
+    if(timerHeap[index].bocOrChare == ITSACHARE) {
+        TRACE(CmiPrintf("(TimerCheck nd[%d])Snding Msg ndx[%d] currT[%d] schedT[%d]\n",
+                 CmiMyPe(),index, currTime, LowestTime(&index)));
+        chareData = (ChareDataEntry *) timerHeap[index].theData;
+        RemoveFromHeap(index); 
+        SendMsg(chareData->entry, chareData->msg,      /* send the message */
+                 &chareData->chareID);
+       CmiFree(chareData);
+        } 
+    else if(timerHeap[index].bocOrChare == ITSABOC) {  /* call the boc fn */
+        TRACE(CmiPrintf("(TimerCheck nd[%d])Cllng Boc ndx[%d] currT[%d] schedT[%d]\n",
+                 CmiMyPe(),index, currTime, timerHeap[1].timeVal));
+        bocData = (BocDataEntry *) timerHeap[index].theData;
+        RemoveFromHeap(index); 
+        (*(bocData->fn_ptr)) (bocData->bocNum);
+       CmiFree(bocData);
+        } 
+    else {
+        CmiPrintf("Internal consistency error, (TimerChecks), exiting...\n");
+        CkExit();
+        }
+    } 
+} 
+
+/*****************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   Here we just initialize some of the data structures 
+*****************************************************************************/
+void CondSendInit()
+{
+int i;
+
+for(i = 0; i < MAXIFCONDARISESARRAYELTS; i++) {
+    ifCondArisesArray[i].isCondRaised = 0;
+    ifCondArisesArray[i].dataListPtr  = NULL;
+    }
+}
+
+/*****************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:  This routine is called periodically to check various conditions and 
+       do housekeeping. Several things are checked.
+       1) we go through the condChkArray and either call the condition 
+       function or make the boc access function call. If the cond function 
+       call returns non-zero, then we send the corresponding msg. If either
+       return non-zero, then that entry is then removed from the array.
+       2) We go through the ifCondArisesArray checking to see if any of the
+       conditions has been raised (by a call to RaiseCondition). If one has,
+       we traverse its corresponding linked list and either send the msg or
+       call the boc function. We then remove the elements from the list.
+       If things are added again later, they will then be taken care of on
+       the next call to this routine, since the condition has already been
+       raised.
+
+*****************************************************************************/
+void PeriodicChecks()
+{
+int i,j;
+ChareDataEntry *chareData;
+BocDataEntry   *bocData;
+LinkRec        *listPtr,*oldPtr;
+
+for(i = 0; i < numCondChkArryElts; i++) {
+    if(condChkArray[i].bocOrChare == ITSACHARE) {
+        chareData = (ChareDataEntry *) condChkArray[i].theData;
+        if((*chareData->cond_fn)()){
+           SendMsg(chareData->entry, chareData->msg, &chareData->chareID);
+           CmiFree(condChkArray[i].theData);
+           for(j = i; j < numCondChkArryElts - 1; j++) /* fill in hole in arry*/
+               condChkArray[i] = condChkArray[i + 1];
+           i--;                            /* keep checking where we left off */
+           numCondChkArryElts--;           /* but we have one fewer elt       */
+           } 
+        } 
+    else if(condChkArray[i].bocOrChare == ITSABOC) {
+        bocData = (BocDataEntry *) condChkArray[i].theData;
+        if((*(bocData->fn_ptr))(bocData->bocNum)) {
+            CmiFree(condChkArray[i].theData);
+            for(j = i; j < numCondChkArryElts - 1; j++)   /* fill in hole */
+                condChkArray[i] = condChkArray[i + 1];
+            i--;                       /* keep checking where we left off */
+            numCondChkArryElts--;      /* but we have one fewer elt       */
+            }
+        } 
+    else {
+        CmiPrintf("Internal inconsistency (PeriodicChecks), exiting...\n");
+        CkExit();
+        } 
+    } 
+
+       /* now we check the ifCondArisesArray to see if any have arisen */
+for(i = 0; i < numRaiseCondArryElts; i++) {
+    if(ifCondArisesArray[i].isCondRaised) {         /* if the condition is T */
+        listPtr = ifCondArisesArray[i].dataListPtr;
+        while(listPtr != NULL) {                    /* traverse the list */
+            if(listPtr->bocOrChare == ITSACHARE) {  /* and take care of tasks */
+                chareData = (ChareDataEntry *) listPtr->theData;
+                SendMsg(chareData->entry, chareData->msg, /* send the msg */
+                        &chareData->chareID);
+                }
+            else if(listPtr->bocOrChare == ITSABOC) {
+                bocData = (BocDataEntry *) listPtr->theData;
+                (*(bocData->fn_ptr)) (bocData->bocNum);
+                }
+            oldPtr = listPtr;
+            listPtr = listPtr->next;
+            CmiFree(oldPtr->theData);           /* free the task */
+            CmiFree(oldPtr);                    /* free the link struct */
+            }
+        ifCondArisesArray[i].isCondRaised = 0; /* now reset condition flg */
+        ifCondArisesArray[i].dataListPtr  = NULL;  /* as well as list head    */
+        }
+    }
+} 
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+info:   here we add an element to the heap.
+***************************************************************************/
+void InsertInHeap(theTime, bocOrChare, heapData)
+unsigned int theTime;
+int            bocOrChare;
+void           *heapData;
+{
+int child, parent;
+
+if(numHeapEntries > MAXTIMERHEAPENTRIES) {
+    CmiPrintf("Heap overflow (InsertInHeap), exiting...\n");
+    CkExit();
+    }
+else {
+    numHeapEntries++;
+    timerHeap[numHeapEntries].timeVal    = theTime;
+    timerHeap[numHeapEntries].bocOrChare = bocOrChare;
+    timerHeap[numHeapEntries].theData    = (void *) heapData;
+    child  = numHeapEntries;    
+    parent = child / 2;
+    while(parent > 0) {
+        if(timerHeap[child].timeVal < timerHeap[parent].timeVal)
+            SwapHeapEntries(child,parent);
+        child  = parent;
+        parent = parent / 2;
+        }
+    }
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   Just removes an element from the heap corresponding to the index.
+        it also frees up the memory associated with the heap element (ie,
+        the space that was pointed to by the heap element). 
+***************************************************************************/
+void RemoveFromHeap(index)
+int index;
+{
+int parent,child;
+
+parent = index;
+if(!numHeapEntries || (index != 1)) {
+    CmiPrintf("Internal inconsistency (RemoveFromHeap), exiting ...\n");
+    CkExit();
+    } 
+else {
+    timerHeap[index].theData = NULL;
+    SwapHeapEntries(index,numHeapEntries); /* put value at end of heap */
+    numHeapEntries--;
+    if(numHeapEntries) {             /* if any left, then bubble up values */
+        child = 2 * parent;
+        while(child <= numHeapEntries) {
+            if(((child + 1) <= numHeapEntries)  &&
+               (timerHeap[child].timeVal > timerHeap[child + 1].timeVal))
+                child++;              /* use the smaller of the two */
+            if(timerHeap[parent].timeVal > timerHeap[child].timeVal) {
+                SwapHeapEntries(parent,child);
+                parent  = child;      /* go down the tree one more step */
+                child  = 2 * child;
+                }
+            else
+                break;                /* no more bubbling so break */
+            }
+        }
+    } 
+/*
+CmiPrintf("Removed from Heap ndx[%d] #HpEntries[%d]\n",index,numHeapEntries);
+*/
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   Just swaps two entries in the heap.
+***************************************************************************/
+void SwapHeapEntries(index1, index2)
+int index1,index2;
+{
+HeapIndexType temp;
+
+temp              = timerHeap[index1];
+timerHeap[index1] = timerHeap[index2];
+timerHeap[index2] = temp;
+} 
+
+
+/***************************************************************************
+Author: Wayne Fenton
+Date:   1/20/90
+
+Info:   Just return the lowest value in the heap, which should always be
+        at location 0. It also sets the index to this value.
+***************************************************************************/
+unsigned int LowestTime(indexPtr)
+int *indexPtr;
+{
+if(!numHeapEntries) {
+    CmiPrintf("Internal inconsistency (LowestTime), exiting...\n");
+    CkExit();
+    }
+else {
+    *indexPtr = 1;
+    return(timerHeap[1].timeVal);
+    }
+} 
+
+
+/******************************************************************************
+Author: Wayne Fenton
+Date:   2/12/90
+
+Info:  Returns a boolean indicating if there are any delayed messages in the
+          heap (ie are there any outstanding SendMsgAfter or CallBocAfter calls) 
+***************************************************************************/
+int  NoDelayedMsgs()
+{
+int i,cat;
+
+/*
+CmiPrintf("entering NoDelayedMsgs(), [%d] in heap\n",numHeapEntries);
+*/
+for(i = 1; i <= numHeapEntries; i++) {
+       if(timerHeap[i].bocOrChare == ITSABOC) {
+        if(((BocDataEntry *)timerHeap[i].theData)->bocNum >= NumSysBoc)
+            return 0;      /* if there is a user level boc func call */
+        }
+    else if(timerHeap[i].bocOrChare == ITSACHARE) {
+
+       ENVELOPE *env;
+
+       env = (ENVELOPE *) ENVELOPE_UPTR(((ChareDataEntry*)timerHeap[i].theData)->msg);
+        cat = GetEnv_category(env);
+        CmiPrintf("NoDelayedMsgs, category is[%d]\n",cat);
+        if(cat == USERcat)
+            return 0;        /* if there is a user level message */
+        }
+    else {
+        CmiPrintf("Error, node[%d], (NoDelayedMsgs ndx[%d] boc[%d])\n",
+                 CmiMyPe(),i,timerHeap[i].bocOrChare);
+        CkExit();
+        break;
+        }
+    }
+return 1;
+}
diff --git a/src/ck-core/condsend.h b/src/ck-core/condsend.h
new file mode 100644 (file)
index 0000000..a6c92df
--- /dev/null
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:25:13  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:23  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/***************************************************************************
+ condsend.h
+
+ Author: Wayne Fenton
+ Date:   1/20/90
+ Here are the data types used in conditionsends.c There are two basic types
+ that are used in three major data structures. The two basic types are
+ ChareDataEntry and BocDataEntry. One is used to send a msg and the other 
+ is used to call a boc function. The three major data structures are
+
+ 1) a heap holding time values and ptrs to the basic types. The lowest times
+    in the heap are checked against the current time. If lower, the msg is
+    sent (boc func called).
+
+ 2) a stack holding ptrs to the basic types. Periodically, the stack is 
+    traversed, and if we have a chareDataEntry then the function_ptr func
+    is called. If it returns 1, then the msg is sent and the entry is 
+    removed from the stack. If it is a BocDataEntry, then the boc func is
+    called. If it returns 1, then the entry is removed from the stack.
+
+ 3) an array, each element of which corresponds to a known condition (ie
+    queueEmpty). A linked list is attached to each condition, corresponding
+    to actions wanted done when the condition occurs. When this happens (ie
+    someone makes a call to RaiseCondition(CondNum), then a flag in the array
+    is set. Then the next time through the PeriodicChecks routine, it will
+    notice that the condition has been raised and execute the elements on
+    the linked list (ie send a message or call a boc function).
+
+***************************************************************************/
+
+#define ITSABOC                   0
+#define ITSACHARE                 1
+
+#define MAXTIMERHEAPENTRIES       512
+#define MAXCONDCHKARRAYELTS       512
+
+#define MAXIFCONDARISESARRAYELTS  512        /* just a dummy, no elts yet */
+             /* the actual indices of the conditions should be defined here */
+
+#define NUMSYSCONDARISEELTS       1    /* number of elements used by system */
+
+#define QUEUEEMPTYCOND            0    /* queue empty condition */
+
+typedef struct {
+    FUNCTION_PTR   cond_fn;
+    int            entry;
+    void           *msg;
+    int            size;
+    ChareIDType    chareID;
+    } ChareDataEntry;
+
+typedef struct {
+    int             bocNum;
+    FUNCTION_PTR    fn_ptr;
+    } BocDataEntry;             /* If pointed to from heap, then next is NULL */
+
+typedef struct {
+    unsigned int timeVal;     /* the actual time value we sort on           */
+    int            bocOrChare;  /* so we know what kind of data we're ptng to */
+    void           *theData;    /* points to either ChareDataEntry or Boc..   */
+    } HeapIndexType;
+
+typedef struct {
+    int            bocOrChare;    /* same struct as HeapIndexType except that */
+    void           *theData;      /* here we are using a simple stack to keep */
+    } CondArrayEltType;           /* the information.                         */
+
+typedef struct linkptr {
+    int             bocOrChare;
+    void            *theData;
+    struct linkptr  *next;
+    } LinkRec;
+
+typedef struct {
+    short          isCondRaised;  /* has condition been raised?               */
+    LinkRec        *dataListPtr;  /* We keep a linked list for each element in*/
+    } IfCondArisesArrayEltType;   /* the array. Each element in the list is   */
+                                  /* either ChareDataEntry or BocDataEntry    */
+
diff --git a/src/ck-core/const.h b/src/ck-core/const.h
new file mode 100644 (file)
index 0000000..856e628
--- /dev/null
@@ -0,0 +1,149 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/05/03  20:57:54  sanjeev
+ * bug fixes for finding uninitialized modules
+ *
+ * Revision 1.2  1994/11/11  05:31:12  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:34  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/* There is no shared declaration for nonshared machines */
+#define SHARED_DECL
+
+/* constants for denoting illegal values (used as flags) */
+#define NULL_VID       NULL
+#define NULL_PACK_ID    0  
+#define NULL_PE        -2   /* -1 indicates all nodes, so use -2 */
+
+/* Constant values for destPE in envelope */
+#define ALL_NODES           (-1)
+#define ALL_NODES_EXCEPT_ME (-2)
+
+/* define the System BocNum's corresponding to system BOCs
+   e.g LoadBalancing, Quiescence, Also Increment the NumSysBoc
+   defined below */
+#define LdbBocNum 0    /* load-balancing         */
+#define QDBocNum  1    /* Quiescecence Detection */
+#define VidBocNum 2    /* virtual id's           */
+#define WOVBocNum 3    /* write once variables   */
+#define TblBocNum 4    /* dynamic table boc      */
+#define DynamicBocNum 5 /* to manage dynamic boc  */
+#define StatisticBocNum 6 /* to manage statistics */
+
+/* define NumSysBoc as the number of system Bocs: Increment this
+   as more system BOCs are added.
+   1 boc is for load balancing 
+   1 boc is for quiescence detection
+   1 boc is for virtual ids  
+   1 boc is for write once variables
+   1 boc is for dynamic tables      */
+
+#define MaxBocs                      100
+#define PSEUDO_Max           20
+#define NumSysBoc             7
+
+#define MainInitEp            0
+#define NumHostSysEps         0
+#define NumNodeSysEps         0
+
+/* Note : Entry Point 0 is the _CkNullEP  --Sanjeev 5/3/95 */
+
+/* Entry points for Quiescence detection BOC   */
+#define QDInsertQuiescenceList_EP                                      1
+#define QDHost_EndPhI_EP                                               2
+#define QDHost_EndPhII_EP                                              3
+#define QDInit_EP                                                      4
+#define QDPhaseIBroadcast_EP                                           5
+#define QDPhaseIMsg_EP                                                 6
+#define QDPhaseIIBroadcast_EP                                          7
+#define QDPhaseIIMsg_EP                                                8
+
+/* Entry points for VID BOC                    */
+#define VidQueueUpInVidBlock_EP                                        9 
+#define VidSendOverMessages_EP                                         10
+
+/* Entry points for Write Once Variables       */
+#define NodeAddWOV_EP                                                  11 
+#define NodeRcvAck_EP                                                  12
+#define HostAddWOV_EP                                                  13 
+#define HostRcvAck_EP                                                  14
+
+/* Entry points for dynamic tables BOC         */
+#define TblUnpack_EP                                                           15
+
+/* Entry points for accumulator BOC            */
+#define ACC_CollectFromNode_EP                                         16
+#define ACC_LeafNodeCollect_EP                                                 17
+#define ACC_InteriorNodeCollect_EP                                     18
+#define ACC_BranchInit_EP                                                      19
+
+/* Entry points for monotonic BOC              */
+#define MONO_BranchInit_EP                                                     20
+#define MONO_BranchUpdate_EP                                           21
+#define MONO_ChildrenUpdate_EP                                         22
+
+/* These are the entry points necessary for the dynamic BOC creation. */
+#define RegisterDynamicBocInitMsg_EP                           23
+#define OtherCreateBoc_EP                                                      24
+#define InitiateDynamicBocBroadcast_EP                                 25
+
+/* These are the entry points for the statistics BOC */
+#define StatCollectNodes_EP                                            26
+#define StatData_EP                                                            27
+#define StatPerfCollectNodes_EP                                28
+#define StatBroadcastExitMessage_EP                            29
+#define StatExitMessage_EP                                                     30
+
+/* Entry points for LoadBalancing BOC          */
+#define LdbNbrStatus_EP                                                31
+
+
+
+/* Total Number of system BOC entry points (numbers 1 through 31) */
+#define NumSysBocEps                                                   31
+
+/* MsgCategories */
+/* at the moment only vaguely defined. Use will be clearer later, if needed */
+#define        IMMEDIATEcat    0
+#define USERcat        1
+
+
+/* MsgTypes */
+/* The performance tools use these also. */
+/**********            USERcat                 *******/
+#define NewChareMsg            0
+#define ForChareMsg            1
+#define BocInitMsg             2
+#define BocMsg                 3
+#define TerminateToZero        4
+#define TerminateSys           5
+#define InitCountMsg           6
+#define ReadVarMsg             7
+#define ReadMsgMsg             8
+#define BroadcastBocMsg        9
+#define DynamicBocInitMsg      10
+
+/**********            IMMEDIATEcat            *******/
+#define LdbMsg                 12
+#define VidMsg                 13
+#define QdBocMsg               14
+#define QdBroadcastBocMsg      15
+
diff --git a/src/ck-core/dagger.h b/src/ck-core/dagger.h
new file mode 100644 (file)
index 0000000..0640a8e
--- /dev/null
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:31:32  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:58  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/* _dag3_WLIMIT is defined in dag.c dag.h also */
+#define _dag3_WLIMIT 8
+
+struct s_dag3_DAGVAR {
+    int index;
+    int init_value;
+    int counter;
+};
+
+struct s_dag3_RLNODE {
+    int    wno;
+    int    refnum;
+    struct s_dag3_RLNODE *next;
+};
+
+
+struct s_dag3_BUFFER {
+    int eno;
+    int refnum;
+    int expect;
+    int ecount;
+    int free_count;
+    void *msg;
+    struct s_dag3_BUFFER **prev;
+    struct s_dag3_BUFFER *next;
+};
+
+
+struct s_dag3_COUNT {
+    int refnum;
+    int value;
+    int bix;
+    struct s_dag3_BUFFER *bpa[_dag3_WLIMIT]; /* back pointer array */
+    struct s_dag3_COUNT  **prev;
+    struct s_dag3_COUNT  *next;
+};
+
+struct s_dag3_FREELIST {
+    int bcount;
+    int ccount;
+    struct s_dag3_BUFFER *b;
+    struct s_dag3_COUNT  *c;
+};
+
+struct s_dag3_RL {
+    int    dagexit;
+    struct s_dag3_COUNT *head;
+    struct s_dag3_COUNT *tail;
+};
+
+typedef struct s_dag3_COUNT _dag3_RLNODE;
+typedef struct s_dag3_RL     _dag3_RL;
+typedef struct s_dag3_BUFFER _dag3_BUFFER;
+typedef struct s_dag3_COUNT  _dag3_COUNT;
+typedef struct s_dag3_FREELIST _dag3_FREELIST;
+typedef struct s_dag3_DAGVAR _dag3_DAGVAR;
+typedef struct s_dag3_DAGVAR DAGVAR;
+typedef struct s_dag3_DAGVAR CONDVAR;
+
+extern _dag3_COUNT  *_dag4_mfc();
+extern _dag3_COUNT  *_dag4_nonmfc();
+extern _dag3_BUFFER *_dag4_mfb();
+extern _dag3_BUFFER *_dag4_nonmfb();
+extern _dag3_BUFFER *_dag4_fb();
+extern void         *_dag4_gb();
+
+/* DAG_NOREF define in dag.c also */
+#define DAG_NOREF 0
+#define expect(x,y) (*_CK_4mydata->_dag3_epf_fptr)(_CK_4mydata,x,y)
+#define dagExit()   (_CK_4mydata->_dag3_rl.dagexit = 1)
+#define eset(n,v)   (n=v)
+#define set(c,v)    (c.counter=v)
+#define inq(c)      (c.counter)
+#define decrement(c) (*_CK_4mydata->_dag3_cv_fptr)(_CK_4mydata,&(c),0,DAG_NOREF)
+#define ready(c,r) (*_CK_4mydata->_dag3_cv_fptr)(_CK_4mydata,&(c),(r==DAG_NOREF)?0:1,(r==DAG_NOREF)?((c.counter=1)-1):r)
+#define GetMyRefNumber() _CK_4mydata->_dag3_myrefnum
+message {int i;} _dag3_MSG;
+
+#ifdef STRACE
+/* trace function calls */
+extern _dag_s_sbranch1();
+extern _dag_s_sbranch2();
+extern _dag_s_broadcast();
+extern _dag_s_smsg();
+extern _dag_s_msetcond();
+extern _dag_s_endsend();
+
+
+#define dag_sendbranch1(e,m,p)    _dag_s_sbranch1(&_CK_4mydata->_dag3_cid,p,e,m)
+#define dag_sendbranch2(e,m,p,b)  _dag_s_sbranch2(b,p,e,m)
+#define dag_broadcast(e,m)        _dag_s_broadcast(&_CK_4mydata->_dag3_cid,e,m)
+#define dag_send(e,m,c)           _dag_s_smsg(c,e,m)
+#define dag_mwset()               (*_CK_4mydata->_dag3_mw_fptr)(_CK_4mydata)
+#define dag_mcset(c,v)            _dag_s_msetcond(c.index,v)
+#define dag_endsend()             _dag_s_endsend();
+
+#else
+
+#define dag_sendbranch1(e,m,p)
+#define dag_sendbranch2(e,m,p,b)  
+#define dag_broadcast(e,m)
+#define dag_send(e,m,c)
+#define dag_mwset()   
+#define dag_mcset(c,v) 
+#define dag_endsend()  
+
+#endif
diff --git a/src/ck-core/default-main.c b/src/ck-core/default-main.c
new file mode 100644 (file)
index 0000000..bac93a1
--- /dev/null
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.4  1995/04/13  20:54:18  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.3  1995/04/02  00:48:53  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.2  1995/03/17  23:38:21  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.1  1994/11/18  20:38:11  narain
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include "converse.h"
+
+int          disable_sys_msgs=0;
+extern int   numHeapEntries;
+extern int   numCondChkArryElts;
+extern int   CsdStopFlag;
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+  ConverseInit(argv);
+  StartCharm(argv);
+  CsdStopFlag=0;
+  while (1) {
+    void *msg;
+    msg = CsdGetMsg();
+    if (msg) (CmiGetHandlerFunction(msg))(msg);
+    if (CsdStopFlag) break;
+    if (!disable_sys_msgs)
+        { if (numHeapEntries > 0) TimerChecks();
+          if (numCondChkArryElts > 0) PeriodicChecks(); }
+  }
+  EndCharm();
+  ConverseExit() ;
+}
+
diff --git a/src/ck-core/dtable.h b/src/ck-core/dtable.h
new file mode 100644 (file)
index 0000000..3b310c2
--- /dev/null
@@ -0,0 +1,104 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.4  1995/05/09  20:55:53  knauff
+ * Added SetId method, plus surrounding #ifndef #define wrappers
+ * for multiple includes.
+ *
+ * Revision 1.2  1994/11/11  05:31:25  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:46  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*      Authors: Wayne Fenton, Balkrishna Ramkumar, Vikram A. Saletore    */
+/*                    Amitabh B. Sinha  and  Laxmikant V. Kale            */
+/*              (C) Copyright 1990 The Board of Trustees of the           */
+/*                          University of Illinois                        */
+/*                           All Rights Reserved                          */
+/*                                                                        */
+/**************************************************************************/
+
+#ifndef _dtable_h_
+#define _dtable_h_
+
+#define TBL_WAITFORDATA 1
+#define TBL_NOWAITFORDATA 2
+
+#define TBL_REPLY 1
+#define TBL_NOREPLY 2
+
+#define TBL_WAIT_AFTER_FIRST 1
+#define TBL_NEVER_WAIT 2
+#define TBL_ALWAYS_WAIT 3
+
+message TBL_MSG {
+       int key;
+       char *data;
+} ;
+
+extern int _CK_NumTables ;
+extern "C" void TblInsert(int, int, int, void *, int, int, ChareIDType *, int);
+extern "C" void TblDelete(int, int, int, int, ChareIDType *, int) ;
+extern "C" void TblFind(int, int, int, int, ChareIDType *, int) ;
+
+
+class table { /* top level distributed table object */
+        int _CK_MyId ;
+public:
+        table()
+        {       _CK_MyId = _CK_NumTables++ ;
+                /* Table ids are assigned at run time unlike in CHARM.
+                   _CK_NumTables is a global, defined in cplus_node_main.c */
+        }
+        void Insert(int key, void *data, int size_data, int EPid, ChareIDType cid, int option)
+        {
+            if ( GetID_onPE(cid) == -1 )
+                ::TblInsert(_CK_MyId, -1, key, data, size_data, EPid, NULL, option) ;
+            else
+                ::TblInsert(_CK_MyId, -1, key, data, size_data, EPid, &cid, option) ;
+        }
+
+        void Delete(int key, int EPid, ChareIDType cid, int option)
+        {
+            if ( GetID_onPE(cid) == -1 )
+                ::TblDelete(_CK_MyId, -1, key, EPid, NULL, option) ;
+            else
+                ::TblDelete(_CK_MyId, -1, key, EPid, &cid, option) ;
+        }
+
+        void Find(int key, int EPid, ChareIDType cid, int option)
+        {
+            if ( GetID_onPE(cid) == -1 )
+                ::TblFind(_CK_MyId, -1, key, EPid, NULL, option) ;
+            else
+                ::TblFind(_CK_MyId, -1, key, EPid, &cid, option) ;
+        }
+
+       int GetId()
+       {       return _CK_MyId ; }
+
+       void SetId (int x) {
+            _CK_MyId = x;
+       }
+
+} ;
+
+#endif
diff --git a/src/ck-core/env_macros.h b/src/ck-core/env_macros.h
new file mode 100644 (file)
index 0000000..d776452
--- /dev/null
@@ -0,0 +1,343 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.6  1995/05/03  20:58:09  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/04/23  20:54:43  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.4  1995/03/17  23:37:51  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1995/03/12  17:09:48  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.2  1994/11/11  05:31:19  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:42  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/*****************************************************************/
+/** This is the structure of the envelope. The various functions**/
+/** that access it follow.                                     **/
+/** This file also contains access macros for the chare-id     **/
+/*****************************************************************/
+
+#ifdef DEBUGGING_MODE
+typedef struct envelope {
+  int          core1;
+  /* core1 is the first word of the core's fields */
+
+  int          prio;
+  /* prio contains 1 bit for priotype, 31 bits for signed integer priority,
+     or offset + size for bitvector priority */
+
+  int           tag1;
+  /** tag1 contains: ref, msgType, isPACKED, packid  **/
+
+  int           tag2;
+  /** tag2 contains: EP, isVID+vidEP / other_id **/
+
+  int           tag3;
+  /** tag3 contains: count, vidBlockPtr, chareBlockPtr, boc_id+boc_num  **/
+
+  int           tag4;
+  /** tag4 contains: chare_magic_number, dataSize **/
+
+  int           tag5;
+  /** tag5 contains: onPE **/
+
+  int           destPE;
+  int           pe;
+  int           event;
+} ENVELOPE;
+
+#else
+typedef struct envelope {
+  int          core1;
+  /* core1 is the first word of the core's fields */
+
+  int          prio;
+  /* prio contains 1 bit for priotype, 31 bits for signed integer priority,
+     or offset + size for bitvector priority */
+
+  int           tag1;
+  /** tag1 contains: ref, category, msgType, isPACKED, packid, destPeFixed; **/
+
+  int           tag2;
+  /** tag2 contains: EP, isVID+vidEP / other_id **/
+
+  int           tag3;
+  /** tag3 contains: count, vidBlockPtr, chareBlockPtr, boc_id+boc_num  **/
+
+  int           tag4;
+  /** tag4 contains: chare_magic_number, dataSize **/
+
+  int           tag5;
+  /** tag5 contains: onPE **/
+
+  int           destPE;
+} ENVELOPE;
+#endif
+
+/*********************************************************/
+/** We are trying to set the most bits of x to y.      **/
+/*********************************************************/
+#define MOST16                         0xffff0000
+#define zeroMOST16(x,p,n)              (x & ~MOST16)
+#define setbitsMOST16(x,y,p,n)         x = (zeroMOST16(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set the least 16 bits of x to y.  **/
+/*********************************************************/
+#define LEAST16                                0xffff
+#define zeroLEAST16(x,p,n)             (x & ~LEAST16)
+#define setbitsLEAST16(x,y,p,n)                x = (zeroLEAST16(x,p,n) | (y << (p+1-n)))
+
+
+/*********************************************************/
+/** We are trying to set the next 8 bits of x to y.    **/
+/*********************************************************/
+#define MIDDLE8                                0xff00
+#define zeroMIDDLE8(x,p,n)             (x & ~MIDDLE8)
+#define setbitsMIDDLE8(x,y,p,n)                x = (zeroMIDDLE8(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set the least 8 bits of x to y.   **/
+/*********************************************************/
+#define LEAST8                         0xff
+#define zeroLEAST8(x,p,n)              (x & ~LEAST8)
+#define setbitsLEAST8(x,y,p,n)         x = (zeroLEAST8(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set bits 16-15 of x to y.         **/
+/*********************************************************/
+#define NEXT2                          0xc000
+#define zeroNEXT2(x,p,n)               (x & ~NEXT2 )
+#define setbitsNEXT2(x,y,p,n)          x = (zeroNEXT2(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set bits 14-1 of x to y.          **/
+/*********************************************************/
+#define NEXT14                         0x3fff
+#define zeroNEXT14(x,p,n)              (x & ~NEXT14 )
+#define setbitsNEXT14(x,y,p,n)         x = (zeroNEXT14(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set bits 14-7 of x to y.          **/
+/*********************************************************/
+#define NEXT8                          0x3fc0
+#define zeroNEXT8(x,p,n)               (x & ~NEXT8 )
+#define setbitsNEXT8(x,y,p,n)          x = (zeroNEXT8(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set the sixth bit of x to y.      **/
+/*********************************************************/
+#define SIXTH                          0x20
+#define zeroSIXTH(x,p,n)               (x & ~SIXTH )
+#define setbitsSIXTH(x,y,p,n)          x = (zeroSIXTH(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set bits 2-5 of x to y.           **/
+/*********************************************************/
+#define MIDDLE4                                0x1e
+#define zeroMIDDLE4(x,p,n)             (x & ~MIDDLE4 )
+#define setbitsMIDDLE4(x,y,p,n)                x = (zeroMIDDLE4(x,p,n) | (y << (p+1-n)))
+
+/*********************************************************/
+/** We are trying to set the first bit of x to y.      **/
+/*********************************************************/
+#define FIRST                          0x1
+#define zeroFIRST(x,p,n)               (x & ~FIRST )
+#define setbitsFIRST(x,y,p,n)          x = (zeroFIRST(x,p,n) | (y << (p+1-n)))
+
+#define getbits(x,p,n)                         ((x >> (p+1-n)) & ~(~0 << n))
+
+
+/*********************************************************/
+/** Arrangement for the first tag word in ChareIDType: **/
+/**    pe = 16 bits                                    **/
+/**    isBOC = 8 bits                                  **/
+/**    isBOC overloaded with DynamicBocNum and type    **/
+/**    of chare in case of a send message.             **/
+/**    isVID = 8 bits                                  **/
+/**    isVID overloaded with whether a new chare is    **/
+/**    created as a vid or not, and the id of an       **/
+/**    accumulator, monotonic and read message         **/
+/**    variable.                                       **/ 
+/*********************************************************/
+#define GetID_onPE(id)                         getbits(id.tag1,31,16)
+#define GetID_isBOC(id)                getbits(id.tag1,15,8)
+#define GetID_isVID(id)                getbits(id.tag1,7,8)
+
+#define SetID_onPE(id,x)               setbitsMOST16(id.tag1,x,31,16)
+#define SetID_isBOC(id,x)              setbitsMIDDLE8(id.tag1,x,15,8)
+#define SetID_isVID(id,x)              setbitsLEAST8(id.tag1,x,7,8)
+
+#define GetID_chare_magic_number(id)   id.chare_boc.chare_magic_number
+#define GetID_boc_num(id)              id.chare_boc.boc_num
+#define GetID_chareBlockPtr(id)                id.id_block.chareBlockPtr
+#define GetID_vidBlockPtr(id)          id.id_block.vidBlockPtr
+
+#define SetID_chare_magic_number(id,x) id.chare_boc.chare_magic_number=x
+#define SetID_boc_num(id,x)            id.chare_boc.boc_num=x
+#define SetID_chareBlockPtr(id,x)      id.id_block.chareBlockPtr=x
+#define SetID_vidBlockPtr(id,x)                id.id_block.vidBlockPtr=x
+
+
+/*********************************************************/
+/** Arrangement for prio word in the envelope:         
+    | signed integer prio : 31 bits | type : 1 bit |
+    | size : 11 bits | offset : 20 bits | type : 1 bit |
+**********************************************************/
+#define GetEnv_PrioType(env)  \
+        (int)(((ENVELOPE *)(env))->prio & 0x00000001)
+#define SetEnv_PrioType(env,x)  \
+        ((ENVELOPE *)(env))->prio = x
+
+#define GetEnv_IntegerPrio(env)  \
+        (int)(((ENVELOPE *)(env))->prio/2)
+#define SetEnv_IntegerPrio(env,x)  \
+        ((ENVELOPE *)(env))->prio = 2*(x) | (((ENVELOPE *)(env))->prio & 0x00000001) 
+#define GetEnv_PrioOffset(env)  \
+        (int)( (((ENVELOPE *)(env))->prio>>1) & 0x000fffff )
+#define SetEnv_PrioOffset(env,x)  \
+        ((ENVELOPE *)(env))->prio = ( (((ENVELOPE *)(env))->prio & 0xffe00001) | (x<<1) )
+#define GetEnv_PrioSize(env)  \
+        (int)( ((ENVELOPE *)(env))->prio >> 21 )
+
+#define SetEnv_PrioSize(env,x)  \
+        ((ENVELOPE *)(env))->prio = ( (((ENVELOPE *)(env))->prio & 0x001fffff) | (x<<21) )
+
+
+/**  EXTRA MACROS FOR PRIORITY FIELDS  *********************************/
+
+#define GetEnv_PriorityPtr(env, priorityptr) {\
+    if ( GetEnv_PrioType((env)) == 0 ) \
+        priorityptr = (PVECTOR *)((char *)(env) + 4) ; \
+    else  \
+        priorityptr = (PVECTOR *)((char *)(env) + *((int *)GetEnv_PrioOffset(env)));\
+}
+#define ReturnEnv_PriorityPtr(env) \
+    ( ( GetEnv_PrioType(env) == 0 ) ?  \
+      ( ((char *)(env)) + 4 ) : \
+      ( ((char *)(env)) + GetEnv_PrioOffset(env) )  \
+    )
+
+
+
+
+/*********************************************************/
+/** Arrangement for first tag word in the envelope:    **/
+/**    ref = 16 bits                                   **/
+/**    isPACKED = 2 bits                               **/
+/**    packid = 8 bits                                 **/
+/**    category = 1 bit                                **/
+/**    msgType = 4 bits                                **/
+/**    destPeFixed = 1 bit                             **/
+/*********************************************************/
+#define GetEnv_ref(env)                getbits(env->tag1,31,16)
+#define GetEnv_isPACKED(env)           getbits(env->tag1,15,2)
+#define GetEnv_packid(env)             getbits(env->tag1,13,8)
+#define GetEnv_category(env)           getbits(env->tag1,5,1)
+#define GetEnv_msgType(env)            getbits(env->tag1,4,4)
+#define GetEnv_destPeFixed(env)        getbits(env->tag1,0,1)
+
+#define SetEnv_ref(env,x)              setbitsMOST16(env->tag1,x,31,16)
+#define SetEnv_isPACKED(env,x)                 setbitsNEXT2(env->tag1,x,15,2)
+#define SetEnv_packid(env,x)           setbitsNEXT8(env->tag1,x,13,8)
+#define SetEnv_category(env,x)         setbitsSIXTH(env->tag1,x,5,1)
+#define SetEnv_msgType(env,x)          setbitsMIDDLE4(env->tag1,x,4,4)
+#define SetEnv_destPeFixed(env,x)      setbitsFIRST(env->tag1,x,0,1)
+
+/*********************************************************/
+/** Arrangement for second tag word in the envelope:   **/
+/**    EP = 16 bits                                    **/
+/**    isVID=2bits+vidEP=14bits / other_id=16bits      **/
+/*********************************************************/
+#define GetEnv_EP(env)                         getbits(env->tag2,31,16)
+#define GetEnv_isVID(env)              getbits(env->tag2,15,2)
+#define GetEnv_vidEP(env)              getbits(env->tag2,13,14)
+#define GetEnv_other_id(env)           getbits(env->tag2,15,16)
+
+#define SetEnv_EP(env,x)               setbitsMOST16(env->tag2,x,31,16)
+#define SetEnv_isVID(env,x)            setbitsNEXT2(env->tag2,x,15,2)
+#define SetEnv_vidEP(env,x)            setbitsNEXT14(env->tag2,x,13,14)
+#define SetEnv_other_id(env,x)                 setbitsLEAST16(env->tag2,x,15,16)
+
+
+/*********************************************************/
+/** Arrangement for third tag word in the envelope:    **/
+/**    count=32bits                                    **/
+/**    vidBlockPtr=32bits                              **/
+/**    chareBlockPtr=32bits.                           **/
+/**    boc_id=16bits+boc_num=16bits                    **/
+/*********************************************************/
+#define GetEnv_count(env)              env->tag3
+#define GetEnv_chareBlockPtr(env)      env->tag3
+#define GetEnv_vidBlockPtr(env)                env->tag3
+#define GetEnv_boc_id(env)             getbits(env->tag3,31,16)
+#define GetEnv_boc_num(env)            getbits(env->tag3,15,16)
+
+#define SetEnv_count(env,x)            env->tag3=x
+#define SetEnv_chareBlockPtr(env,x)    env->tag3=x
+#define SetEnv_vidBlockPtr(env,x)      env->tag3=x
+#define SetEnv_boc_id(env,x)           setbitsMOST16(env->tag3,x,31,16)
+#define SetEnv_boc_num(env,x)          setbitsLEAST16(env->tag3,x,15,16)
+
+
+/*********************************************************/
+/** Arrangement for fourth tag word in the envelope:   **/
+/**    sizeData=32bits                                 **/
+/**    chare_magic_number=32bits                       **/
+/*********************************************************/
+#define GetEnv_sizeData(env)           env->tag4
+#define GetEnv_chare_magic_number(env) env->tag4
+
+#define SetEnv_sizeData(env,x)                 env->tag4=x
+#define SetEnv_chare_magic_number(env,x) env->tag4=x
+
+
+/*********************************************************/
+/** Arrangement for fifth tag word in the envelope:    **/
+/**    onPE = 32 bits                                  **/
+/*********************************************************/
+#define GetEnv_onPE(env)               env->tag5
+#define SetEnv_onPE(env,x)             env->tag5=x
+
+
+/*********************************************************/
+/** These fields are alone currently, and accessed     **/
+/** separately.                                                **/
+/*********************************************************/
+#define GetEnv_destPE(env)             env->destPE
+#define GetEnv_pe(env)                 env->pe
+#define GetEnv_event(env)              env->event
+
+#define SetEnv_destPE(env,x)           env->destPE=x
+#define SetEnv_pe(env,x)               env->pe=x
+#define SetEnv_event(env,x)            env->event=x
diff --git a/src/ck-core/globals.c b/src/ck-core/globals.c
new file mode 100644 (file)
index 0000000..07c4302
--- /dev/null
@@ -0,0 +1,123 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.7  1995/05/04  22:03:51  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.6  1995/05/03  20:57:13  sanjeev
+ * bug fixes for finding uninitialized modules
+ *
+ * Revision 1.5  1995/04/02  00:47:16  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.4  1995/03/12  17:08:13  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.3  1995/01/17  23:45:52  knauff
+ * Added variables for the '++outputfile' option in the network version.
+ *
+ * Revision 1.2  1994/12/01  23:55:06  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:32  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "trans_defs.h"
+#include <stdio.h>
+
+/**********************************************************************/
+/* These fields are needed by message macros. Any changes must be
+reflected there. */
+/**********************************************************************/
+
+int PAD_SIZE, HEADER_SIZE ;
+int _CK_Env_To_Usr;
+int _CK_Ldb_To_Usr;
+int _CK_Usr_To_Env, _CK_Usr_To_Ldb ;
+
+
+
+
+/**********************************************************************/
+/* Other global variables. */
+/**********************************************************************/
+int TotalEps;
+int NumReadMsg =  0;
+int MsgCount;                  /* for the initial, pre-loop phase.
+                               to count up all the messages
+                               being sent out to nodes                 */
+int InsideDataInit = 0;
+int mainChare_magic_number;
+struct chare_block * mainChareBlock;
+struct chare_block * currentChareBlock;
+int currentBocNum = (NumSysBoc - 1); /* was set to  -1 */
+int MainDataSize;              /* size of dataarea for main chare      */
+
+
+int         * EpLanguageTable ;
+
+/* void            ** _CK_9_ReadMsgTable;  no longer global */
+FUNCTION_PTR *ROCopyFromBufferTable, *ROCopyToBufferTable ;
+
+int          * EpIsImplicitTable;
+FUNCTION_PTR * EpTable;        /* actual table to be allocated dynamically
+                               depending on the number of entry-points */
+int         * EpToMsgTable ;  /* Table mapping EPs to associated       
+                               messages.                               */
+int         * EpChareTypeTable ;  /* Table mapping EPs to chare type 
+                                     (CHARE or BOC) */         
+MSG_STRUCT   * MsgToStructTable;/* Table mapping message to struct table*/
+PSEUDO_STRUCT * PseudoTable;
+
+int         *EpChareTable ;
+char        ** EpNameTable ;
+
+int         * ChareSizesTable;
+FUNCTION_PTR * ChareFnTable ;
+char        ** ChareNamesTable;
+
+int msgs_processed, msgs_created;
+
+int nodecharesCreated=0;
+int nodeforCharesCreated=0;
+int nodebocMsgsCreated=0;
+int nodecharesProcessed = 0;
+int nodebocMsgsProcessed = 0;
+int nodeforCharesProcessed = 0;
+
+/* FIFO_QUEUE *LocalQueueHead; now in converse.c */
+
+int PrintChareStat = 0;
+int PrintSummaryStat = 0;
+
+int RecdStatMsg;
+int RecdPerfMsg;
+
+int numHeapEntries=0;  /* heap of tme-dep calls   */
+int numCondChkArryElts=0; /* arry hldng conditon check info */
+
+
+int _CK_13PackOffset;
+int _CK_13PackMsgCount;
+int _CK_13ChareEPCount;
+int _CK_13TotalMsgCount;
+FUNCTION_PTR    * _CK_9_GlobalFunctionTable;
+
+int MainChareLanguage = -1 ;
diff --git a/src/ck-core/globals.h b/src/ck-core/globals.h
new file mode 100644 (file)
index 0000000..5d792c2
--- /dev/null
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.8  1995/04/23  17:47:02  sanjeev
+ * removed declaration of LanguageHandlerTable
+ *
+ * Revision 1.7  1995/04/23  14:26:27  brunner
+ * Removed sysDone, since it is in converse.h
+ *
+ * Revision 1.6  1995/04/02  00:48:37  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.5  1995/03/24  16:42:51  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.4  1995/03/17  23:38:03  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1994/12/02  00:02:03  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:24:52  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:17  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#include "trans_defs.h"
+#include "trans_decls.h"
+
+extern int numPe;
+extern int SysMem;
+extern int TotalEps;
+extern int TotalMsgs;
+extern int TotalPseudos;
+extern int NumReadMsg;
+extern int MsgCount;           
+
+extern int MainDataSize;       /* size of dataarea for main chare      */
+extern int currentBocNum;
+extern int InsideDataInit;
+extern int mainChare_magic_number;
+extern struct chare_block * mainChareBlock;
+extern struct chare_block * currentChareBlock;
+
+extern int          * EpLanguageTable ;
+/* extern void **_CK_9_ReadMsgTable;  was in trans_decls.h, no longer global */
+extern FUNCTION_PTR *ROCopyFromBufferTable, *ROCopyToBufferTable ;
+extern int * EpIsImplicitTable;
+extern int * EpToMsgTable;
+extern int * EpChareTypeTable;
+extern FUNCTION_PTR * EpTable;
+extern MSG_STRUCT * MsgToStructTable; 
+extern int  * ChareSizesTable;
+extern FUNCTION_PTR * ChareFnTable ;
+extern PSEUDO_STRUCT * PseudoTable;
+extern char         ** EpNameTable;
+
+extern char **ChareNamesTable;
+extern int *EpChareTable;
+
+extern int msgs_processed, msgs_created;
+
+extern int disable_sys_msgs;
+extern int nodecharesProcessed;
+extern int nodebocMsgsProcessed;
+extern int nodeforCharesProcessed;
+extern int nodecharesCreated;
+extern int nodeforCharesCreated;
+extern int nodebocMsgsCreated;
+
+extern void *LocalQueueHead;
+extern void *SchedQueue;
+
+extern int PrintQueStat; 
+extern int PrintMemStat; 
+extern int PrintChareStat;
+extern int PrintSummaryStat;
+
+extern int RecdStatMsg;
+extern int RecdPerfMsg;
+
+extern int numHeapEntries, numCondChkArryElts;
+extern int MainChareLanguage ;
+
+extern int CallProcessMsg_Index ;
+extern int HANDLE_INCOMING_MSG_Index ;
+
diff --git a/src/ck-core/init.c b/src/ck-core/init.c
new file mode 100644 (file)
index 0000000..b32a597
--- /dev/null
@@ -0,0 +1,732 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.16  1995/05/03  20:56:44  sanjeev
+ * bug fixes for finding uninitialized modules
+ *
+ * Revision 1.15  1995/05/03  06:28:20  sanjeev
+ * registered _CkNullFunc
+ *
+ * Revision 1.14  1995/05/02  20:37:46  milind
+ * Added _CkNullFunc()
+ *
+ * Revision 1.13  1995/04/25  03:40:01  sanjeev
+ * fixed dynamic boc creation bug in ProcessBocInitMsg
+ *
+ * Revision 1.12  1995/04/23  20:53:14  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.11  1995/04/13  20:54:18  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.10  1995/04/06  17:46:21  sanjeev
+ * fixed bug in tracing Charm++ BranchInits
+ *
+ * Revision 1.9  1995/04/02  00:48:57  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.8  1995/03/25  18:25:40  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.7  1995/03/24  16:42:59  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.6  1995/03/21  20:55:23  sanjeev
+ * Changes for new converse names
+ *
+ * Revision 1.5  1995/03/17  23:38:27  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.4  1995/03/12  17:10:39  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.3  1994/12/02  00:02:26  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:39:52  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char     ident[] = "@(#)$Header$";
+/***************************************************************************/
+/* This is the main process that runs on each pe                           */
+/* */
+/***************************************************************************/
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+
+
+/* these two variables are set in registerMainChare() */
+int             _CK_MainChareIndex;
+int             _CK_MainEpIndex;
+
+int             ReadBuffSize = 0; /* this is set in registerReadOnly() */
+void          **_CK_9_ReadMsgTable;    /* was previously global */
+char           *ReadBufIndex;
+char           *ReadFromBuffer;
+
+#define BLK_LEN 512
+BOCINIT_QUEUE  *BocInitQueueHead;
+void *BocInitQueueCreate() ;
+ENVELOPE *DeQueueBocInitMsgs() ;
+
+/* these store argc, argv for use by CharmInit */
+extern int             userArgc;
+extern char          **userArgv;
+
+
+/* all these counts are incremented in register.c */
+extern int      fnCount;
+extern int      msgCount;
+extern int      chareCount;
+extern int      chareEpsCount; /* count of chare AND boc eps */
+extern int      pseudoCount;
+extern int      readMsgCount;
+extern int      readCount;     /* count of read-only functions. Should be
+                                * same as total number of modules */
+extern int     handlerCount ;  /* count of "language" handlers */
+
+
+extern void CPlus_ProcessBocInitMsg(); /* in cplus_node_init.c */
+extern void CPlus_CallCharmInit();     /* in cplus_node_init.c */
+extern void CPlus_SetMainChareID();    /* in cplus_node_init.c */
+extern void *CreateChareBlock();
+
+
+/* This is the "processMsg()" for Charm and Charm++ */
+extern void CallProcessMsg() ;
+extern int CallProcessMsg_Index ;
+
+/* This is the "handleMsg()" for Charm and Charm++ */
+extern void HANDLE_INCOMING_MSG() ;
+extern int HANDLE_INCOMING_MSG_Index ;
+
+
+/*Added By Milind 05/02/95 */
+
+void _CkNullFunc()
+{
+       CmiPrintf("[%d] In Null Function: Module Uninitialized\n", CmiMyPe());
+}
+
+/**** This is now in converse.c *****************
+startup(argc, argv)
+int             argc;
+char           *argv[];
+{
+       int             MainDataSize;
+       int             eps, num_boc, i;
+       void           *MainDataArea;
+       userArgc = ParseCommandOptions(argc, argv);
+
+       InitializeMessageMacros();
+
+        CkMemInit();
+        CmiInit(argc, argv);
+       CsdInit();
+       OtherQsInit();
+       StatInit();
+       InitializeDynamicBocMsgList();
+       InitializeBocDataTable();
+       InitializeBocIDMessageCountTable();
+       InitializeEPTables();
+
+
+       log_init();
+#ifdef DEBUGGING_MODE
+       trace_begin_computation();
+#endif
+       SysBocInit();   
+       msgs_created = msgs_processed = 0;
+       CondSendInit();
+       userArgv = argv;
+}
+*************************************************/
+
+
+
+static int CountArgs(argv)
+char **argv;
+{
+    int argc=0;
+    while (*argv) { argc++; argv++; }
+    return argc;
+}
+
+char **userArgv;
+int    userArgc;
+
+StartCharm(argv)
+char **argv;
+{
+       int             i;
+       char           *ReadBufMsg;
+
+        userArgc = ParseCommandOptions(CountArgs(argv), argv);
+        userArgv = argv;
+
+       InitializeMessageMacros();
+
+       CmiSpanTreeInit();
+
+        /* OtherQsInit(); this was combined with CsdInitialize */
+        StatInit();
+        InitializeDynamicBocMsgList();
+        InitializeBocDataTable();
+        InitializeBocIDMessageCountTable();
+        InitializeEPTables();
+        log_init();
+#ifdef DEBUGGING_MODE
+        trace_begin_computation();
+#endif
+        SysBocInit();
+        msgs_created = msgs_processed = 0;
+        CondSendInit();
+
+
+
+       if (CmiMyPe() == 0)
+       {
+               MsgCount = 0;   /* count # of messages being sent to each
+                                * node. assume an equal number gets sent to
+                                * every one. if there is a difference, have
+                                * to modify this somewhat */
+#ifdef DEBUGGING_MODE
+               trace_begin_charminit();
+#endif
+               if (MainChareLanguage == CHARMPLUSPLUS)
+               {
+                       CPlus_CallCharmInit(userArgc, userArgv);
+               }
+               else
+               {
+                       MainDataSize = ChareSizesTable[_CK_MainChareIndex];
+                       mainChareBlock = currentChareBlock =
+                               (CHARE_BLOCK *) CreateChareBlock(MainDataSize);
+
+                       SetID_chare_magic_number(mainChareBlock->selfID,
+                                                rand());
+                       /* Calling CharmInit entry point */
+                       NumReadMsg = 0;
+                       InsideDataInit = 1;
+
+                       (EpTable[_CK_MainEpIndex]) (NULL, currentChareBlock + 1,
+                                                   userArgc, userArgv);
+                       InsideDataInit = 0;
+               }
+#ifdef DEBUGGING_MODE
+               trace_end_charminit();
+#endif
+               /* create the buffer for the read only variables */
+               ReadBufMsg = (char *) CkAllocMsg(ReadBuffSize);
+               ReadBufIndex = ReadBufMsg;
+               if (ReadBuffSize > 0)
+                       CkMemError(ReadBufMsg);
+
+               /*
+                * in Charm++ the CopyToBuffer fns also send out the
+                * ReadonlyMsgs by calling ReadMsgInit()
+                */
+               for (i = 0; i < readCount; i++)
+                       (ROCopyToBufferTable[i]) ();
+
+               /*
+                * we are sending the id of the main chare along with the
+                * read only message. in future versions, we might eliminate
+                * this because the functionality can be expressed using
+                * readonly variables and MyChareID inside the main chare
+                */
+
+               BroadcastReadBuffer(ReadBufMsg, ReadBuffSize, mainChareBlock);
+
+               /*
+                * send a message with the count of initial messages sent so
+                * far, to all nodes; includes messages for read-buffer and
+                * bocs
+                */
+               BroadcastCount();
+       }
+       else
+       {
+               CharmInitLoop();
+       }
+       SysPeriodicCheckInit();
+
+       /* Loop();      - Narain 11/16 */
+}
+
+
+/*
+ * Receive read only variable buffer, read only messages and  BocInit
+ * messages. Start Boc's by allocating and filling the NodeBocTbl. Wait until
+ * (a) the  "count" message is received and (b) "count" number of initial
+ * messages are received.
+ */
+CharmInitLoop()
+{
+       int             i, id;
+       void           *usrMsg;
+       int             countInit = 0;
+       extern void    *CmiGetMsg();
+       int         countArrived = 0;
+       ENVELOPE       *envelope, *readvarmsg;
+
+       BocInitQueueHead = (BOCINIT_QUEUE *) BocInitQueueCreate();
+
+       while ((!countArrived) || (countInit != 0))
+       {
+               envelope = NULL;
+               while (envelope == NULL)
+                       envelope = (ENVELOPE *) CmiGetMsg();
+               if ((GetEnv_msgType(envelope) == BocInitMsg) ||
+                   (GetEnv_msgType(envelope) == ReadMsgMsg))
+                       UNPACK(envelope);
+               usrMsg = USER_MSG_PTR(envelope);
+               /* Have a valid message now. */
+               switch (GetEnv_msgType(envelope))
+               {
+
+               case BocInitMsg:
+                       EnQueueBocInitMsgs(envelope);
+                       countInit++;
+                       break;
+
+               case InitCountMsg:
+                       countArrived = 1;
+                       countInit -= GetEnv_count(envelope);
+                       CmiFree(envelope);
+                       break;
+
+               case ReadMsgMsg:
+                       id = GetEnv_other_id(envelope);
+                       _CK_9_ReadMsgTable[id] = (void *) usrMsg;
+                       countInit++;
+                       break;
+
+               case ReadVarMsg:
+                       ReadFromBuffer = usrMsg;
+                       countInit++;
+
+                       /* get the information about the main chare */
+                       mainChareBlock = (struct chare_block *)
+                               GetEnv_chareBlockPtr(envelope);
+                       mainChare_magic_number =
+                               GetEnv_chare_magic_number(envelope);
+                       if (MainChareLanguage == CHARMPLUSPLUS)
+                               CPlus_SetMainChareID();
+                       readvarmsg = envelope;
+                       break;
+
+               default:
+                       CmiSetHandler(envelope,CallProcessMsg_Index) ;
+                       CsdEnqueue(envelope);
+                       break;
+               }
+       }
+
+       /*
+        * call all the CopyFromBuffer functions for ReadOnly variables.
+        * _CK_9_ReadMsgTable is passed as an arg because it is no longer
+        * global
+        */
+       for (i = 0; i < readCount; i++)
+               (ROCopyFromBufferTable[i]) (_CK_9_ReadMsgTable);
+       CmiFree(readvarmsg);
+
+       while ( (envelope=DeQueueBocInitMsgs()) != NULL ) 
+               ProcessBocInitMsg(envelope);
+}
+
+ProcessBocInitMsg(envelope)
+ENVELOPE       *envelope;
+{
+       BOC_BLOCK      *bocBlock;
+       void           *usrMsg = USER_MSG_PTR(envelope);
+       int             current_ep = GetEnv_EP(envelope);
+       int             executing_boc_num = GetEnv_boc_num(envelope);
+       int             current_msgType = GetEnv_msgType(envelope);
+       if (IsCharmPlus(current_ep))
+       {                       /* Charm++ BOC */
+               CPlus_ProcessBocInitMsg(envelope, usrMsg, executing_boc_num, 
+                                       current_msgType, current_ep);
+       }
+       else
+       {
+               bocBlock = (BOC_BLOCK *) CreateBocBlock
+                       (GetEnv_sizeData(envelope));
+               bocBlock->boc_num = executing_boc_num;
+               SetBocDataPtr(executing_boc_num, (void *) (bocBlock + 1));
+               trace_begin_execute(envelope);
+               (*(EpTable[current_ep]))
+                       (usrMsg, GetBocDataPtr(executing_boc_num));
+               trace_end_execute(executing_boc_num, current_msgType,
+                                 current_ep);
+       }
+
+       /* for dynamic BOC creation, used in node_main.c */
+       return executing_boc_num ;
+}
+
+
+/* this call can only be made after the clock has been initialized */
+
+SysPeriodicCheckInit()
+{
+       LdbPeriodicCheckInit();
+}
+
+
+int 
+ParseCommandOptions(argc, argv)
+int             argc;
+char          **argv;
+{
+/* Removed Converse options into ConverseParseCommandOptions. - Sanjeev */
+       /*
+        * configure the chare kernel according to command line parameters.
+        * by convention, chare kernel parameters begin with '+'.
+        */
+       int             i, j, numSysOpts = 0, foundSysOpt = 0, end;
+       int             mainflag = 0, memflag = 0;
+
+       if (argc < 1)
+       {
+               CmiPrintf("Too few arguments. Usage> host_prog node_prog [...]\n");
+               exit(1);
+       }
+
+       end = argc;
+       if (CmiMyPe() == 0)
+               mainflag = 1;
+
+       for (i = 1; i < end; i++)
+       {
+               foundSysOpt = 0;
+               if (strcmp(argv[i], "+cs") == 0)
+               {
+                       PrintChareStat = 1;
+                       /*
+                        * if (mainflag) CmiPrintf("Chare Statistics Turned
+                        * On\n");
+                        */
+                       foundSysOpt = 1;
+               }
+               else if (strcmp(argv[i], "+ss") == 0)
+               {
+                       PrintSummaryStat = 1;
+                       /*
+                        * if(mainflag)CmiPrintf("Summary Statistics Turned
+                        * On\n");
+                        */
+                       foundSysOpt = 1;
+               }
+                else if (strcmp(argv[i], "+p") == 0 && i + 1 < argc)
+                {
+                        sscanf(argv[i + 1], "%d", &numPe);
+                        foundSysOpt = 2;
+                }
+                else if (sscanf(argv[i], "+p%d", &numPe) == 1)
+                {
+                        foundSysOpt = 1;
+                }
+               if (foundSysOpt)
+               {
+                       /* if system option, remove it. */
+                       numSysOpts += foundSysOpt;
+                       end -= foundSysOpt;
+                       for (j = i; j < argc - foundSysOpt; j++)
+                       {
+                               argv[j] = argv[j + foundSysOpt];
+                       }
+                       /* reset i because we shuffled everything down one */
+                       i--;
+               }
+
+       }
+       return (argc - numSysOpts);
+}
+
+
+
+#define TABLE_SIZE 256
+
+InitializeEPTables()
+{
+       int             i;
+       int             TotalFns;
+       int             TotalMsgs;
+       int             TotalChares;
+       int             TotalModules;
+       int             TotalReadMsgs;
+       int             TotalPseudos;
+
+
+       /*
+        * TotalEps     =  _CK_5mainChareEPCount(); TotalFns    =
+        * _CK_5mainFunctionCount(); TotalMsgs  =  _CK_5mainMessageCount();
+        * TotalChares  =  _CK_5mainChareCount(); TotalBocEps   =
+        * NumSysBocEps + _CK_5mainBranchEPCount();
+        */
+       TotalEps = TABLE_SIZE;
+       TotalFns = TABLE_SIZE;
+       TotalMsgs = TABLE_SIZE;
+       TotalChares = TABLE_SIZE;
+       TotalModules = TABLE_SIZE;
+       TotalReadMsgs = TABLE_SIZE;
+       TotalPseudos = TABLE_SIZE;
+
+       /*
+        * this table is used to store all ReadOnly Messages on processors
+        * other than proc 0. After they are received, they are put in the
+        * actual variables in the user program in the ...CopyFromBuffer
+        * functions
+        */
+       _CK_9_ReadMsgTable = (void **) CmiAlloc((TotalReadMsgs + 1) *
+                                              sizeof(void *));
+       if (TotalReadMsgs > 0)
+               CkMemError(_CK_9_ReadMsgTable);
+
+       ROCopyFromBufferTable = (FUNCTION_PTR *) CmiAlloc((TotalModules + 1) *
+                                                     sizeof(FUNCTION_PTR));
+       ROCopyToBufferTable = (FUNCTION_PTR *) CmiAlloc((TotalModules + 1) *
+                                                      sizeof(FUNCTION_PTR));
+       if (TotalModules > 0)
+       {
+               CkMemError(ROCopyFromBufferTable);
+               CkMemError(ROCopyToBufferTable);
+       }
+
+       EpTable = (FUNCTION_PTR *) CmiAlloc((TotalEps + 1) *
+                                          sizeof(FUNCTION_PTR));
+       EpIsImplicitTable = (int *) CmiAlloc((TotalEps + 1) * sizeof(int));
+       EpLanguageTable = (int *) CmiAlloc((TotalEps + 1) * sizeof(int));
+       for (i = 0; i < TotalEps + 1; i++)
+               EpIsImplicitTable[i] = 0;
+       EpNameTable = (char **) CmiAlloc((TotalEps + 1) * sizeof(char *));
+       EpChareTable = (int *) CmiAlloc((TotalEps + 1) * sizeof(int));
+       EpToMsgTable = (int *) CmiAlloc((TotalEps + 1) * sizeof(int));
+       EpChareTypeTable = (int *) CmiAlloc((TotalEps + 1) * sizeof(int));
+
+       if (TotalEps > 0)
+       {
+               CkMemError(EpTable);
+               CkMemError(EpIsImplicitTable);
+               CkMemError(EpLanguageTable);
+               CkMemError(EpNameTable);
+               CkMemError(EpChareTable);
+               CkMemError(EpToMsgTable);
+               CkMemError(EpChareTypeTable);
+       }
+
+       /*
+        * set all the system BOC EPs to be CHARM bocs because they dont get
+        * registered in the normal way
+        */
+       for (i = 0; i < chareEpsCount; i++)
+               EpLanguageTable[i] = -1;
+
+
+       _CK_9_GlobalFunctionTable = (FUNCTION_PTR *) CmiAlloc((TotalFns + 1) *
+                                                     sizeof(FUNCTION_PTR));
+       if (TotalFns > 0)
+               CkMemError(_CK_9_GlobalFunctionTable);
+
+
+       MsgToStructTable = (MSG_STRUCT *) CmiAlloc((TotalMsgs + 1) *
+                                                 sizeof(MSG_STRUCT));
+       if (TotalMsgs > 0)
+               CkMemError(MsgToStructTable);
+
+
+       ChareSizesTable = (int *) CmiAlloc((TotalChares + 1) * sizeof(int));
+       ChareNamesTable = (char **) CmiAlloc(TotalChares * sizeof(char *));
+       ChareFnTable = (FUNCTION_PTR *) CmiAlloc((TotalChares + 1) *
+                                               sizeof(FUNCTION_PTR));
+       if (TotalChares > 0)
+       {
+               CkMemError(ChareSizesTable);
+               CkMemError(ChareNamesTable);
+               CkMemError(ChareFnTable);
+       }
+
+       PseudoTable = (PSEUDO_STRUCT *) CmiAlloc((TotalPseudos + 1) *
+                                               sizeof(PSEUDO_STRUCT));
+       if (TotalPseudos > 0)
+               CkMemError(PseudoTable);
+
+
+
+       /** end of table allocation **/
+
+       /* Register the NullFunction to detect uninitialized modules */
+       registerMsg("NULLMSG",_CkNullFunc,_CkNullFunc,_CkNullFunc,0) ;
+       registerEp("NULLEP",_CkNullFunc,0,0,0) ;
+       registerChare("NULLCHARE",0,_CkNullFunc) ;
+       registerFunction(_CkNullFunc) ;
+       registerMonotonic("NULLMONO",_CkNullFunc,_CkNullFunc,CHARM) ;
+       registerTable("NULLTABLE",_CkNullFunc,_CkNullFunc) ;
+       registerAccumulator("NULLACC",_CkNullFunc,_CkNullFunc,_CkNullFunc,CHARM) ;
+
+       chareEpsCount += AddSysBocEps(EpTable);
+
+       /*
+        * This is the top level call to all modules for initialization. It
+        * is generated at link time by charmc, in module_init_fn.c
+        */
+       _CK_module_init_fn();
+
+       if ( MainChareLanguage == -1 ) {
+               CmiPrintf("[%d] ERROR: registerMainChare() not called : uninitialized module exists\n",CmiMyPe()) ;
+       }
+
+       /* Register the Charm handlers with Converse */
+       HANDLE_INCOMING_MSG_Index = CmiRegisterHandler(HANDLE_INCOMING_MSG) ;
+       CallProcessMsg_Index = CmiRegisterHandler(CallProcessMsg) ;
+
+
+
+       /* set all the "Total" variables so that the rest of the modules work */
+       TotalEps = chareEpsCount;
+       TotalFns = fnCount;
+       TotalMsgs = msgCount;
+       TotalChares = chareCount;
+       TotalModules = readCount;
+       TotalReadMsgs = readMsgCount;
+       TotalPseudos = pseudoCount;
+}
+
+/* Adding entry points for system branch office chares. */
+AddSysBocEps()
+{
+       LdbAddSysBocEps();
+       QDAddSysBocEps();
+       VidAddSysBocEps();
+       WOVAddSysBocEps();
+       TblAddSysBocEps();
+       AccAddSysBocEps();
+       MonoAddSysBocEps();
+       DynamicAddSysBocEps();
+       StatAddSysBocEps();
+
+       return (NumSysBocEps);  /* number of system boc-eps */
+}
+
+
+/* Broadcast the count of messages that are received during initialization. */
+BroadcastCount()
+{
+       ENVELOPE       *env;
+       void           *dummy_msg;
+       dummy_msg = (int *) CkAllocMsg(sizeof(int));
+       CkMemError(dummy_msg);
+       env = ENVELOPE_UPTR(dummy_msg);
+       SetEnv_destPE(env, ALL_NODES_EXCEPT_ME);
+       SetEnv_category(env, USERcat);
+       SetEnv_msgType(env, InitCountMsg);
+       SetEnv_destPeFixed(env, 1);
+
+       SetEnv_count(env, currentBocNum - NumSysBoc + 2 + NumReadMsg);
+
+       CkCheck_and_Broadcast(env, 0);
+       /* CkFreeMsg(dummy_msg);  commented on Jun 23 */
+}
+
+int 
+EmptyBocInitMsgs()
+{
+       return (BocInitQueueHead->length == 0);
+}
+
+
+void           *
+BocInitQueueCreate()
+{
+       BOCINIT_QUEUE  *queue;
+       queue = (BOCINIT_QUEUE *) CmiAlloc(sizeof(BOCINIT_QUEUE));
+       queue->block = (void **) CmiAlloc(sizeof(void *) * BLK_LEN);
+       queue->block_len = BLK_LEN;
+       queue->first = queue->block_len;
+       queue->length = 0;
+       return (void *) queue;
+}
+
+
+EnQueueBocInitMsgs(envelope)
+ENVELOPE       *envelope;
+{
+       int             num = GetEnv_boc_num(envelope);
+       int i ;
+
+       if (num > BocInitQueueHead->block_len)
+       {
+               void          **blk = BocInitQueueHead->block;
+               int             last;
+               BocInitQueueHead->block = (void **) CmiAlloc(sizeof(void *) * (num + BLK_LEN));
+               last = BocInitQueueHead->first + BocInitQueueHead->length;
+               for (i = BocInitQueueHead->first; i < last; i++)
+                       BocInitQueueHead->block[i] = blk[i];
+               BocInitQueueHead->block[num] = envelope;
+               BocInitQueueHead->length++;
+               CmiFree(blk);
+       }
+       else
+       {
+               BocInitQueueHead->block[num] = envelope;
+               BocInitQueueHead->length++;
+               if (BocInitQueueHead->first > num)
+                       BocInitQueueHead->first = num;
+       }
+}
+
+
+ENVELOPE *DeQueueBocInitMsgs()
+{
+       ENVELOPE      *envelope;
+       if (BocInitQueueHead->length)
+       {
+               envelope = BocInitQueueHead->block[BocInitQueueHead->first++];
+               BocInitQueueHead->length--;
+       /*      if (!BocInitQueueHead->length)
+                       BocInitQueueHead->first = BocInitQueueHead->block_len;
+       */
+               return envelope ;
+       }
+       else
+               return NULL ;
+}
+
+SysBocInit()
+{
+       LdbBocInit();
+       QDBocInit();
+       VidBocInit();
+       TblBocInit();
+       WOVBocInit();
+       DynamicBocInit();
+       StatisticBocInit();
+}
+
+
+
+hostep_error(msg, mydata)
+void           *msg, *mydata;
+{
+       CmiPrintf("****error*** main chare ep called on node %d.\n",
+                CmiMyPe());
+}
diff --git a/src/ck-core/init.doc b/src/ck-core/init.doc
new file mode 100755 (executable)
index 0000000..c1dc809
--- /dev/null
@@ -0,0 +1,25 @@
+       This directory includes the files for the main processes
+on the host and the node. The host and the node processes are quite
+similar. A description of the node process follows.
+
+       The node process looks like :
+               1. Call main_startup on node 0.
+               2. Call node_startup on all nodes.
+               3. Process all initialization messages.
+       The procedure main_startup initializes all the queues, managers,
+and executes the DataInit and the ChareInit sections of the user program.
+After executing the DataInit section a broadcast containing initial 
+values of all the pseudoglobal variables is carried out. This
+is defined in the translated file.
+       The procedure main_startup is executed only on node 0, but
+the rest are executed on all nodes. So there is a slight asynchrony 
+between the execution of node_startup on node 0 and the other nodes.
+node_startup initializes all the branches, quiescence detection and
+load balancing strategy. 
+       In the third stage all the initialization messages are processed.
+A count message is sent alongwith the initialization messages so that
+the nodes know how many messages to wait for.
+       The final stage is the procedure Loop defined in main. This is the
+main loop that handles all the messages, other than quiescence (which are
+executed as they come in). The messages are pumped from the queue using
+NodePumpMsgs.
diff --git a/src/ck-core/main.c b/src/ck-core/main.c
new file mode 100644 (file)
index 0000000..6c898e6
--- /dev/null
@@ -0,0 +1,264 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.11  1995/05/03  20:57:07  sanjeev
+ * bug fixes for finding uninitialized modules
+ *
+ * Revision 1.10  1995/04/24  20:17:13  sanjeev
+ * fixed typo
+ *
+ * Revision 1.9  1995/04/23  20:53:26  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.8  1995/04/13  20:54:53  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.7  1995/03/25  18:23:59  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.6  1995/03/23  22:12:51  sanjeev
+ * *** empty log message ***
+ *
+ * Revision 1.5  1995/03/17  23:35:04  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.4  1995/03/09  22:21:53  sanjeev
+ * fixed bug in BlockingLoop
+ *
+ * Revision 1.3  1994/12/01  23:55:10  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/18  20:32:17  narain
+ * Added a parameter (number of iterations) to Loop()
+ * Added functions DoCharm and EndCharm (main seperation)
+ *  - Sanjeev and Narain
+ *
+ * Revision 1.1  1994/11/03  17:38:31  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+
+/*************************************************************************/
+/** This file now contains only the Charm/Charm++ part of the run-time.
+    The core (scheduler/Converse) part is in converse.c                 */
+/*************************************************************************/
+
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+
+
+/* This is the "processMsg()" for Charm and Charm++ */
+int CallProcessMsg() ;
+int CallProcessMsg_Index ;
+/* This is the "handleMsg()" for Charm and Charm++ */
+int HANDLE_INCOMING_MSG() ;
+int HANDLE_INCOMING_MSG_Index ;
+
+
+#ifdef REPLAY_DEBUGGING
+
+HANDLE_INCOMING_MSG(env)
+ENVELOPE *env;
+{
+       /* Fill in the language field in the message */
+       CmiSetHandler(env,CallProcessMsg_Index) ;
+       
+       CsdEnqueue(env);
+}
+
+#else
+
+/* This is the handler function for Charm and Charm++, which is called
+   immediately when a message is received from the network */
+
+HANDLE_INCOMING_MSG(env)
+ENVELOPE *env;
+{
+       /* send to ldb strategy to extract load information */
+       LdbStripMsg(env);
+
+       switch (GetEnv_category(env)) {
+       case IMMEDIATEcat :
+               CallProcessMsg(env, USER_MSG_PTR(env));
+               break;
+
+       case USERcat :
+               /* Fill in the language field in the message */
+               CmiSetHandler(env,CallProcessMsg_Index) ;
+
+               if (!GetEnv_destPeFixed(env)) { 
+                       /* if destPeFixed==0, msg is always USERcat */
+                       Ldb_NewChare_FromNet(env);
+               }
+               else 
+                       CsdEnqueue(env);
+               break;
+
+       default :
+               CmiPrintf("*** ERROR *** Illegal Message Cat. %d\n", 
+                   GetEnv_category(env));
+       }
+       TRACE(CmiPrintf("[%d] Handled message.\n", CmiMyPe()));
+}
+#endif
+
+
+
+
+
+CallProcessMsg(envelope)
+ENVELOPE *envelope;
+{
+       EntryPointType current_ep = GetEnv_EP(envelope);
+
+       UNPACK(envelope);
+
+       switch ( EpLanguageTable[current_ep] ) {
+           case CHARM :
+               ProcessMsg(envelope) ;
+               break ;
+
+           case CHARMPLUSPLUS :
+               CPlus_ProcessMsg(envelope) ;
+               break ;
+
+           default :
+               CmiPrintf("[%d] ERROR : Language type of entry-point %d undefined. Possibly uninitialized module.\n",CmiMyPe(),current_ep) ;
+       }
+}
+       
+
+ProcessMsg(envelope)
+ENVELOPE *envelope;
+{
+/* only Charm messages come here */
+
+       int id;
+       void * CreateChareBlock();
+       ChareNumType executing_boc_num;
+       int current_msgType = GetEnv_msgType(envelope);
+       EntryPointType current_ep = GetEnv_EP(envelope);
+       void *usrMsg ;
+
+       TRACE(CmiPrintf("[%d] ProcessMsg: msgType = %d, ep = %d\n",
+           CmiMyPe(), current_msgType, current_ep));
+
+       usrMsg = USER_MSG_PTR(envelope);
+       switch (current_msgType)
+       {
+
+       case NewChareMsg:
+
+               TRACE(CmiPrintf("[%d] Loop: isVID=%d, sizeData=%d\n",
+                   CmiMyPe(), GetEnv_isVID(envelope), GetEnv_sizeData(envelope)));
+
+               /* allocate data area, and strart execution. */
+               currentChareBlock = (struct chare_block *)
+                   CreateChareBlock(GetEnv_sizeData(envelope));
+               SetID_chare_magic_number(currentChareBlock->selfID,
+                   nodecharesProcessed);
+
+               TRACE(CmiPrintf("[%d] Loop: currentChareBlock=0x%x, magic=%d\n",
+                   CmiMyPe(), currentChareBlock, 
+                   GetID_chare_magic_number(currentChareBlock->selfID)));
+
+               /* If virtual block exists, get all messages for this chare     */
+               if (GetEnv_isVID(envelope))
+                       VidSend(currentChareBlock, GetEnv_onPE(envelope),
+                           GetEnv_vidBlockPtr(envelope));
+               trace_begin_execute(envelope);
+               (*(EpTable[current_ep])) (usrMsg, currentChareBlock + 1);
+               trace_end_execute(nodecharesProcessed, current_msgType, current_ep);
+
+               nodecharesProcessed++;
+               break;
+
+
+       case ForChareMsg:
+               TRACE(CmiPrintf("[%d] Loop: Message type is ForChareMsg.\n",
+                   CmiMyPe()));
+
+               currentChareBlock = (void *) GetEnv_chareBlockPtr(envelope);
+               nodeforCharesProcessed++;
+
+               TRACE(CmiPrintf("[%d] Loop: currentChareBlock=0x%x\n",
+                   CmiMyPe(), currentChareBlock));
+               TRACE(CmiPrintf("[%d] Loop: envelope_magic=%d, id_magic=%d\n",
+                   CmiMyPe(), GetEnv_chare_magic_number(envelope),
+                   GetID_chare_magic_number(currentChareBlock->selfID)));
+
+               if (GetEnv_chare_magic_number(envelope) ==
+                   GetID_chare_magic_number(currentChareBlock->selfID))
+               {
+                       id = GetEnv_chare_magic_number(envelope);
+                       trace_begin_execute(envelope);
+                       (*(EpTable[current_ep]))
+                           (usrMsg,currentChareBlock + 1);
+                       trace_end_execute(id, current_msgType, current_ep);
+               }
+               else 
+                       CmiPrintf("[%d] *** ERROR *** Message to dead chare at entry point %d.\n", CmiMyPe(),  EpChareTable[current_ep]);
+
+               break;
+
+
+       case DynamicBocInitMsg:
+
+               /* ProcessBocInitMsg handles Charm++ bocs properly */
+               executing_boc_num = ProcessBocInitMsg(envelope);
+
+               /* This process of registering the new boc using the
+                          spanning tree is exactly the same for Charm++ */
+               RegisterDynamicBocInitMsg(&executing_boc_num, NULL);
+               break;
+
+
+       case BocMsg:
+       case LdbMsg:
+       case QdBocMsg:
+       case BroadcastBocMsg:
+       case QdBroadcastBocMsg:
+               executing_boc_num = GetEnv_boc_num(envelope);
+               trace_begin_execute(envelope);
+
+TRACE(CmiPrintf("[%d] ProcessMsg: Executing message for %d boc %d\n", 
+CmiMyPe(), current_ep, executing_boc_num));
+
+               (*(EpTable[current_ep]))(usrMsg, 
+                           GetBocDataPtr(executing_boc_num));
+
+               trace_end_execute(executing_boc_num, current_msgType, current_ep);
+               nodebocMsgsProcessed++;
+               break;
+
+
+       case VidMsg:
+               current_ep = GetEnv_vidEP(envelope);
+               trace_begin_execute(envelope);
+               (*(EpTable[current_ep])) (usrMsg, NULL);
+               trace_end_execute(VidBocNum, current_msgType, current_ep);
+               break;
+
+
+       default :
+               CmiPrintf("*** ERROR *** Illegal Msg %d in Loop for EP %d.\n", GetEnv_msgType(envelope), GetEnv_EP(envelope));
+       }
+       QDCountThisProcessing(current_msgType);
+}
diff --git a/src/ck-core/main.doc b/src/ck-core/main.doc
new file mode 100755 (executable)
index 0000000..da67a64
--- /dev/null
@@ -0,0 +1,20 @@
+       This directory includes the files for the main processes
+on the host and the node. The host and the node processes are quite
+similar. A description of the node process follows.
+
+       The node process looks like :
+               1. Call main_startup on node 0.
+               2. Call node_startup on all nodes.
+               3. Process all initialization messages.
+               4. Enter loop to process messages.
+       The final stage is the procedure Loop. This is the main loop
+that handles all the messages, other than quiescence (which are executed
+as they come in). The messages are pumped from the queue using NodePumpMsgs.
+
+The procedure to pump messages into the system - NodePumpMsgs. NodePumpMsgs,
+referred to as Pump hereafter, looks at the local queue, which includes
+messages sent locally between chares, and the system by a probe function
+- McProbe. If there are any quiescence messages it executes them directly,
+all other messages are queued up in the appropriate queues and the
+control is returned to the Loop in main.
+
diff --git a/src/ck-core/memstuff.c b/src/ck-core/memstuff.c
new file mode 100644 (file)
index 0000000..f83703e
--- /dev/null
@@ -0,0 +1,200 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/04/25  04:32:43  narain
+ * moved CKMEM_UNIT from mem_common.c to both memory managers
+ *
+ * Revision 1.4  1995/04/02  00:44:51  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.3  1995/03/12  17:12:47  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.2  1994/11/11  06:06:17  brunner
+ * Since this file is #include-ed, got rid of static char in RCS header
+ *
+ * Revision 1.1  1994/11/03  17:34:41  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#include <stdio.h>
+
+#define _CK_MEMORY_MANAGER
+#include "chare.h"
+#undef _CK_MEMORY_MANAGER
+#include "trans_defs.h"
+#include "trans_decls.h"
+
+void * CmiAllocPackBuffer(msg, size)
+char *msg;
+int size;
+{
+       int i;
+       int prio_size;
+       int pack_size;
+       int headersize;
+       ENVELOPE *envelope, *pack_envelope;
+
+    pack_size = ((size + 3) & ~3);
+    prio_size = MSG_PRIORITY_SIZE(msg);
+    pack_envelope = (ENVELOPE *) 
+       CmiAlloc(TOTAL_MSG_SIZE(pack_size, prio_size));
+
+       /*** Now we need to copy the envelope  ***/
+       envelope = ENVELOPE_UPTR(msg); 
+       headersize = (msg - (char *) envelope);
+       memcpy( ((char *) pack_envelope), ((char *) envelope), headersize);
+
+       /**************** Converted to memcpy (Amitabh) ************/
+       /** for (i=0; i<headersize; i++) **/  
+       /** ((char *) pack_envelope)[i] = ((char *) envelope)[i]; **/
+       /**************** Converted to memcpy (Amitabh) ************/
+
+       /*** Now we insert the priority field ***/
+    INSERT_PRIO_OFFSET(pack_envelope, pack_size, prio_size);
+       COPY_PRIORITY(envelope, pack_envelope);
+    return( (void *) USER_MSG_PTR(pack_envelope));
+}
+
+
+void *CkAllocMsg(request)
+int request;
+{
+    ENVELOPE *envptr;
+
+    request = ((request + 3) & ~3);
+    envptr = (ENVELOPE *) CmiAlloc(TOTAL_MSG_SIZE(request, 0));
+    CkMemError(envptr);
+    SetEnv_isPACKED(envptr, NO_PACK);
+    SetEnv_packid(envptr, 0);
+    INSERT_PRIO_OFFSET(envptr, request, 0);
+    return( (void *) USER_MSG_PTR(envptr));
+}
+
+
+
+
+CkFreeMsg(ptr)
+char *ptr;
+{
+    ENVELOPE *envptr;
+
+    envptr = ENVELOPE_UPTR(ptr);
+    CmiFree(envptr);
+}
+
+
+/* Makes a copy of the envelope and the priority fields of the message passed
+   to it and returns the envelope */
+
+ENVELOPE *CkCopyEnv(env)
+ENVELOPE *env ;
+{
+        int size = CmiSize(env) ;   /* size of env in bytes */
+        ENVELOPE *newenv ;
+
+        newenv = (ENVELOPE *) CmiAlloc(size) ;
+        memcpy(newenv, env, size) ;
+
+        return(newenv) ;
+}
+
+/* Makes a copy of the entire system message (Envelope, priorities, user 
+   message et al.) and returns a pointer to the user message */
+
+void *CkCopyMsg(sourceUptr)
+char *sourceUptr ;
+{
+    int size ;
+    ENVELOPE *env, *newenv;
+
+    env = ENVELOPE_UPTR(sourceUptr) ;
+    
+    PACK(env);
+    size = CmiSize(env) ;   /* size of env in bytes */
+    newenv = (ENVELOPE *) CmiAlloc(size) ;
+    memcpy(newenv, env, size) ;
+    UNPACK(env);
+    UNPACK(newenv);
+    return((void *)USER_MSG_PTR(newenv)) ;
+}
+
+
+
+/*****************************************************************
+The message allocation calls CkAllocMsg and CkAllocPrioMsg     
+inside the user program are translated to the GenericCkAlloc
+call in the following manner :
+
+CkAllocMsg(Type) -->  GenericCkAlloc(TypeId, sizeof(Type), 0) ;
+CkAllocPrioMsg(Type,prio) -->  GenericCkAlloc(TypeId, sizeof(Type), prio) ;
+
+For varsize msgs :
+CkAllocMsg(Type,sizearray) -->  
+       (MsgToStructTable[TypeId].allocfn)(TypeId,sizeof(Type),sizearray,0) ;
+CkAllocPrioMsg(Type,prio,sizearray) -->  
+       (MsgToStructTable[TypeId].allocfn)(TypeId,sizeof(Type),sizearray,prio);
+where the translator-generated allocfn template is :
+allocfn(id, msgsize, sizearray, prio)
+{
+       ... determine total message size (including varsize arrays) ...
+       GenericCkAlloc(id, total_msg_size, prio) ;
+       ... set varsize array pointers ...
+}
+
+- Sanjeev
+
+/*****************************************************************/
+
+void * GenericCkAlloc(msgno, msgsize, prio_size)
+int msgno;
+int msgsize;
+int prio_size;
+{
+       ENVELOPE *env;
+
+    /* msgsize is in bytes since theres a sizeof(MsgType) done by caller */
+    msgsize = ((msgsize + 3) & ~3);
+
+    /* priosize is in words */
+    prio_size *= 4 ;
+/*    prio_size = ((prio_size + 3) & ~3);  this was a bug : Sanjeev 3/11/95 */
+
+    env = (ENVELOPE *) CmiAlloc(TOTAL_MSG_SIZE(msgsize, prio_size));
+    CkMemError(env);
+
+    INSERT_PRIO_OFFSET(env, msgsize, prio_size);
+
+    SetEnv_isPACKED(env, NO_PACK);
+    SetEnv_packid(env, 0);
+
+    if (MsgToStructTable[msgno].pack != NULL)
+#ifdef SHARED
+       {       
+          env->needsPack = UNPACKED;
+       env->packid = msgno;
+       }
+#else
+    {
+        SetEnv_isPACKED(env, UNPACKED);
+        SetEnv_packid(env, msgno);
+    }
+#endif
+    return( (void *) USER_MSG_PTR(env));
+}
+
diff --git a/src/ck-core/mono.c b/src/ck-core/mono.c
new file mode 100644 (file)
index 0000000..539ed0f
--- /dev/null
@@ -0,0 +1,146 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:55:22  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/12/01  23:58:00  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:56  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "mono.h"
+
+void * GetMonoMsgPtr() ;
+
+extern void * CPlus_CallMonoInit() ;
+extern void * CPlus_GetMonoMsgPtr() ;
+extern void CPlus_CallUpdateFn() ;
+extern void CPlus_SetMonoId() ;
+
+
+void * MonoValue(bocnum)
+int bocnum;
+{
+        return( GetMonoMsgPtr((MONO_DATA *) GetBocDataPtr(bocnum)) );
+}
+
+MonoIDType CreateMono(id, initmsg, ReturnEP, ReturnID)
+int id;
+char *initmsg;
+EntryPointType ReturnEP;
+ChareIDType *ReturnID;
+{
+       int boc;
+       ENVELOPE *env = (ENVELOPE  *) ENVELOPE_UPTR(initmsg);
+
+       SetEnv_other_id(env, id);
+       boc = GeneralCreateBoc(sizeof(MONO_DATA), MONO_BranchInit_EP,
+                        initmsg,  ReturnEP, ReturnID);
+TRACE(CmiPrintf("[%d] CreateMono: boc = %d\n", CmiMyPe(), boc));
+       return(boc);
+}
+
+
+MONO_BranchInit_Fn(msg, mydata)
+void *msg;
+MONO_DATA *mydata;
+{
+       ENVELOPE * env = (ENVELOPE *) ENVELOPE_UPTR(msg);
+
+       mydata->id = GetEnv_other_id(env);
+       mydata->time = 0;
+
+        if ( IsCharmPlusPseudo(mydata->id) ) {
+            mydata->dataptr = CPlus_CallMonoInit(mydata->id, msg) ;
+            CPlus_SetMonoId(mydata->dataptr,MyBocNum(mydata)) ;
+        }
+        else
+            mydata->dataptr = (void *) (*(PseudoTable[mydata->id].initfn))
+                                       (NULL, msg);
+}
+
+
+
+_CK_9MONO_BranchNewValue(mydata, x)
+MONO_DATA *mydata; 
+char *x;
+{
+       if ((*(PseudoTable[mydata->id].pseudo_type.mono.updatefn))
+               (mydata->dataptr, x))
+       {
+               _CK_BroadcastMono(GetMonoMsgPtr(mydata), ((BOC_BLOCK *)mydata-1)->boc_num) ;
+       }
+}
+
+
+MONO_BranchUpdate_Fn(msg, mydata)
+char *msg;
+MONO_DATA *mydata;
+{
+        if ( IsCharmPlusPseudo(mydata->id) )
+                CPlus_CallUpdateFn(mydata->dataptr,msg) ;
+        else
+               (*(PseudoTable[mydata->id].pseudo_type.mono.updatefn))
+               (mydata->dataptr, msg);
+}
+
+
+
+MonoAddSysBocEps()
+{
+       EpTable[MONO_BranchInit_EP] = MONO_BranchInit_Fn;
+       EpTable[MONO_BranchUpdate_EP] = MONO_BranchUpdate_Fn;
+}
+
+
+void * _CK_9GetMonoDataPtr(monodata)
+MONO_DATA *monodata;
+{
+       return(monodata->dataptr);
+}
+
+FUNCTION_PTR _CK_9GetMonoCompareFn(monodata)
+MONO_DATA *monodata;
+{
+       return(PseudoTable[monodata->id].pseudo_type.mono.updatefn);
+}
+
+void * GetMonoMsgPtr(mydata)
+MONO_DATA *mydata ;
+{
+       if ( IsCharmPlusPseudo(mydata->id) ) 
+               return(CPlus_GetMonoMsgPtr(mydata->dataptr)) ;
+       else
+               return(mydata->dataptr) ;
+}
+
+_CK_BroadcastMono(msg, bocnum)
+void *msg ; 
+int bocnum ;
+{
+       char *tmsg;
+
+       tmsg = (char *) CkCopyMsg(msg);
+       GeneralBroadcastMsgBranch(MONO_BranchUpdate_EP,
+                       tmsg,   IMMEDIATEcat, BroadcastBocMsg, bocnum) ;
+}
diff --git a/src/ck-core/mono.h b/src/ck-core/mono.h
new file mode 100644 (file)
index 0000000..8d6a4c6
--- /dev/null
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:24:34  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:11  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*      Authors: Wayne Fenton, Balkrishna Ramkumar, Vikram A. Saletore    */
+/*                    Amitabh B. Sinha  and  Laxmikant V. Kale            */
+/*              (C) Copyright 1990 The Board of Trustees of the           */
+/*                          University of Illinois                        */
+/*                           All Rights Reserved                          */
+/*                                                                        */
+/**************************************************************************/
+
+typedef int MonoIDType;
+
+#define UP_WAIT_TIME 200
+#define MAX_UP_WAIT_TIME 5*200
+
+typedef struct {
+       int id;
+       int time;
+       char *dataptr;
+       int ismodified;
+} MONO_DATA;
+
+/* void * _CK_9GetMonoDataPtr();  */
+FUNCTION_PTR _CK_9GetMonoCompareFn();
diff --git a/src/ck-core/msg_macros.h b/src/ck-core/msg_macros.h
new file mode 100644 (file)
index 0000000..f71457d
--- /dev/null
@@ -0,0 +1,153 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.4  1995/03/17  23:37:57  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1995/03/12  17:10:05  sanjeev
+ * changes for new msg macros
+ *
+ * Revision 1.2  1994/11/11  05:24:19  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:08  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+
+/**********************************************************************
+ THIS FILE CONSTITUTES THE NEW FORMAT OF A Charm MESSAGE 
+ This file provides access macros for extracting the different
+ sections of a message. The organisation of a message is as follows 
+
+           -------------------------------------
+           | env | ldb | pad | user | priority |
+           -------------------------------------
+   The sizes of the fields are as follows:
+       envelope      : sizeof(ENVELOPE)
+                        (ENVELOPE is defined in env_macros.h)
+                       First word in ENVELOPE is the core language field.
+       ldb           : LDB_ELEM_SIZE is a global variable defined by the
+                        load balancing module
+       pad           : padding to ensure that the message header ends at a
+                       double word boundary.
+       user          : the user message data.
+       priority      : bit-vector (variable size)
+
+
+************************************************************************
+ The following variables reflect the message format above. If any
+change is made to the format, the initialization of the variables must
+be altered. The variables are initialized in InitializeMessageMacros()
+in main/common.c. Compile time constants are #defines. 
+All variables reflect sizes in BYTES.                  
+************************************************************************/
+
+extern int PAD_SIZE, HEADER_SIZE;
+extern int LDB_ELEM_SIZE ;
+#define ENVELOPE_SIZE sizeof(ENVELOPE)
+
+extern int _CK_Env_To_Usr;
+#define _CK_Env_To_Ldb ENVELOPE_SIZE
+
+extern int _CK_Ldb_To_Usr;
+#define _CK_Ldb_To_Env (-ENVELOPE_SIZE)
+
+extern int _CK_Usr_To_Env, _CK_Usr_To_Ldb ;
+
+
+
+
+#define TOTAL_MSG_SIZE(usrsize, priosize) (HEADER_SIZE + priosize + usrsize)
+#define CHARRED(x) ((char *) (x))
+
+
+
+/**********************************************************************/
+/* The following macros assume that -env- is an ENVELOPE pointer */
+/**********************************************************************/
+#define LDB_ELEMENT_PTR(env)  \
+       (LDB_ELEMENT *) (CHARRED(env) + _CK_Env_To_Ldb)
+
+#define USER_MSG_PTR(env)\
+    (CHARRED(env) + _CK_Env_To_Usr)
+
+#define COPY_PRIORITY(env1, env2) {\
+        if ( GetEnv_PrioType(env1) == 0 ) { \
+                SetEnv_PrioType(env2,0) ; \
+                SetEnv_IntegerPrio(env2, GetEnv_IntegerPrio(env1)) ; \
+        } \
+        else { \
+                char *ptr1, *ptr2; \
+                SetEnv_PrioType(env2,1) ; \
+                ptr1 = (char *)env1 + *((int *)GetEnv_PrioOffset(env1));\
+                ptr2 = (char *)env2 + *((int *)GetEnv_PrioOffset(env2));\
+                memcpy( ((char *) ptr2), ((char *) ptr1), \
+                                GetEnv_PrioSize(env1) );   \
+        } \
+}
+#define MSG_PRIORITY_PTR(env, priorityptr) GetEnv_PriorityPtr(env,priorityptr)
+#define INSERT_PRIO_OFFSET(env, usrsize, priosize)\
+{\
+    if ( priosize > 4 ) { \
+        SetEnv_PrioType(env,1) ; \
+        SetEnv_PrioOffset(env,usrsize+_CK_Env_To_Usr) ; \
+        SetEnv_PrioSize(env,priosize) ; \
+    } \
+    else \
+        SetEnv_PrioType(env,0) ; \
+}
+
+
+
+/**********************************************************************/
+/* the following macros assume that -ldbptr- is a LDB_ELEMENT pointer */
+/**********************************************************************/
+
+#define ENVELOPE_LDBPTR(ldbptr) \
+       (ENVELOPE *) (CHARRED(ldbptr) + _CK_Ldb_To_Env)
+
+#define USR_MSG_LDBPTR(ldbptr) \
+       (CHARRED(ldbptr) + _CK_Ldb_To_Usr)
+
+
+/**********************************************************************/
+/* the following macros assume that "usrptr" is a pointer to a user defined 
+   message */
+/**********************************************************************/
+#define ENVELOPE_UPTR(usrptr)\
+       (ENVELOPE *) (CHARRED(usrptr) + _CK_Usr_To_Env)
+
+#define LDB_UPTR(usrptr)\
+    (LDB_ELEMENT *) (CHARRED(usrptr) + _CK_Usr_To_Ldb)
+
+#define PRIORITY_UPTR(usrptr) \
+    (PVECTOR *) ( ReturnEnv_PriorityPtr(CHARRED(usrptr) + _CK_Usr_To_Env) )
+
+#define MSG_PRIORITY_SIZE(usrptr) \
+               GetEnv_PrioSize(CHARRED(usrptr) + _CK_Usr_To_Env)
+
+
diff --git a/src/ck-core/prio_macros.h b/src/ck-core/prio_macros.h
new file mode 100644 (file)
index 0000000..5ea31fe
--- /dev/null
@@ -0,0 +1,227 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:25:06  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:21  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/************************************************************************/
+/*                                                                     */
+/*                     Malloc Macro definitions                        */
+/*                                                                     */
+/************************************************************************/
+
+#define PGEN_COPY_VECTOR(vector1_ptr, vector2_ptr)\
+{\
+       PVECTOR         *p_ptr, *c_ptr;\
+       int             vector1_size;\
+\
+       p_ptr = vector1_ptr;\
+       c_ptr = vector2_ptr;\
+       if ( (*p_ptr >> 24) > 24 )\
+               vector1_size = ( ((*p_ptr >> 24) - 25) >> 5 )  + 2;\
+       else\
+               vector1_size = 1;\
+\
+        for (;p_ptr < vector1_ptr+vector1_size; p_ptr++,c_ptr++)\
+               *c_ptr = *p_ptr;\
+}
+
+#define PGEN_VECTOR_SIZE(ptr,size)\
+{\
+       if ( (*ptr >> 24) > 24 )\
+               size = ( ((*ptr >> 24) - 25) >> 5 )  + 2;\
+       else\
+               size = 1;\
+}
+
+#define PGEN_VECTOR_LENGTH(ptr,length)\
+{\
+       length = (*ptr >> 24) & 0xff;\
+}
+
+
+#define PGEN_GET_NEW_PVECTOR(ptr1,ptr2,branch_bits,ptr2_rel_prio)\
+{\
+       unsigned int    all_zeros=0x0, all_ones=0xffffffff;\
+       PVECTOR *p_ptr, *c_ptr;\
+       int     ptr1_size, ptr2_size;\
+       int     shift;\
+       int     ptr1_length, ptr2_length;\
+\
+          ptr1_length =  *ptr1 >> 24;\
+          ptr2_length =  ptr1_length + branch_bits;\
+\
+          if ( ptr2_length > 248 )\
+               ptr2_length = 248;\
+\
+          if ( ptr1_length > 24)\
+               ptr1_size = ( (ptr1_length - 25) >> 5 )  + 2;\
+          else\
+               ptr1_size = 1;\
+\
+          if ( ptr2_length > 24)\
+               ptr2_size = ( (ptr2_length - 25) >> 5 )  + 2;\
+          else\
+               ptr2_size = 1;\
+\
+          branch_bits = ptr2_length - ptr1_length;\
+          p_ptr = ptr1;\
+          c_ptr = ptr2;\
+          for(;p_ptr < ptr1+ptr1_size; p_ptr++,c_ptr++)\
+               *c_ptr = *p_ptr;\
+          c_ptr = ptr2;\
+          *ptr2 = (*ptr2 & 0x0ffffff) | ((ptr2_length & 0x0ff) << 24 );\
+\
+       if ( ptr2_rel_prio > 0 )\
+       {\
+          if  ( ptr1_size == 1 )\
+          {\
+            if ( ptr2_size == ptr1_size )\
+            {\
+               /* clear and modify the first word of the child bit vector */\
+               *ptr2 = ( *ptr2 & (all_ones << (24-ptr1_length)) )\
+                       | (ptr2_rel_prio << (24-ptr2_length) );\
+               ptr2 = c_ptr;\
+            }\
+            else\
+            {\
+               /* if the parent bit vector is on a word boundry */\
+               if ( ((ptr1_length + 8) % 32) == 0)\
+               {\
+                  /* set child ptr to the last word of the child vector */\
+                  ptr2 = ptr2 + (ptr2_size - 1);\
+                  /* append the child priority to that word */\
+                  *ptr2 = (*ptr2 & all_zeros)\
+                          | (ptr2_rel_prio << (32-branch_bits));\
+               ptr2 = c_ptr;\
+               }/* ptr1_length +8 % 32 == 0 */\
+               else\
+               { /* if the parent bit vector is NOT on a word boundry */\
+                     /*append the child priority to the child word */\
+                  *ptr2 = (*ptr2 & (all_ones << (24-ptr1_length)))\
+                         | (ptr2_rel_prio >> (branch_bits-(24-ptr1_length)) );\
+                  /* go to the next word */\
+                  ptr2++;\
+                  /* append the remaining priority bits to the next\
+                       child bit vector*/\
+                  *ptr2 = (*ptr2 & all_zeros)\
+                     | ( ptr2_rel_prio << (32-(branch_bits-(24-ptr1_length))) );\
+               ptr2 = c_ptr;\
+               }/* ptr1_length +8 % 32 != 0 */\
+            }\
+          }\
+          else\
+          {\
+            if (ptr2_size == ptr1_size)\
+            {\
+               /* set child ptr to the last word of the child vector */\
+               ptr2 = ptr2 + ptr2_size - 1;\
+               shift = 32 - ((ptr1_length - 24) % 32) - branch_bits;\
+               /* modify the last word of the child bit vector */\
+               *ptr2 = (*ptr2 & (all_ones << (shift+branch_bits)) )\
+                       | (ptr2_rel_prio << shift );\
+               ptr2 = c_ptr;\
+            }\
+            else\
+            {\
+               /* if the parent bit vector is on a word boundry */\
+               if ( ((ptr1_length + 8) % 32) == 0)\
+               {\
+                  /* set child ptr to the last word of the child vector */\
+                  ptr2 = ptr2 + ptr2_size - 1;\
+                  /* append the child priority to that word */\
+                  *ptr2 = (*ptr2 & all_zeros)\
+                          | (ptr2_rel_prio << (32-branch_bits));\
+               ptr2 = c_ptr;\
+               }/* ptr1_length +8 % 32 == 0 */\
+               else\
+               { /* if the parent bit vector is NOT on a word boundry */\
+                /*set child ptr to the last BUT ONE word of the childvector*/\
+                  ptr2 = ptr2 + ptr2_size - 2;\
+                  shift = branch_bits - ( ((ptr1_size<<5) - 8) - ptr1_length);\
+                  /*append the child priority to the child word */\
+                  *ptr2 =(*ptr2 & (all_ones<<((ptr1_size<<5)-8-ptr1_length)))\
+                          | (ptr2_rel_prio >> shift );\
+                  /* go to the next word */\
+                  ptr2++;\
+                  /* append the remaining priority bits to the next\
+                       child bit vector*/\
+                  *ptr2 = (*ptr2 & all_zeros) | ptr2_rel_prio << (32 - shift);\
+                  ptr2 = c_ptr;\
+               }/* ptr1_length +8 % 32 != 0 */\
+            }\
+          }\
+       }\
+}
+
+#define        PGEN_IDENTICAL_PVECTOR(ptrP, new_priority_ptr)\
+{\
+          int  ptrP_size;\
+\
+          /* get vector size */\
+          if ( (*ptrP >> 24) > 24 )\
+               ptrP_size = ( ((*ptrP >> 24) - 25) >> 5 )  + 2;\
+          else\
+               ptrP_size = 1;\
+\
+          new_priority_ptr = (PVECTOR *) CmiAlloc(sizeof(PVECTOR)*ptrP_size);\
+          /* copy the parent bit vector to child bit vector */\
+          PGEN_COPY_VECTOR(ptrP, new_priority_ptr);\
+}
+
+
+#define        CEIL_LOG2(m, k)\
+{\
+       int     j;\
+\
+       j = 020000000000;\
+\
+       if ( k == 0 )\
+               m = 32;\
+       else if ( k==1 )\
+               m = 31;\
+       else if ( k==2 )\
+               m = 30;\
+       else if ( k==3 )\
+               m = 30;\
+       else if ( k==4)\
+               m = 29;\
+       else if ( k==5)\
+               m = 29;\
+       else if ( k==6 )\
+               m = 29;\
+       else if ( k==7 )\
+               m = 29;\
+       else if ( k > 7)\
+       for ( m=0; m < 32; m++ )\
+       {\
+               if ( (j & k) == 0 )\
+                       j = j >> 1;\
+               else\
+                       break;\
+       }\
+\
+       m = 32 - m;\
+}
+
+
+
+
diff --git a/src/ck-core/pseudo.doc b/src/ck-core/pseudo.doc
new file mode 100755 (executable)
index 0000000..1893fa1
--- /dev/null
@@ -0,0 +1,25 @@
+       This directory contains the files for the pseudoglobal variables.
+       All of them are implemented as branch office chares. 
+       The initial values of these pseudoglobal variables are broadcast
+alongwith the values of all variables created during the DataInit phase.
+       The code for the branch office chares for the accumulators and
+monotonic variables appear in the translator directory.
+       For monotonic variables a copy of the variable is maintained 
+on each node, and this local copy is updated. The updated value is 
+propagated up a spanning tree on the nodes, and the updates are later
+broadcast by the root to each node.
+       For accumulators also a copy of the variable is maintained on 
+each node, which is updated locally. When the final call for CollectValue
+comes the local values are sent up a spanning tree and the interior
+nodes combine the values that it receives from its children. The root 
+sends the final value to the requested destination.
+       Tables are also implemented as branch office chares. Each branch
+maintains a fragment of the table. A hash function on the key returns
+the processor returns the processor on which that key would be stored.
+Insert, Delete and Find messages are then redirected to the correct
+branch. Each branch has its packing and unpacking routines, which
+collect messages from the other branches, unpack and decode the information
+and perform the appropriate action, or else pack information to send
+it some other branch.
+       Writeonce variables are very well documented.
+A message is sent to
diff --git a/src/ck-core/rdonly.c b/src/ck-core/rdonly.c
new file mode 100644 (file)
index 0000000..33953a6
--- /dev/null
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/21  22:43:18  sanjeev
+ * fixed mainchareid bug
+ *
+ * Revision 1.2  1994/12/01  23:58:02  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:39:01  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+
+
+extern char * ReadBufIndex;
+extern char * ReadFromBuffer;
+
+/************************************************************************/
+/* The following functions are used to copy the read-buffer out of and         */
+/* into the read only variables.                                       */
+/************************************************************************/
+_CK_13CopyToBuffer(srcptr, var_size) 
+char *srcptr;
+int var_size;
+{
+  int i;
+
+  for (i=0; i<var_size; i++) 
+    *ReadBufIndex++ = *srcptr++;
+}
+
+_CK_13CopyFromBuffer(destptr, var_size) 
+char *destptr;
+int var_size;
+{
+  int i;
+
+  for (i=0; i<var_size; i++) 
+    *destptr++ = *ReadFromBuffer++;
+}
+
+
+BroadcastReadBuffer(ReadBuffer, size, mainChareBlock)
+char *ReadBuffer;
+int size;
+struct chare_block * mainChareBlock;
+{
+       ENVELOPE * env;
+
+       env = ENVELOPE_UPTR(ReadBuffer);
+       SetEnv_destPE(env,  ALL_NODES_EXCEPT_ME);
+       SetEnv_category(env, USERcat);
+       SetEnv_msgType(env, ReadVarMsg);
+       SetEnv_destPeFixed(env, 1);
+       
+       /* this is where we add the information for the main chare
+       block */
+       SetEnv_chareBlockPtr(env, (int) mainChareBlock);
+       if ( MainChareLanguage == CHARMPLUSPLUS )
+               SetEnv_chare_magic_number(env, 
+                       CPlus_GetMagicNumber(mainChareBlock));
+       else
+               SetEnv_chare_magic_number(env, 
+                       GetID_chare_magic_number(mainChareBlock->selfID));
+
+       CkCheck_and_Broadcast(env, 0);
+}
+
+
+ReadMsgInit(msg, id)
+char *msg;
+int id;
+{
+       int packed;
+       ENVELOPE *env ;
+
+       env = ENVELOPE_UPTR(msg);
+       NumReadMsg++;
+       SetEnv_destPE(env, ALL_NODES_EXCEPT_ME);
+       SetEnv_category(env, USERcat);
+       SetEnv_msgType(env, ReadMsgMsg);
+       SetEnv_destPeFixed(env, 1);
+       SetEnv_other_id(env, id);
+       if (GetEnv_isPACKED(env) == UNPACKED)
+               packed = 1;
+       else
+                packed = 0;
+       CkCheck_and_BroadcastNoFree(env, 0);
+}
+
diff --git a/src/ck-core/register.c b/src/ck-core/register.c
new file mode 100644 (file)
index 0000000..5fcd083
--- /dev/null
@@ -0,0 +1,227 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/04/02  00:49:08  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.4  1995/03/21  20:44:43  sanjeev
+ * Changed registerHandler to CsdRegisterHandler
+ *
+ * Revision 1.3  1995/03/17  23:38:33  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.2  1994/12/10  19:01:24  sanjeev
+ * bug fixes for working with Charm++ translator
+ *
+ * Revision 1.1  1994/12/02  00:08:12  sanjeev
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+
+#include "chare.h"
+#include "globals.h"
+
+
+/* indexes */
+extern int _CK_MainChareIndex ;
+extern int _CK_MainEpIndex ;
+extern int ReadBuffSize ;
+
+int fnCount=0;
+
+int chareEpsCount=0;
+
+int msgCount=0;
+
+int chareCount=0;
+
+int pseudoCount=0;
+
+int readCount=0 ;
+
+int readMsgCount=0 ;
+
+
+
+
+int registerMsg(name,allocf,packf,unpackf,size)
+char *name;
+FUNCTION_PTR allocf, packf, unpackf;
+int size ;
+{
+/* fills in MsgToStructTable */
+       MsgToStructTable[msgCount].alloc = allocf ;
+       MsgToStructTable[msgCount].pack = packf ;
+       MsgToStructTable[msgCount].unpack = unpackf ;
+       MsgToStructTable[msgCount].size = size ;
+       msgCount ++ ;
+       return(msgCount-1) ;
+}
+
+
+int registerBocEp(name,epFunc,epType,msgIndx,chareIndx)
+char *name;
+FUNCTION_PTR epFunc ;
+int epType ;
+int msgIndx, chareIndx;
+{
+/* fills in EpTable, EpIsImplicitTable, EpNameTable, EpChareTable
+   EpToMsgTable */
+       EpTable[chareEpsCount] = epFunc ;
+       EpIsImplicitTable[chareEpsCount] = 0 ;
+       EpNameTable[chareEpsCount] = (char *)malloc(strlen(name)*sizeof(char)+1);
+       strcpy(EpNameTable[chareEpsCount], name) ;
+       EpChareTable[chareEpsCount] = chareIndx ;
+       EpToMsgTable[chareEpsCount] = msgIndx ;
+       EpLanguageTable[chareEpsCount] = epType ;
+
+       EpChareTypeTable[chareEpsCount] = BOC ;
+
+       chareEpsCount++ ;
+       return(chareEpsCount-1) ;
+}
+
+
+
+int registerEp(name,epFunc,epType,msgIndx,chareIndx)
+char *name;
+FUNCTION_PTR epFunc ;
+int epType ;
+int msgIndx, chareIndx;
+{
+/* fills in EpTable, EpIsImplicitTable, EpNameTable, EpChareTable
+   EpToMsgTable */
+
+       EpTable[chareEpsCount] = epFunc ;
+       EpIsImplicitTable[chareEpsCount] = 0 ;
+       EpNameTable[chareEpsCount] = (char *)malloc(strlen(name)*sizeof(char)+1);
+       strcpy(EpNameTable[chareEpsCount], name) ;
+       EpChareTable[chareEpsCount] = chareIndx ;
+       EpToMsgTable[chareEpsCount] = msgIndx ;
+       EpLanguageTable[chareEpsCount] = epType ;
+
+       EpChareTypeTable[chareEpsCount] = CHARE ;
+
+       chareEpsCount++ ;
+       return(chareEpsCount-1) ;
+}
+
+int registerChare(name,dataSz,createfn)
+char *name;
+int dataSz;
+FUNCTION_PTR createfn ;
+{
+/* fills in ChareSizesTable, ChareNamesTable */
+       ChareSizesTable[chareCount] = dataSz ;
+       ChareNamesTable[chareCount] = (char *)malloc(strlen(name)*sizeof(char)+1);
+       ChareFnTable[chareCount] = createfn ;
+
+        strcpy(ChareNamesTable[chareCount], name) ;
+       chareCount++ ;
+       return(chareCount-1) ;
+}
+
+
+int registerFunction(fn)
+FUNCTION_PTR fn ;
+{
+/* fills in _CK_9_GlobalFunctionTable */
+       _CK_9_GlobalFunctionTable[fnCount] = fn ;
+       fnCount++ ;     
+       return(fnCount-1) ;
+}
+
+
+int registerMonotonic(name, initfn, updatefn,language)
+char *name ;
+FUNCTION_PTR initfn, updatefn ;
+int language ;
+{
+       PseudoTable[pseudoCount].name = (char *)malloc(strlen(name)*sizeof(char)+1);
+       strcpy(PseudoTable[pseudoCount].name,name) ;
+       PseudoTable[pseudoCount].type = MONOTONIC ;
+       PseudoTable[pseudoCount].initfn = initfn ;
+       PseudoTable[pseudoCount].language = language ;
+       PseudoTable[pseudoCount].pseudo_type.mono.updatefn = updatefn ;
+       pseudoCount++ ;
+
+       return(pseudoCount-1) ;
+}
+
+int registerTable(name, initfn, hashfn)
+char *name ;
+FUNCTION_PTR initfn, hashfn ;
+{
+       PseudoTable[pseudoCount].name = (char *)malloc(strlen(name)*sizeof(char)+1);
+       strcpy(PseudoTable[pseudoCount].name,name) ;
+       PseudoTable[pseudoCount].type = TABLE ;
+       PseudoTable[pseudoCount].initfn = initfn ;
+       PseudoTable[pseudoCount].pseudo_type.table.hashfn = hashfn ;
+       pseudoCount++ ;
+
+       return(pseudoCount-1) ;
+}
+
+int registerAccumulator(name, initfn, addfn, combinefn,language)
+char *name ;
+FUNCTION_PTR initfn, addfn, combinefn ;
+int language ;
+{
+       PseudoTable[pseudoCount].name = (char *)malloc(strlen(name)*sizeof(char)+1);
+       strcpy(PseudoTable[pseudoCount].name,name) ;
+       PseudoTable[pseudoCount].type = ACCUMULATOR ;
+       PseudoTable[pseudoCount].initfn = initfn ;
+       PseudoTable[pseudoCount].language = language ;
+       PseudoTable[pseudoCount].pseudo_type.acc.addfn = addfn ;
+       PseudoTable[pseudoCount].pseudo_type.acc.combinefn = combinefn ;
+       pseudoCount++ ;
+
+       return(pseudoCount-1) ;
+}
+
+
+int registerReadOnlyMsg()
+{
+/* this is only needed to give a unique index to all all readonly msgs */
+       readMsgCount++ ;
+       return(readMsgCount-1) ;
+}
+
+
+void registerReadOnly(size, fnCopyFromBuffer, fnCopyToBuffer)
+int size ;
+FUNCTION_PTR fnCopyFromBuffer, fnCopyToBuffer ;
+{
+/* this is called only once per module */
+       ROCopyFromBufferTable[readCount] = fnCopyFromBuffer ;
+       ROCopyToBufferTable[readCount] = fnCopyToBuffer ;
+       ReadBuffSize += size ;
+       readCount++ ;
+}
+
+
+
+void registerMainChare(m, ep, type)
+int m, ep ;
+int type ;
+{
+       _CK_MainChareIndex = m ;
+       _CK_MainEpIndex = ep ;
+       MainChareLanguage = type ;
+}
diff --git a/src/ck-core/stat.c b/src/ck-core/stat.c
new file mode 100644 (file)
index 0000000..e6b744c
--- /dev/null
@@ -0,0 +1,265 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/05/04  22:05:47  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.4  1995/05/04  22:04:17  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.3  1995/04/13  20:55:41  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/12/09  15:42:37  sanjeev
+ * interoperability stuff
+ *
+ * Revision 1.1  1994/11/03  17:39:42  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#define NODESTAT
+
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+#include "stat.h"
+
+static int **HostStat;
+static int **HostMemStatistics;
+static int NumPe;
+
+extern CollectPerfFromNodes();
+
+
+StatInit()
+{
+       BOC_BLOCK *bocBlock;
+       int i;
+
+       NumPe = CmiNumPe();
+       RecdStatMsg = 1;
+       if (CmiMyPe() == 0)
+               RecdStatMsg = 0;
+}
+
+StatisticBocInit()
+{
+       BOC_BLOCK *bocBlock;
+
+       bocBlock = (BOC_BLOCK *) CreateBocBlock(0);
+       bocBlock->boc_num = StatisticBocNum;
+       SetBocDataPtr(StatisticBocNum, (void *) (bocBlock + 1));
+}
+
+
+NodeCollectStatistics(msgPtr, localdataPtr)
+void *msgPtr;
+void *localdataPtr;
+{
+       STAT_MSG *sPtr;
+       int i;
+
+TRACE(CmiPrintf("Node %d: Enter NodeCollectStatistics() \n", CmiMyPe()));
+
+       sPtr = (STAT_MSG *) CkAllocMsg(sizeof(STAT_MSG)); 
+       CkMemError(sPtr);
+
+       sPtr->srcPE = CmiMyPe();
+       sPtr->chareQueueLength = CstatsMaxChareQueueLength;
+       sPtr->forChareQueueLength = CstatsMaxForChareQueueLength;
+       sPtr->fixedChareQueueLength = CstatsMaxFixedChareQueueLength;
+       sPtr->charesCreated = nodecharesCreated;
+       sPtr->charesProcessed = nodecharesProcessed;
+       sPtr->forCharesCreated = nodeforCharesCreated;
+       sPtr->forCharesProcessed = nodeforCharesProcessed;
+       sPtr->bocMsgsCreated = nodebocMsgsCreated;
+       sPtr->bocMsgsProcessed = nodebocMsgsProcessed;
+
+       for (i=0; i < MAXMEMSTAT; i++)
+               sPtr->nodeMemStat[i] = CstatMemory(i);
+
+       GeneralSendMsgBranch(StatCollectNodes_EP, sPtr, 
+               0, USERcat, BocMsg, LdbBocNum);
+}
+
+
+
+
+CollectStatistics()
+{
+       DUMMY_STAT_MSG *mPtr;
+
+       TRACE(CmiPrintf("Host: Enter CollectStatistics(): and Call BroadcastMsgBranch()\n"));
+       mPtr = (DUMMY_STAT_MSG *) CkAllocMsg(sizeof(DUMMY_STAT_MSG));
+       CkMemError(mPtr);
+       GeneralBroadcastMsgBranch(StatData_EP, mPtr,
+                                IMMEDIATEcat, BroadcastBocMsg, LdbBocNum);
+}
+
+
+CollectFromNodes(msgPtr, localdataptr)
+void *msgPtr, *localdataptr;
+{
+       int i,j,k;
+       STAT_MSG *mPtr = (STAT_MSG *) msgPtr;
+
+TRACE(CmiPrintf("Host %d: Enter CollectFromNodes(): NumPe %d\n",
+        CmiMyPe(), NumPe));
+       if (NumPe == CmiNumPe())
+       {
+               HostMemStatistics = (int **) CmiAlloc(sizeof(int)*NumPe);
+               CkMemError(HostMemStatistics);
+               for (i=0; i<NumPe; i++)
+               {
+                       HostMemStatistics[i] = 
+                           (int *) CmiAlloc(sizeof(int)*MAXMEMSTAT);
+                       CkMemError(HostMemStatistics[i]);
+               }
+               HostStat = (int **) CmiAlloc(sizeof(int)*NumPe);
+               CkMemError(HostStat);
+               for (i=0; i<NumPe; i++)
+               {
+                       HostStat[i] = (int *) CmiAlloc(sizeof(int)*10);
+                       CkMemError(HostStat[i]);
+               }
+               for (i=0; i<NumPe; i++)
+               {
+                       for (j=0; j<MAXMEMSTAT; j++)
+                               HostMemStatistics[i][j] = 0;
+                       for (j=0; j<10; j++)
+                               HostStat[i][j] = 0;
+               }
+       }
+       NumPe--;
+
+       HostStat[mPtr->srcPE][0] = mPtr->chareQueueLength;
+       HostStat[mPtr->srcPE][1] = mPtr->forChareQueueLength;
+       HostStat[mPtr->srcPE][2] = mPtr->fixedChareQueueLength;
+       HostStat[mPtr->srcPE][3] = mPtr->charesCreated;
+       HostStat[mPtr->srcPE][4] = mPtr->charesProcessed;
+       HostStat[mPtr->srcPE][5] = mPtr->forCharesCreated;
+       HostStat[mPtr->srcPE][6] = mPtr->forCharesProcessed;
+       HostStat[mPtr->srcPE][7] = mPtr->bocMsgsCreated;
+       HostStat[mPtr->srcPE][8] = mPtr->bocMsgsProcessed;
+
+       for (k=0; k < MAXMEMSTAT; k++)
+               HostMemStatistics[mPtr->srcPE][k] = mPtr->nodeMemStat[k];
+       
+       /* Exit when statistics from all the nodes have been received */
+       if (NumPe == 0)
+       {
+               RecdStatMsg = 1;
+               if (RecdPerfMsg) ExitNode();
+       }
+}
+
+
+
+PrintOutStatistics()
+{
+       int i,j,k;
+       int col = 0;
+       int totalHops = 0;
+       int  totalChares = 0;
+       int  totalCharesCrea = 0;
+       int  totalCharesProc = 0;
+       int totalChareQ = 0, totalForChareQ = 0, totalMemoryUsage = 0;
+       int totalMemoryOverflow = 0;
+       ENVELOPE * env;
+       char *msg;
+
+       if (CstatPrintQueueStats())
+       {
+               CmiPrintf("Queue Statistics: (NODE)[MaxChareQ, MaxForChareQ, MaxFixedChareQ]\n");
+               for (k=0; k < CmiNumPe(); k++)
+               {
+                       totalChareQ += HostStat[k][0];
+                       totalForChareQ += HostStat[k][1];
+               }
+               CmiPrintf("Average Queue Sizes: [AvgMaxChareQ %d, AvgMaxForChareQ %d]\n",
+                   totalChareQ/CmiNumPe(), totalForChareQ/CmiNumPe());
+
+               for (k=0; k < CmiNumPe(); k++)
+                       CmiPrintf("(%d)[%d, %d, %d], ", k, HostStat[k][0], HostStat[k][1], HostStat[k][2]);
+               CmiPrintf("\n\n");
+       }
+
+
+        if (PrintChareStat || PrintSummaryStat)
+               for (k=0; k < CmiNumPe(); k++)
+               {
+                       totalCharesCrea += HostStat[k][3];
+                       totalCharesProc += HostStat[k][4];
+               }
+
+
+       if (PrintSummaryStat)
+       {
+               CmiPrintf("\nPrinting Chare Summary Statistics:\n");
+               CmiPrintf("Total Chares: [Created %d, Processed %d]\n",
+                   totalCharesCrea, totalCharesProc);
+       }
+
+
+       if (PrintChareStat)
+       {
+               CmiPrintf("\nPrinting Chare Statistics:\n");
+               CmiPrintf("Individual Chare Info: (NODE)[Created, Processed]\n");
+               for (k=0; k < CmiNumPe(); k++)
+                       CmiPrintf("(%d)[%d, %d], ", k, HostStat[k][3], HostStat[k][4]);
+               CmiPrintf("\nFor Chare Messages: ");
+               for (k=0; k < CmiNumPe(); k++)
+                       CmiPrintf("(%d)[%d, %d], ", k, HostStat[k][5], HostStat[k][6]);
+               CmiPrintf("\n");
+
+               CmiPrintf("For Boc Messages: ");
+               for (k=0; k < CmiNumPe(); k++)
+                       CmiPrintf("(%d)[%d, %d], ", k, HostStat[k][7], HostStat[k][8]);
+               CmiPrintf("\n\n");
+
+       }
+        
+       if (CstatPrintMemStats())
+       {
+               CmiPrintf("Printing Memory Statistics:\n\n");
+                CmiPrintf("Available Memory: %d (words)\n",
+                         HostMemStatistics[0][0]);
+                CmiPrintf(" Node     Unused         Allocated                   Freed\n");
+                CmiPrintf(" Node     (words)     (no.req, words)            (no.req, words)\n");
+                CmiPrintf("------   --------    ---------------------      ---------------------\n");
+               for (k=0; k < CmiNumPe(); k++)
+                        CmiPrintf("%4d    %8d     [%8d,%10d]      [%8d,%10d]\n",
+                        k,HostMemStatistics[k][1],
+                        HostMemStatistics[k][2],HostMemStatistics[k][3]*2,
+                        HostMemStatistics[k][4],HostMemStatistics[k][5]*2);
+                CmiPrintf("\n");
+       }
+}
+
+
+
+StatAddSysBocEps()
+{
+       extern BroadcastExitMessage(), ExitMessage();
+
+       EpTable[StatCollectNodes_EP] = CollectFromNodes;
+       EpTable[StatData_EP] = NodeCollectStatistics;
+       EpTable[StatPerfCollectNodes_EP] = CollectPerfFromNodes;
+       EpTable[StatBroadcastExitMessage_EP] = BroadcastExitMessage;
+       EpTable[StatExitMessage_EP] = ExitMessage;
+}
diff --git a/src/ck-core/stat.h b/src/ck-core/stat.h
new file mode 100644 (file)
index 0000000..46d264a
--- /dev/null
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/05/04  22:11:10  jyelon
+ * *** empty log message ***
+ *
+ * Revision 1.2  1994/11/11  05:31:06  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:28  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#define MAXMEMSTAT 10 
+/* MAXMEMSTAT is also defined in memory management */
+
+extern int CstatsMaxChareQueueLength;
+extern int CstatsMaxForChareQueueLength;
+extern int CstatsMaxFixedChareQueueLength;
+extern int MemStatistics[];
+
+
+typedef struct message3 {
+    int srcPE;
+    int chareQueueLength;
+    int forChareQueueLength;
+    int fixedChareQueueLength;
+    int charesCreated;
+    int charesProcessed;
+    int forCharesCreated;
+    int forCharesProcessed;
+    int bocMsgsCreated;
+    int bocMsgsProcessed;
+    int nodeMemStat[MAXMEMSTAT];
+} STAT_MSG;
+
+
+typedef struct dummy_message {
+    int dummy;
+} DUMMY_STAT_MSG;
+
diff --git a/src/ck-core/sys_macros.h b/src/ck-core/sys_macros.h
new file mode 100644 (file)
index 0000000..bf427a0
--- /dev/null
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/04/23  20:55:17  sanjeev
+ * Removed Core....
+ *
+ * Revision 1.4  1995/03/17  23:38:13  sanjeev
+ * changes for better message format
+ *
+ * Revision 1.3  1994/12/02  00:02:05  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:31:21  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:43  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/* #define IsCharmPlus(Entry) (Entry & 0xffff8000)     */
+
+#define IsCharmPlus(Entry) (EpLanguageTable[Entry]==CHARMPLUSPLUS)
+
+#define IsCharmPlusPseudo(id) (PseudoTable[id].language==CHARMPLUSPLUS)
+
+
+#define CkMemError(ptr) if (ptr == NULL) \
+                CmiPrintf("*** ERROR *** Memory Allocation Failed --- consider +m command-line option.\n");
+
+#define QDCountThisProcessing(msgType) \
+         if ((msgType != QdBocMsg) && (msgType != QdBroadcastBocMsg) && \
+                       (msgType != LdbMsg)) msgs_processed++; 
+
+#define QDCountThisCreation(ep, category, type, x) \
+         if ((type != QdBocMsg) && (type != QdBroadcastBocMsg) && \
+                       (type != LdbMsg)) msgs_created += x;
+
+#ifdef DEBUGGING_MODE
+#define COPY_AND_SEND(env)  { \
+       ENVELOPE *new = (ENVELOPE *) CkCopyEnv(env); \
+       trace_creation(GetEnv_msgType(new), GetEnv_EP(new), new); \
+        CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+        CkAsyncSend(GetEnv_destPE(new), \
+        CmiSize(new), new); }
+#else
+#define COPY_AND_SEND(env)  { \
+       ENVELOPE *new = (ENVELOPE *) CkCopyEnv(env); \
+        CmiSetHandler(env,HANDLE_INCOMING_MSG_Index); \
+        CkAsyncSend(GetEnv_destPE(new), \
+        CmiSize(new), new); }
+#endif
diff --git a/src/ck-core/table.h b/src/ck-core/table.h
new file mode 100644 (file)
index 0000000..e4a98f7
--- /dev/null
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:31:14  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:36  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*      Authors: Wayne Fenton, Balkrishna Ramkumar, Vikram A. Saletore    */
+/*                    Amitabh B. Sinha  and  Laxmikant V. Kale            */
+/*              (C) Copyright 1990 The Board of Trustees of the           */
+/*                          University of Illinois                        */
+/*                           All Rights Reserved                          */
+/*                                                                        */
+/**************************************************************************/
+
+#define TBL_WAITFORDATA 1
+#define TBL_NOWAITFORDATA 2
+
+#define TBL_REPLY 1
+#define TBL_NOREPLY 2
+
+#define TBL_WAIT_AFTER_FIRST 1
+#define TBL_NEVER_WAIT 2
+#define TBL_ALWAYS_WAIT 3
+
+#define MAX_TBL_SIZE 211
+
+typedef struct {
+       int penum;
+       int index;
+} map;
+
+typedef struct {
+       int key;
+       char *data;
+} TBL_MSG;
+
+
+typedef struct address {
+       int entry;
+       ChareIDType  chareid;
+       struct address *next;
+} ADDRESS;
+
+typedef struct tbl_element {
+       int isDefined;
+       int tbl;
+       int key;
+       char *data;
+       int size_data;
+       struct address *reply;
+       struct tbl_element *next;
+}      TBL_ELEMENT;
+
+typedef struct {
+       int i;
+} DATA_BR_TBL;
+
+typedef struct {
+       int i;
+} DATA_MNGR_TBL;
+
diff --git a/src/ck-core/tbl.c b/src/ck-core/tbl.c
new file mode 100644 (file)
index 0000000..38525cc
--- /dev/null
@@ -0,0 +1,600 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:55:22  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/12/01  23:58:04  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:57  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "table.h"
+#include "globals.h"
+#include "performance.h"
+
+#define SIZE_CHARE_ID sizeof(ChareIDType)
+
+int MaxPe;
+/* made static, July 9 */
+static struct tbl_element *table[MAX_TBL_SIZE];
+
+TblBocInit()
+{
+       BOC_BLOCK *bocBlock;
+       int i;
+
+       bocBlock = (BOC_BLOCK *) CreateBocBlock(sizeof(DATA_BR_TBL));
+       /*TRACE(CmiPrintf("Node %d: TblBocInit:created block with size %d\n",CmiMyPe(), sizeof(DATA_BR_VID))); */
+       bocBlock->boc_num = TblBocNum;
+       SetBocDataPtr(TblBocNum, (void *) (bocBlock + 1));
+       MaxPe = CmiNumPe();     
+       for (i=0; i<MAX_TBL_SIZE; i++)
+               table[i] = (TBL_ELEMENT *) NULL;
+       TRACE(CmiPrintf("Node %d: TblBocInit: BocDataTbl entry filled.\n",CmiMyPe()));
+}
+
+
+/************************************************************************/
+/*     This entry point unpacks the packed stuff and does the required */
+/*     operation.                                                      */
+/************************************************************************/
+
+void Unpack(ptr, dataptr)
+char *ptr;
+void *dataptr;
+{
+       int size;
+       int *operation, *tbl, *entry, *option;
+       int *index;
+       char  *data;
+       int *key;
+       int  *size_data;
+       ChareIDType *chareid;
+       TBL_MSG *msg;
+       int *size_chareid;
+
+
+TRACE(CmiPrintf("[%d] Unpack:: ptr=0x%x\n", CmiMyPe(), ptr));
+
+       size = sizeof(int);
+       operation  = (int *) ptr;
+       ptr += size;
+       tbl  = (int *)ptr;
+       ptr += size;
+       index = (int *)ptr;
+       ptr += size;
+       key = (int *) ptr;
+       ptr += size;
+       size_data = (int *) ptr;
+       ptr += size;
+       if (*size_data == 0)
+               data = (char *) NULL;
+       else
+       {
+               data = (char *)  ptr;
+               ptr += *size_data;
+       }
+       entry  =(int *) ptr;
+       ptr += size;
+
+TRACE(CmiPrintf("[%d] Unpack:: index=%d, key=%d, size_data=%d, entry=%d\n",
+               CmiMyPe(), *index, *key, *size_data, *entry));
+
+       size_chareid = (int *) ptr;
+       ptr += size;
+
+TRACE(CmiPrintf("[%d] Unpack:: size_chareid=%d\n",
+               CmiMyPe(), *size_chareid));
+
+       if (*size_chareid == 0)
+               chareid = (ChareIDType *) NULL;
+       else
+       {
+               chareid = (ChareIDType *) ptr;  
+               ptr += *size_chareid;
+       }
+       option = (int *) ptr;
+
+TRACE(CmiPrintf("[%d] Unpack:: option=%d\n",
+               CmiMyPe(), *option));
+
+       switch (*operation){
+       case 0 :
+               TblInsert(*tbl, *index, *key, data, *size_data,
+                        *entry, chareid, *option);
+               break;
+       case 1:
+               TblDelete(*tbl, *index, *key, *entry, chareid, *option);
+               break;
+       case 2:
+               TblFind(*tbl, *index, *key,  *entry, chareid, *option);
+               break;
+       case 3:
+               msg = (TBL_MSG *) CkAllocMsg(sizeof(TBL_MSG));
+               CkMemError(msg);
+               msg->key = *((int *) key);
+               msg->data = data;
+               SendMsg(*entry, msg, chareid);
+               break;
+       default:
+               CmiPrintf("We are in trouble here\n");
+       }
+}
+
+
+absolute(i)
+int i;
+{
+       if (i<0)
+               return(-i);
+       else
+               return(i);
+}
+
+
+/************************************************************************/
+/*     This function copies structures.                                */
+/************************************************************************/
+
+structure_copy(x, y, size)
+char *x, *y;
+int size;
+{
+       int i;
+
+       for (i=0; i<size; i++)
+               *x++ = *y++;
+}
+
+
+/************************************************************************/
+/*     This function takes a key and its size, and computes a mapping  */
+/*     (p,i), where p is the processor on which the key resides/will   */
+/*     reside, and i is the index in the table.                        */
+/************************************************************************/
+
+map * Hash(tbl, key)
+int tbl, key;
+{
+       int p, i;
+       map *value;
+       
+       if (PseudoTable[tbl].pseudo_type.table.hashfn)
+               p = (*PseudoTable[tbl].pseudo_type.table.hashfn)(key);
+       else
+               p = 13*key % MAX_TBL_SIZE; 
+               
+       i = 83*key;
+       value = (map *) CmiAlloc(sizeof(map));
+       CkMemError(value);
+       value->penum = absolute(p % MaxPe);
+       value->index = absolute(i % MAX_TBL_SIZE);
+       return(value);
+}
+
+
+/************************************************************************/
+/*     This function takes the key and table index and matches it with */
+/*     the entries in the table . It returns a pointer to the matched  */
+/*     element.                                                        */
+/************************************************************************/
+
+TBL_ELEMENT * match(key, tbl, ptr)
+int key;
+int tbl;
+TBL_ELEMENT * ptr;
+{
+       while (ptr != NULL)
+       {
+               if ( (ptr->tbl == tbl) && (key == ptr->key))
+                               return(ptr);
+               else
+                       ptr = ptr->next;
+       }
+       return(NULL);
+}
+
+
+
+/************************************************************************/
+/*     This function packs the key, data etc for an entry              */
+/************************************************************************/
+char *
+pack(operation, tbl, index, penum, key, data, size_data, entry,chareid, option)
+char *operation, *tbl, *index;
+int  penum;
+char  *key;
+char  *data;
+char *size_data;
+char *entry, *chareid;
+char *option;
+{
+       int size, sized;
+       int total_size;
+       char *original, *ptr;
+       TBL_MSG *msg;
+       int size_chareid;
+
+TRACE(CmiPrintf("[%d] Pack :: operation=%d, penum=%d, key=%d, entry=%d\n",
+                CmiMyPe(),
+                *((int *) operation), penum,
+                *((int *)key), *((int *)entry)));
+
+       if (penum == CmiMyPe())
+       {
+
+TRACE(CmiPrintf("[%d] Pack :: operation=%d, penum=%d, key=%d, entry=%d\n",
+                CmiMyPe(),
+                *((int *) operation), penum,
+                *((int *)key), *((int *)entry)));
+
+               msg = (TBL_MSG *) CkAllocMsg(sizeof(TBL_MSG));
+               CkMemError(msg);
+               msg->key = *((int *) key);
+               msg->data = data;
+               SendMsg(*((int *) entry), msg, (ChareIDType *) chareid);
+       }
+       else
+       {
+
+               size = sizeof(int);
+               sized = *((int *) size_data);
+               if (chareid == NULL)
+                       size_chareid = 0;
+               else 
+                       size_chareid = SIZE_CHARE_ID;
+               total_size = 9*size + sized + size_chareid;
+
+TRACE(CmiPrintf("[%d] Pack:: size_chareid=%d, total_size=%d\n",
+               CmiMyPe(), size_chareid, total_size));
+
+               ptr = (char *) CkAllocMsg(total_size);
+               CkMemError(ptr);
+               original = ptr;
+               structure_copy(ptr, operation, size);
+               ptr += size;
+               structure_copy(ptr, tbl, size);
+               ptr += size;
+               structure_copy(ptr, index, size);
+               ptr += size;
+               structure_copy(ptr, key, size);
+               ptr += size;
+               structure_copy(ptr, size_data, size);
+               ptr += size;
+               if (sized != 0)
+               {
+                       structure_copy(ptr, data, sized);
+                       ptr += sized;
+               }
+               structure_copy(ptr, entry, size);
+               ptr += size;
+               structure_copy(ptr, &size_chareid, size);
+               ptr += size;
+               if (size_chareid != 0)
+               {
+                       structure_copy(ptr, chareid, size_chareid);
+                       ptr += size_chareid;
+               }
+               structure_copy(ptr, option, size);
+       TRACE(CmiPrintf("Pack :: sending key %d to penum %d\n", 
+                       *((int *) key), penum));
+               GeneralSendMsgBranch(TblUnpack_EP, original,
+                               penum, IMMEDIATEcat, BocMsg, TblBocNum);
+       }
+}
+
+
+/************************************************************************/
+/*     This function intercepts local Insert calls, and then sends a   */
+/*     message to the entry point BR_TblInsert on the processor on     */
+/*     which the element is to be stored with details about the element*/
+/*     to be inserted.                                                 */
+/************************************************************************/
+
+TblInsert(tbl, index, key, data, size_data, entry, chareid, option)
+int tbl;
+int index;
+int key;
+char *data;
+int size_data;
+int entry;
+ChareIDType *chareid;
+int option;
+{
+       map *place;
+       int operation = 0;
+       ADDRESS *temp;
+       TBL_ELEMENT *ptr;
+
+       option = -1;
+       if (index == -1)
+               place = Hash(tbl, key);
+       
+#ifdef DEBUGGING_MODE
+       if (index == -1)
+               trace_table(INSERT, tbl, key, place->penum);
+       else 
+               trace_table(INSERT, tbl, key, CmiMyPe());
+#endif
+
+       if (!data)  {
+               CmiPrintf("*** ERROR *** Insert on processor %d has null data.\n",
+                                       CmiMyPe());
+               return;
+       }
+       if ( (index == -1) && (place->penum != CmiMyPe()))
+               pack(&operation, &tbl, &(place->index), place->penum,
+                        &key,  data, &size_data, &entry, chareid, &option);
+       else
+       {
+               if (index == -1) index = place->index;
+TRACE(CmiPrintf("TblInsert :: key = %d, index = %d\n", key, index));
+               ptr = match(key, tbl, table[index]);
+               operation = 3;
+               if ( (ptr == NULL) ||  (! ptr->isDefined) )
+               {
+                       if (ptr == NULL)
+                       {
+                               ptr = (TBL_ELEMENT *) CmiAlloc(sizeof(TBL_ELEMENT));
+                               CkMemError(ptr);
+                               ptr->tbl = tbl;
+                               ptr->key = key;
+                               ptr->reply = (ADDRESS *) NULL;
+                               ptr->next = table[index];
+                               table[index] = ptr;
+TRACE(CmiPrintf("TblInsert :: table entry created with key %d\n", key));
+                       }               
+                       ptr->data = (char *) CmiAlloc(size_data);
+                       CkMemError(ptr->data);
+                       structure_copy(ptr->data, data, size_data);
+                       ptr->size_data = size_data;
+                       ptr->isDefined = 1;
+                       temp = ptr->reply;
+                       while (temp != NULL)
+                       {
+TRACE(CmiPrintf("TblInsert :: Pending request key is %d  - data is %d\n",
+               ptr->key, *((int *) data)));
+                               pack(&operation, &tbl, &index, GetID_onPE(temp->chareid),
+                                               &ptr->key, ptr->data, &size_data,
+                                               &temp->entry, &temp->chareid, &option);
+                               temp = temp->next;
+                       };
+                       if ((entry != -1) && (chareid != NULL))
+                               pack(&operation, &tbl, &index, GetID_onPE((*chareid)),
+                                               &ptr->key, ptr->data, &size_data,  
+                                               &entry, chareid, &option);
+               }
+               else
+               {
+                       if ((entry != -1) && (chareid != NULL))
+                       {
+                               pack(&operation, &tbl, &index,
+                                       GetID_onPE((*chareid)),
+                                        &ptr->key, ptr->data, &ptr->size_data,
+                                        &entry, chareid, &option);
+                       } 
+               }
+       }
+}
+
+
+/************************************************************************/
+/*     This function intercepts local Delete calls, and then sends a   */
+/*     message to the entry point BR_TblDelete on the processor on     */
+/*     which the element is to be stored with details about the element*/
+/*     to be deleted.                                                  */
+/************************************************************************/
+
+TblDelete(tbl, index, key, entry, chareid, option)
+int tbl;
+int index;
+int key;
+int entry;
+ChareIDType *chareid;
+int option;
+{
+       int size = 0;
+       char *data = (char  *) NULL;
+       map *place;
+       int operation = 1;
+       TBL_ELEMENT *ptr1, *ptr2;
+
+       if ((option !=  TBL_REPLY) && (option != TBL_NOREPLY))
+               CmiPrintf("***error*** TblDelete :: Unknown option chosen\n");
+       if (index == -1)
+               place = Hash(tbl, key); 
+
+#ifdef DEBUGGING_MODE
+       if (index == -1)
+               trace_table(DELETE, tbl, key, place->penum);
+       else 
+               trace_table(DELETE, tbl, key, CmiMyPe());
+#endif
+
+       if ( (index == -1) && ( place->penum != CmiMyPe()))
+               pack(&operation, &tbl, &(place->index), place->penum,
+                        &key, data, &size,  &entry, chareid, &option);
+       else
+       {
+               if (index == -1) index  = place->index;
+               ptr1 = table[index];
+               ptr2 = (TBL_ELEMENT *) NULL;
+               while ( (ptr1 != NULL) &&
+                       (  (ptr1->tbl != tbl) || 
+                          (key != ptr1->key)))
+               {
+                       ptr2 = ptr1;
+                       ptr1 = ptr1->next;
+               }
+               operation = 3;
+               if ( (ptr1 != NULL) && (entry != -1) && (chareid != NULL)) 
+                       pack(&operation, &tbl, &index, 
+                               GetID_onPE((*chareid)),
+                               &ptr1->key, ptr1->data, &ptr1->size_data,
+                               &entry, chareid, &option);
+               if ( (ptr1 == NULL) && (entry != -1) && (chareid != NULL) 
+                                   && (option == TBL_REPLY))
+                       pack(&operation, &tbl, &index, GetID_onPE((*chareid)),
+                                &key, data, &size, &entry, chareid, &option);
+               if (ptr2 == NULL) 
+                       if (ptr1 != NULL)
+                       {
+                               table[index] =  ptr1->next;
+                               CmiFree(ptr1);
+                       }
+                       else
+                               table[index] = (TBL_ELEMENT *) NULL;
+               else
+                       if (ptr1 != NULL)
+                       {
+                               ptr2->next = ptr1->next;
+                               CmiFree(ptr1);
+                       }
+                       else
+                               ptr2->next =(TBL_ELEMENT *) NULL;
+       }       
+}
+
+
+/************************************************************************/
+/*     This function intercepts local Find calls, and then sends a     */
+/*     message to the entry point BR_Tbl_Find on the processor on which*/
+/*     the element may exist with information about element to be found*/
+/************************************************************************/
+
+TblFind( tbl, index, key, entry, chareid, option)
+int tbl;
+int index;
+int key;
+int entry;
+ChareIDType *chareid;
+int option;
+{
+       char * data = (char *) NULL;
+       int size =  0;
+       map *place;
+       int operation = 2;
+       TBL_ELEMENT *ptr;
+       ADDRESS *temp;
+
+       if ((option != TBL_NEVER_WAIT) && (option != TBL_ALWAYS_WAIT)
+               && (option != TBL_WAIT_AFTER_FIRST))
+                       CmiPrintf("***error*** TblFind :: Unknown option chosen\n");
+       place = Hash(tbl, key); 
+
+#ifdef DEBUGGING_MODE
+       if (index == -1)
+               trace_table(FIND, tbl, key, place->penum);
+       else 
+               trace_table(FIND, tbl, key, CmiMyPe());
+#endif
+
+
+       if ( (index == -1) && (place->penum != CmiMyPe()))
+               pack(&operation, &tbl, &(place->index), place->penum,
+                        &key, data, &size, &entry, chareid, &option);
+       else
+       {
+               if (index == -1) index = place->index;
+               ptr = match(key, tbl, table[index]);    
+
+TRACE(CmiPrintf("[%d] TblFind: ptr=0x%x, entry=%d, option=%d, index=%d\n",
+               CmiMyPe(), ptr, entry, option, index));
+
+               operation = 3;
+               if (ptr != NULL)
+                       if (ptr->isDefined)
+                               {
+                               if ((entry != -1) && (chareid != NULL))
+                                       pack(&operation, &tbl, &index, 
+                                               GetID_onPE((*chareid)), &key, 
+                                               ptr->data, &ptr->size_data,
+                                               &entry, chareid, &option);
+                               }
+                       else
+                       {
+                          if (option == TBL_NEVER_WAIT)
+                          {
+                               if ((entry != -1) && (chareid != NULL))
+                                       pack(&operation, &tbl, &index, 
+                                               GetID_onPE((*chareid)), &key,
+                                               data, &size,
+                                               &entry, chareid, &option);
+                          }
+                          else
+                          {
+                               if ((entry != -1) && (chareid != NULL))
+                               {
+                                  temp = (ADDRESS *) CmiAlloc(sizeof(ADDRESS));
+                                  CkMemError(temp);
+                                  temp->entry = entry;
+                                  temp->chareid = *chareid;
+                                  temp->next = ptr->reply;
+                                  ptr->reply = temp;
+                               }
+                          }
+                       }
+               else
+               {
+TRACE(CmiPrintf("[%d TblFind: ptr is NULL, tbl=%d, key=%d\n",
+       CmiMyPe(), tbl, key));
+
+                       ptr = (TBL_ELEMENT *) CmiAlloc(sizeof(TBL_ELEMENT));
+TRACE(CmiPrintf("[%d] TblFind: Going to send message.\n"));
+                       CkMemError(ptr);
+                       ptr->tbl = tbl;
+                       ptr->key = key;
+                       ptr->reply = (ADDRESS *) NULL;
+                       ptr->next = table[index];
+                       table[index] = ptr;
+                       ptr->isDefined = 0;
+                       ptr->data = (char *) NULL;
+                       ptr->size_data = 0;
+
+                       if (option == TBL_ALWAYS_WAIT)
+                       {
+                          if ((entry != -1) && (chareid != NULL)) 
+                          {
+                               temp = (ADDRESS *) CmiAlloc(sizeof(ADDRESS));
+                               CkMemError(temp);
+                               temp->entry = entry;
+                               temp->chareid = *chareid;
+                               temp->next = ptr->reply;
+                               ptr->reply = temp;
+                          }
+                       }
+                       else
+                          if ((entry != -1) && (chareid != NULL)) 
+                               pack(&operation, &tbl, &index, 
+                                       GetID_onPE((*chareid)),
+                                       &key, data, &size, &entry, chareid,
+                                       &option);
+TRACE(CmiPrintf("[%d] TblFind: Sent message.\n"));
+
+               }
+       }
+}
+
+TblAddSysBocEps()
+{
+       EpTable[TblUnpack_EP] = (FUNCTION_PTR) Unpack;
+}
diff --git a/src/ck-core/tbl.h b/src/ck-core/tbl.h
new file mode 100644 (file)
index 0000000..d940b39
--- /dev/null
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:31:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:24:40  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:13  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*      Authors: Wayne Fenton, Balkrishna Ramkumar, Vikram A. Saletore    */
+/*                    Amitabh B. Sinha  and  Laxmikant V. Kale            */
+/*              (C) Copyright 1990 The Board of Trustees of the           */
+/*                          University of Illinois                        */
+/*                           All Rights Reserved                          */
+/*                                                                        */
+/**************************************************************************/
+
+#define TBL_REPLY 1
+#define TBL_NOREPLY 2
+
+#define TBL_WAIT_AFTER_FIRST 1
+#define TBL_NEVER_WAIT 2
+#define TBL_ALWAYS_WAIT 3
+
+message {
+       int key;
+       char *data;
+} TBL_MSG;
+
+
+#define TblInsert(x1, x2, x3, x4, x5, x6) \
+               _CK_Insert(x1, -1, x2, x3, x4, x5, x6, -1)
+#define TblDelete(x1, x2, x3, x4, x5)  _CK_Delete(x1, -1, x2, x3, x4, x5)
+#define TblFind(x1, x2, x3, x4, x5) _CK_Find(x1, -1, x2, x3, x4, x5)
diff --git a/src/ck-core/trans_decls.h b/src/ck-core/trans_decls.h
new file mode 100644 (file)
index 0000000..5207a7f
--- /dev/null
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1994/12/02  00:02:06  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:24:04  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:05  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+extern int _CK_13PackOffset;
+extern int _CK_13PackMsgCount;
+extern int _CK_13ChareEPCount;
+extern int _CK_13TotalMsgCount;
+extern  FUNCTION_PTR   * _CK_9_GlobalFunctionTable;
+extern MSG_STRUCT * MsgToStructTable;
+
diff --git a/src/ck-core/trans_defs.h b/src/ck-core/trans_defs.h
new file mode 100644 (file)
index 0000000..b6a36af
--- /dev/null
@@ -0,0 +1,113 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.5  1995/04/13  21:26:44  milind
+ * Changed  definition of CkTimer.
+ *
+ * Revision 1.4  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.3  1994/12/02  00:02:08  sanjeev
+ * interop stuff
+ *
+ * Revision 1.2  1994/11/11  05:31:10  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:32  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+/* used in EpChareTypeTable, for now this is used only in projections.c */
+#define CHARE          53
+#define BOC            35
+
+/* Used to find which Language an EP is of by EpLanguageTable */
+#define CHARM          0
+#define CHARMPLUSPLUS  1
+
+#define ACCUMULATOR    0
+#define MONOTONIC      1
+#define TABLE          2
+
+#define ReadValue(v)                   (v)
+#define ReadInit(v) 
+
+#define CkTimer()                      (int)(CmiTimer() * 1000.0)
+#define CkUTimer()                     (int)(CmiTimer() * 1000000.0)
+#define CkHTimer()                     (int)(CmiTimer() / 3600.0)
+
+#define _CK_4MonoDataAreaType          MONO_DATA 
+#define _CK_9LockMonoDataArea(x)
+#define _CK_9GetMonoDataArea           GetBocDataPtr
+#define _CK_9UnlockMonoDataArea(x)
+
+#define _CK_4AccDataAreaType           ACC_DATA
+#define _CK_9LockAccDataArea(x)
+#define _CK_9GetAccDataArea            GetBocDataPtr
+#define _CK_9UnlockAccDataArea(x)
+
+
+#ifdef STRIP
+#define _CK_BroadcastMsgBranch(ep,msg,boc)  GeneralBroadcastMsgBranch(ep,msg,\
+                                       IMMEDIATEcat,BroadcastBocMsg,boc)
+#define _CK_SendMsgBranch(ep,msg,boc,pe)       GeneralSendMsgBranch(ep,msg,pe,\
+                                       IMMEDIATEcat,BocMsg,boc)
+#else
+#define _CK_BroadcastMsgBranch(ep,msg,boc)  GeneralBroadcastMsgBranch(ep,msg,\
+                                       USERcat,BroadcastBocMsg,boc)
+#define _CK_SendMsgBranch(ep,msg,boc,pe)       GeneralSendMsgBranch(ep,msg,pe,\
+                                       USERcat,BocMsg,boc)
+#endif
+
+#define VOIDFNPTR                      FUNCTION_PTR
+
+typedef struct msg_struct {
+       int size;
+       FUNCTION_PTR pack;
+       FUNCTION_PTR unpack;
+       FUNCTION_PTR alloc;
+} MSG_STRUCT;
+
+typedef struct mono_struct {
+       FUNCTION_PTR updatefn;
+} MONO_STRUCT;
+
+typedef struct acc_struct {
+       FUNCTION_PTR addfn;
+       FUNCTION_PTR combinefn;
+} ACC_STRUCT;
+typedef struct table_struct {
+       FUNCTION_PTR hashfn;
+} TABLE_STRUCT;
+typedef struct pseudo_struct {
+       int type;
+       int language ;
+       char *name;
+       FUNCTION_PTR initfn;
+       union {
+               MONO_STRUCT mono;
+               ACC_STRUCT acc;
+               TABLE_STRUCT table;
+       } pseudo_type;
+} PSEUDO_STRUCT;
+
+/* This causes problems in C++ so its now in trans_externs.h : SANJEEV 
+extern void * GenericCkAlloc();
+*/
diff --git a/src/ck-core/trans_externs.h b/src/ck-core/trans_externs.h
new file mode 100644 (file)
index 0000000..e3805a6
--- /dev/null
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:31:28  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:55  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+extern void * GenericCkAlloc();
+
+/* This is needed for accumulators - SANJEEV */
+void * GetBocDataPtr();
+
+/* This is needed for monotonics - SANJEEV */
+void * MonoValue();
diff --git a/src/ck-core/user_macros.h b/src/ck-core/user_macros.h
new file mode 100644 (file)
index 0000000..2dcbc94
--- /dev/null
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/11/11  05:31:15  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:38  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+
+#define CHARE_PROCESSOR(id) id.onPE
+#define CHARE_EQUAL(id1, id2) ((id1.onPE == id2.onPE) && \
+                               (id1.chare_boc.chare_magic_number == \
+                                id2.chare_boc.chare_magic_number))
+#define CHARE_PRINT(id) CmiPrintf("[%d] chare chars.: pe = %d, magic_number = %d, data_area = 0x%x\n",\
+                       CmiMyPe(), id.onPE, \
+                       id.chare_boc.chare_magic_number, \
+                       id.id_block.chareBlockPtr)
diff --git a/src/ck-core/vid.c b/src/ck-core/vid.c
new file mode 100644 (file)
index 0000000..b04f2d1
--- /dev/null
@@ -0,0 +1,165 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.4  1995/04/13  20:55:50  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.3  1995/04/02  00:48:02  sanjeev
+ * changes for separating Converse
+ *
+ * Revision 1.2  1994/12/01  23:57:00  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:55  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "chare.h"
+#include "globals.h"
+#include "performance.h"
+#include "vid.h"
+
+
+VidBocInit()
+{
+    BOC_BLOCK *bocBlock;
+
+    bocBlock = (BOC_BLOCK *) CreateBocBlock(sizeof(DATA_BR_VID));
+    bocBlock->boc_num = VidBocNum;
+    SetBocDataPtr(VidBocNum, (void *) (bocBlock + 1));
+}
+
+
+
+/************************************************************************/
+/*                     VidQueueUpInVidBlock                            */
+/*     The message msgPtr has been sent to a chare created with a      */
+/*     virtual id. The address of the virtual id block is available    */
+/*     as part of the message, and is used to determine whether or     */
+/*     not the chare has been created. If the chare hasn't been        */
+/*     created, then msgPtr is queued up in the virtual block, else    */
+/*     the message is forwarded to the processor on which the chare    */
+/*     was created.                                                    */
+/************************************************************************/
+
+VidQueueUpInVidBlock(msgPtr, data_area)
+void *msgPtr;
+void *data_area;
+{
+    ENVELOPE * env = ENVELOPE_UPTR(msgPtr);
+    VID_BLOCK * vidblock;
+    void *vidqueue;
+
+    vidblock = (VID_BLOCK *) GetEnv_vidBlockPtr(env);
+    vidqueue = vidblock->info_block.vid_queue;
+    if (vidblock->vidPenum == -1)
+       FIFO_EnQueue(vidqueue, env);
+    else
+    {
+       SetEnv_category(env,USERcat);
+       SetEnv_msgType(env,ForChareMsg);
+       SetEnv_destPE(env,vidblock->vidPenum);
+       SetEnv_chareBlockPtr(env, (int) vidblock->info_block.chareBlockPtr);
+       SetEnv_chare_magic_number(env, vidblock->chare_magic_number);
+       trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
+       CkCheck_and_Send(env, GetEnv_EP(env));
+       QDCountThisCreation(GetEnv_EP(env), USERcat, ForChareMsg, 1);
+    }
+}
+
+/************************************************************************/
+/*                     VidSendOverMessage                              */
+/*     Once the chare ha been created it needs to get the messages     */
+/*     that were sent to it while it hadn't been created. These        */
+/*     messages are queued up in its virtual id block, whose address   */
+/*     it has available. The chare on creation sends a messages to     */
+/*     the branch office chare, on which the virtual block resides     */
+/*     asking it to send over the messages to it. The messages are     */
+/*     then dequeued and sent over to the processor on which the       */
+/*     was finally created.                                            */
+/************************************************************************/
+
+VidSendOverMessages(msgPtr, data_area)
+CHARE_ID_MSG *msgPtr;
+void *data_area;
+{
+    CHARE_BLOCK        *cblock = msgPtr->dataPtr;
+    ENVELOPE           *env = ENVELOPE_UPTR(msgPtr);
+    VID_BLOCK          *vidblock = (VID_BLOCK *) GetEnv_vidBlockPtr(env);
+    void               *vidqueue;
+    int                magic_number = msgPtr->chare_magic_number;
+
+    vidblock->vidPenum = GetEnv_onPE(env);
+    vidblock->chare_magic_number = magic_number;
+    vidqueue = vidblock->info_block.vid_queue;
+    while (!FIFO_Empty(vidqueue))
+    {
+       FIFO_DeQueue(vidqueue, &env);
+       SetEnv_category(env, USERcat);
+       SetEnv_msgType(env, ForChareMsg);
+       SetEnv_destPE(env, vidblock->vidPenum);
+       SetEnv_chareBlockPtr(env, (int) cblock);
+       SetEnv_chare_magic_number(env, magic_number);
+       trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
+       CkCheck_and_Send(env, GetEnv_EP(env));
+       QDCountThisCreation(GetEnv_EP(env), USERcat, ForChareMsg, 1);
+   }
+   vidblock->info_block.chareBlockPtr = cblock; 
+}
+
+
+VidAddSysBocEps()
+{
+   EpTable[VidQueueUpInVidBlock_EP] = VidQueueUpInVidBlock;
+   EpTable[VidSendOverMessages_EP] = VidSendOverMessages;
+}
+
+
+/************************************************************************/
+/*                     VidSend                                         */
+/*     This call is replication of the SendMsgBranch call, but sends   */
+/*     the message with the category field as VIDcat.                  */
+/************************************************************************/
+
+VidSend(chareblockPtr,destPE,vidPtr)
+CHARE_BLOCK * chareblockPtr;
+PeNumType   destPE;
+VID_BLOCK *vidPtr;
+{
+    CHARE_ID_MSG * msg;
+    ENVELOPE * env;
+
+    msg  = (CHARE_ID_MSG *) CkAllocMsg(sizeof(CHARE_ID_MSG));
+    CkMemError(msg);
+    env = ENVELOPE_UPTR(msg);
+    SetEnv_destPE(env, destPE);
+    SetEnv_category(env, IMMEDIATEcat);
+    SetEnv_vidEP(env, VidSendOverMessages_EP);
+    SetEnv_msgType(env, VidMsg);
+    SetEnv_destPeFixed(env, 1);
+    SetEnv_onPE(env, CmiMyPe());
+    SetEnv_vidBlockPtr(env, (int)  vidPtr);
+
+    msg->dataPtr = chareblockPtr;
+    msg->chare_magic_number =
+       GetID_chare_magic_number(currentChareBlock->selfID);
+
+    QDCountThisCreation(GetEnv_vidEP(env), IMMEDIATEcat, VidMsg, 1);
+    trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
+    CkCheck_and_Send(env, GetEnv_vidEP(env));
+}
diff --git a/src/ck-core/vid.doc b/src/ck-core/vid.doc
new file mode 100755 (executable)
index 0000000..190bbd4
--- /dev/null
@@ -0,0 +1,23 @@
+       Virtual IDs were created so that a chare could be sent messages
+to even before it's data block is actually set up. The was this is done
+is by creating a virtual block for the chare, where all messages for it
+are created, and when the actual data area of the chare is created it
+requests for any messages that might have been sent before its creation.
+
+       The procedure VidQueueUpInVidBlock looks at the the address of
+the virtual id block, available as part of the message, and determines 
+whether or not the chare has been created. If the chare hasn't been
+created, then msgPtr is queued up in the virtual block, else
+the message is forwarded to the processor on which the chare
+was created.                                           
+
+       Once the chare ha been created it needs to get the messages
+that were sent to it while it hadn't been created. The procedure
+VidSendOverMessages does this.  These messages are queued
+up in its virtual id block, whose address it has available. 
+The chare on creation sends a messages to the branch office chare, 
+on which the virtual block reside asking it to send over the messages 
+to it. The messages are then dequeued and sent over to the processor
+ on which the chare was finally created.                       
+       The SysSendMsgBranch is replication of the SendMsgBranch call,
+ but sends the message with the category field as VIDcat.
diff --git a/src/ck-core/vid.h b/src/ck-core/vid.h
new file mode 100644 (file)
index 0000000..8aefb82
--- /dev/null
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.2  1994/11/11  05:25:19  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:24  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+typedef struct data_brnch_vid {
+       int dummy;
+} DATA_BR_VID;
+
+typedef struct dummy_msg {
+       int dummy;
+} DUMMY_MSG;
+
+typedef struct vid_msg{
+       CHARE_BLOCK *dataPtr;
+        int chare_magic_number;
+} CHARE_ID_MSG;
diff --git a/src/ck-core/wrtone.c b/src/ck-core/wrtone.c
new file mode 100644 (file)
index 0000000..a0e17ca
--- /dev/null
@@ -0,0 +1,268 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:27:40  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:55:22  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/12/01  23:58:06  sanjeev
+ * interop stuff
+ *
+ * Revision 1.1  1994/11/03  17:38:59  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+/*****************************************************************************
+                   Write once variable system boc (branch part)
+
+*****************************************************************************/
+
+#include "chare.h"
+#include "globals.h"
+#include "wrtone.h"
+
+
+
+/*****************************************************************************
+*****************************************************************************/
+void WOVBocInit()
+{
+       BOC_BLOCK *bocBlock;
+       WOV_Boc_Data *bocData;
+       int       i;
+
+       TRACE(CmiPrintf("[%d]: WOVBocInit() called\n", CmiMyPe()));
+
+       bocBlock  = (BOC_BLOCK *) CreateBocBlock(sizeof(WOV_Boc_Data));
+       bocBlock->boc_num  = WOVBocNum;
+
+       SetBocDataPtr(WOVBocNum, (void *) (bocBlock+1));
+       bocData  = (WOV_Boc_Data *) (bocBlock + 1);
+
+       for(i = 0; i < MAXWRITEONCEVARS; i++)
+               bocData->WOVArray[i].numAcks =
+                                CmiNumSpanTreeChildren(CmiMyPe());
+}
+
+
+/*****************************************************************************
+*****************************************************************************/
+void NodeAddWriteOnceVar(msgptr_,localdataptr_)
+void *msgptr_,*localdataptr_;
+{
+       Node_New_WOV_Msg  *newWovMsg = (Node_New_WOV_Msg *) msgptr_;
+       WOV_Boc_Data *bocData   = (WOV_Boc_Data *) localdataptr_;
+       Ack_To_Host_Msg   *ackMsg;
+
+
+       /* instead of removing data from message just point to data IN msg */
+       bocData->WOVArray[(int) newWovMsg->wovID].wovData = 
+               (char *) ( (Node_New_WOV_Msg *) newWovMsg + 1);
+
+       /* now we need to acknowledge the fact that we have created the WOV */
+       if(isLeaf(CmiMyPe())) {
+               ackMsg = (Ack_To_Host_Msg *)CkAllocMsg(sizeof(Ack_To_Host_Msg));
+               CkMemError(ackMsg);
+               ackMsg->wovID = newWovMsg->wovID;
+
+               if(CmiMyPe() == CmiSpanTreeRoot()) {
+TRACE(CmiPrintf("[%d]:: NodeWrtOnceVar...Ack to Host for wovID %d\n",
+                               CmiMyPe() ,ackMsg->wovID);)
+                       HostReceiveAcknowledge(ackMsg, bocData);
+               }
+               else
+               {
+              /* Note: we add TotalHostBocEps to deal with weird decrement */
+TRACE(CmiPrintf("[%d]:: NodeWrtOnceVar...Ack to Parent %d for wovID %d\n",
+                           CmiMyPe(), CmiSpanTreeParent(CmiMyPe()),
+                           ackMsg->wovID);)
+                       GeneralSendMsgBranch(NodeRcvAck_EP, ackMsg, 
+                                CmiSpanTreeParent(CmiMyPe()), IMMEDIATEcat,
+                                BocMsg, WOVBocNum);
+               }
+       }
+}
+
+
+/*****************************************************************************
+*****************************************************************************/
+void NodeReceiveAcknowledge(msgptr_,localdataptr_)
+void *msgptr_,*localdataptr_;
+{
+       Ack_To_Host_Msg   *theMsg  = (Ack_To_Host_Msg *) msgptr_;
+       WOV_Boc_Data *bocData = (WOV_Boc_Data *) localdataptr_;
+       Ack_To_Host_Msg   *ackMsg;  /* msg to pass up the tree */
+       WriteOnceID wovID;
+
+       wovID = theMsg->wovID;
+       bocData->WOVArray[(int) wovID].numAcks--; 
+
+
+TRACE(CmiPrintf("[%d]:: NodeRecvAck...wovID = %d, kids left = %d\n",
+               CmiMyPe(), wovID, bocData->WOVArray[(int) wovID].numAcks));
+       if(!(bocData->WOVArray[(int) wovID].numAcks)) 
+       {      
+               /* if we've got all acks */
+               ackMsg = (Ack_To_Host_Msg *)
+                                CkAllocMsg(sizeof(Ack_To_Host_Msg));
+               CkMemError(ackMsg);
+               ackMsg->wovID = theMsg->wovID;
+
+               if(CmiMyPe() == CmiSpanTreeRoot())
+                           HostReceiveAcknowledge(ackMsg, bocData);
+               else
+                           GeneralSendMsgBranch(NodeRcvAck_EP, ackMsg, 
+                               CmiSpanTreeParent(CmiMyPe()), IMMEDIATEcat,
+                               BocMsg, WOVBocNum);
+       }
+       else 
+               CkFreeMsg(msgptr_);
+}
+
+/*****************************************************************************
+*****************************************************************************/
+void *DerefWriteOnce(ID)
+WriteOnceID ID;
+{
+       WOV_Boc_Data * localBocData;
+
+
+       localBocData = (WOV_Boc_Data *) GetBocDataPtr(WOVBocNum);
+       return(localBocData->WOVArray[(int) ID].wovData);
+}
+
+
+/***************************************************************************
+***************************************************************************/
+void HostAddWriteOnceVar(msgptr_,localdataptr_)
+void *msgptr_,*localdataptr_;
+{
+       Host_New_WOV_Msg  *newWov   = (Host_New_WOV_Msg *)  msgptr_;
+       WOV_Boc_Data *localBocData  = (WOV_Boc_Data *) localdataptr_;
+       ENVELOPE *env;
+       int i, nodeMsgSize;
+
+       Node_New_WOV_Msg *msgForNodes; /* going to broadcast this to nodes */
+       char *src,*dest;               /* just indices to copy bytes       */
+
+
+       if (localBocData->numWOVs > MAXWRITEONCEVARS)
+       {
+               CmiPrintf("*** ERROR *** Exceeded permitted number of WriteOnce Variables.\n");
+               CkExit();
+       }
+       localBocData->WOVArray[localBocData->numWOVs].ep      = newWov->ep;
+       localBocData->WOVArray[localBocData->numWOVs].cid     = newWov->cid;
+       localBocData->WOVArray[localBocData->numWOVs].wovSize = newWov->wovSize;
+       localBocData->WOVArray[localBocData->numWOVs].wovData = 
+           (char *) (( Host_New_WOV_Msg *) newWov + 1);
+
+       nodeMsgSize = sizeof(Node_New_WOV_Msg) + newWov->wovSize;
+       msgForNodes = (Node_New_WOV_Msg *) CkAllocMsg(nodeMsgSize);
+       CkMemError(msgForNodes);
+
+       msgForNodes->wovID   = (WriteOnceID) localBocData->numWOVs;
+       msgForNodes->wovSize = newWov->wovSize;
+
+       src  = (char *) ((Host_New_WOV_Msg  *) newWov + 1);
+       dest = (char *) ((Node_New_WOV_Msg  *) msgForNodes + 1); 
+       for(i = 0; i < newWov->wovSize; i++)  
+               *dest++ = *src++; /* copy data into the message struct */
+
+TRACE(CmiPrintf("Host::  HostAddWriteOnceVar...wovID %d, size %d\n",
+                       msgForNodes->wovID, newWov->wovSize);)
+
+       GeneralBroadcastMsgBranch(NodeAddWOV_EP, msgForNodes,
+                       IMMEDIATEcat, BroadcastBocMsg, WOVBocNum);
+
+       localBocData->numWOVs++;            /* weve got one more wov */
+}
+
+
+/***************************************************************************
+ Here we receive the acknowledgement from our child node (the root of the 
+ spanning tree) that ALL the nodes have indeed created the write once variable
+ in question. We can then send a message to the user program on the originating
+ node, telling the user that it is now ok to access the WOV, or to broadcast
+ the id to other nodes, or whatever.  ***************************************************************************/ 
+HostReceiveAcknowledge(msgptr_,localdataptr_)
+void *msgptr_,*localdataptr_;
+{
+       Ack_To_Host_Msg *ackMessage    = (Ack_To_Host_Msg *) msgptr_;
+       WOV_Boc_Data    *localBocData  = (WOV_Boc_Data *) localdataptr_;
+       Return_To_Origin_Msg *msgForCreator;
+       WriteOnceID          wovID;
+
+TRACE(CmiPrintf("[%d]:: HostRecvAck...wovID %d, Notifying user at ep [%d]\n",
+               CmiMyPe(),
+               ackMessage->wovID,
+               localBocData->WOVArray[(int)ackMessage->wovID].ep);)
+
+       msgForCreator = (Return_To_Origin_Msg *)
+                               CkAllocMsg(sizeof(Return_To_Origin_Msg));
+       CkMemError(msgForCreator);
+       wovID = msgForCreator->wovID = ackMessage->wovID;
+
+       SendMsg(localBocData->WOVArray[(int) wovID].ep,msgForCreator,
+           &localBocData->WOVArray[(int) wovID].cid);
+}
+
+
+/***************************************************************************
+If we call WriteOnce from the host, we don't need to send a message, just
+call the appropriate routine.
+***************************************************************************/
+void WriteOnce(dataPtr,dataSize,ep,cid)
+char           *dataPtr;
+int            dataSize;
+EntryPointType ep;
+ChareIDType    cid;
+{
+       Host_New_WOV_Msg *newWov;
+       int msgSize,i;
+       char *src,*dest;
+
+       TRACE(CmiPrintf("Node %d : WriteOnce called.\n", CmiMyPe()));
+       msgSize = dataSize + sizeof(Host_New_WOV_Msg);
+       newWov = (Host_New_WOV_Msg *) CkAllocMsg(msgSize);
+       CkMemError(newWov);
+
+       newWov->cid = cid;
+       newWov->ep = ep;            /* fill up the fields of the struct */
+       newWov->wovSize = dataSize;
+       src  = dataPtr; 
+       dest = (char *) ((Host_New_WOV_Msg *) newWov + 1);
+       for(i = 0; i < dataSize; i++)
+               *dest++ = *src++;
+       /* here we bypass the SendMsg function and just call directly */
+       if (CmiMyPe() == 0)
+               HostAddWriteOnceVar(newWov,GetBocDataPtr(WOVBocNum));
+       else
+               GeneralSendMsgBranch(HostAddWOV_EP, newWov,
+                   0, IMMEDIATEcat, BocMsg, WOVBocNum);
+}
+
+
+WOVAddSysBocEps()
+{
+       EpTable[NodeAddWOV_EP] = (FUNCTION_PTR) NodeAddWriteOnceVar;
+       EpTable[NodeRcvAck_EP] = (FUNCTION_PTR) NodeReceiveAcknowledge;
+       EpTable[HostAddWOV_EP] = (FUNCTION_PTR) HostAddWriteOnceVar;
+       EpTable[HostRcvAck_EP] = (FUNCTION_PTR) HostReceiveAcknowledge;
+}
+
diff --git a/src/ck-core/wrtone.h b/src/ck-core/wrtone.h
new file mode 100644 (file)
index 0000000..bae69a6
--- /dev/null
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-02 17:30:04  brunner
+ * Reorganized directory structure
+ *
+ * Revision 1.3  1995/04/13  20:53:46  sanjeev
+ * Changed Mc to Cmi
+ *
+ * Revision 1.2  1994/11/11  05:24:46  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:39:15  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+/****************************************************************************
+
+   Types and stuff for write-once variables
+
+****************************************************************************/
+
+#define MAXWRITEONCEVARS  50         /* arbitrary maximum number */
+
+#define isLeaf(peNum) (CmiNumSpanTreeChildren(peNum) == 0)
+
+/* Data Structures. We keep a different type for the host and for the nodes */
+/* This is because on the nodes we don't need a lot of the information that */
+/* is kept on the host to inform the user program that the wov has been     */
+/* created.                                                                 */
+
+typedef struct {              /* data needed for each write once variable */
+    EntryPointType ep;
+    ChareIDType    cid;
+    int                   numAcks;
+    int            wovSize;
+    char           *wovData;
+    } WOV_Elt_Data;
+
+/* this is the struct that holds the local boc data */
+typedef struct {           
+    int numWOVs;              /* current number of write once variables    */
+    WOV_Elt_Data WOVArray[MAXWRITEONCEVARS];
+    } WOV_Boc_Data;
+
+/* the rest of the structs are messaged that are passed around */
+typedef struct {            /* Original message sent from node up To the host.*/
+    ChareIDType    cid;
+    EntryPointType ep;
+    int            wovSize;
+    } Host_New_WOV_Msg;
+
+typedef struct {            /* Message sent from the host down to the nodes   */
+    WriteOnceID    wovID;
+    int            wovSize;
+    } Node_New_WOV_Msg;
+
+typedef struct {            /* Acknowledge msg passed up the tree to the host.*/
+    WriteOnceID    wovID;
+    } Ack_To_Host_Msg;
+
+typedef struct {            /* Final message returned to the user program.    */
+    WriteOnceID    wovID;
+    } Return_To_Origin_Msg;
+