Merge branch 'charm' of charmgit:charm into charm
authorChao Mei <chaomei2@illinois.edu>
Sat, 30 Oct 2010 22:46:13 +0000 (17:46 -0500)
committerChao Mei <chaomei2@illinois.edu>
Sat, 30 Oct 2010 22:46:13 +0000 (17:46 -0500)
17 files changed:
src/arch/mpi-linux-x86_64/conv-mach-smp.h
src/ck-com/ComlibSectionInfo.C
src/ck-perf/trace-summary.C
src/ck-perf/trace-summary.h
src/langs/charj/build.xml
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/CharjASTModifier.g
src/langs/charj/src/charj/translator/CharjASTModifier2.g
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjSemantics.g
src/langs/charj/src/charj/translator/SymbolDefiner.g
src/langs/charj/src/charj/translator/SymbolResolver.g
tests/charm++/commtest/broadcast/Makefile [new file with mode: 0644]
tests/charm++/commtest/broadcast/broadcast.C [new file with mode: 0644]
tests/charm++/commtest/broadcast/broadcast.ci [new file with mode: 0644]
tests/charm++/commtest/commlib_stream/hello.C
tests/charm++/commtest/pipeBroadcast/test.C

index df0b2327c0eeb6a930e107855cd00aa0d6ba518c..d151c6de355011430d9fd2abde8603243d35ef2b 100644 (file)
@@ -15,8 +15,8 @@
 
 #undef CMK_MALLOC_USE_GNU_MALLOC
 #undef CMK_MALLOC_USE_OS_BUILTIN
-#define CMK_MALLOC_USE_GNU_MALLOC                          0
-#define CMK_MALLOC_USE_OS_BUILTIN                          1
+#define CMK_MALLOC_USE_GNU_MALLOC                          1
+#define CMK_MALLOC_USE_OS_BUILTIN                          0
 
 /*#define  CMK_USE_MFENCE                                    1 */
 /*#define  CMK_PCQUEUE_LOCK                                  1 */
index dffda71fbb23014577cf45c1160885416bfb8609..db5682d97fed25fe40a84ec8005a8764515971d4 100644 (file)
@@ -198,6 +198,7 @@ void ComlibSectionInfo::processOldSectionMessage(CharmMessageHolder *cmsg) {
 
     //Old section id, send the id with the message
     CkMcastBaseMsg *cbmsg = (CkMcastBaseMsg *)cmsg->getCharmMessage();
+    cbmsg->_cookie.pe = CkMyPe();
     cbmsg->_cookie.sInfo.cInfo.id = cur_sec_id;
     cbmsg->_cookie.sInfo.cInfo.status = COMLIB_MULTICAST_OLD_SECTION;
 }
index 3b13bb8b8ae01d6cc948681ee7685f0e6d635923..82d6c56a0c64ac8cf9592fc7cc23d69cd08a5505 100644 (file)
@@ -726,18 +726,20 @@ void TraceSummary::endExecute(void)
   double ts = start;
   double nts = binStart;
 
+/*
   if (execEp == TRACEON_EP) {
     // if trace just got turned on, then one expects to see this
     // END_PROCESSING event without seeing a preceeding BEGIN_PROCESSING
     return;
   }
+*/
 
   if (execEp == INVALIDEP) {
     TRACE_WARN("Warning: TraceSummary END_PROCESSING without BEGIN_PROCESSING!\n");
     return;
   }
 
-  if (execEp != -1)
+  if (execEp >= 0)
   {
     _logPool->setEp(execEp, t-ts);
   }
@@ -800,6 +802,16 @@ void TraceSummary::endIdle(double currT)
   binIdle += t - t_idleStart;
 }
 
+void TraceSummary::traceBegin(void)
+{
+  beginExecute(-1, -1, TRACEON_EP, -1, -1);
+}
+
+void TraceSummary::traceEnd(void)
+{
+  endExecute();
+}
+
 void TraceSummary::beginPack(void)
 {
     packstart = CmiWallTimer();
index 7372587b6db05d55b56161d9a3c797dbf45ec5b0..2db5b5655165fd57f5556333bcba963aa5690361 100644 (file)
@@ -270,6 +270,8 @@ class TraceSummary : public Trace {
     void endExecute(void);
     void beginIdle(double currT);
     void endIdle(double currT);
+    void traceBegin(void);
+    void traceEnd(void);
     void beginPack(void);
     void endPack(void);
     void beginUnpack(void);
index 3e49553dd7d65a2c349be88afd3c84a52c2257d8..e11481bfca6010f62fb01b230766c4f745648e78 100644 (file)
@@ -30,8 +30,9 @@
     <target name="compile"
         description="compile">
         <javac debug="true" srcdir="${buildsrc}" destdir="${classes}"
-               target="1.5" listfiles="Yes" deprecation="Yes">
-               <classpath refid="${classpath}"/>
+            target="1.5" listfiles="Yes" deprecation="Yes"
+            includeantruntime="false">
+            <classpath refid="${classpath}"/>
         </javac>
     </target>
 
index 9da829872543e5b1410889b6225d719c8555f18d..0b3bc40c4bc2868232be1ed34df37218e16e3355 100644 (file)
@@ -268,6 +268,7 @@ compilationUnit
 topLevelDeclaration
     :   importDeclaration
     |   readonlyDeclaration
+    |   externDeclaration
     |   typeDeclaration
     ;
 
@@ -284,6 +285,10 @@ readonlyDeclaration
     :   READONLY^ localVariableDeclaration ';'!
     ;
 
+externDeclaration
+    :   EXTERN^ qualifiedIdentifier ';'!
+    ;
+
 typeDeclaration
     :   classDefinition
     |   templateDeclaration
index c0c395feacb88328c22b767be75a6c92501690a4..fcc78d3d9f0448974a4b55480aaf047133b28807 100644 (file)
@@ -42,8 +42,9 @@ charjSource
     :   ^(CHARJ_SOURCE 
         packageDeclaration?
         importDeclaration*
-        readonlyDeclaration*
-        typeDeclaration*)
+        (externDeclaration
+        |readonlyDeclaration
+        |typeDeclaration)*)
     ;
 
 packageDeclaration
@@ -58,6 +59,10 @@ readonlyDeclaration
     :   ^(READONLY localVariableDeclaration)
     ;
 
+externDeclaration
+    :   ^(EXTERN qualifiedIdentifier)
+    ;
+
 typeOfType returns [boolean array_type]
     : CLASS 
     | chareType 
index 3eb4d8264b591b7eb0926ae3470aa49980b51517..a5b00e9f2206358b7d97694c05bb380ab72ed462 100644 (file)
@@ -65,6 +65,7 @@ charjSource[SymbolTable _symtab] returns [ClassSymbol cs]
         (packageDeclaration)? 
         (importDeclaration
         | typeDeclaration { $cs = $typeDeclaration.sym; }
+        | externDeclaration
         | readonlyDeclaration)*)
     ;
 
@@ -81,6 +82,10 @@ readonlyDeclaration
     :   ^(READONLY localVariableDeclaration)
     ;
 
+externDeclaration
+    :   ^(EXTERN qualifiedIdentifier)
+    ;
+
 typeDeclaration returns [ClassSymbol sym]
     :   ^(TYPE classType IDENT { currentClass = (ClassSymbol) $IDENT.def.type; }
             (^('extends' parent=type))? (^('implements' type+))?
index f491a118a08dcdb960b3fe7b383e5dbce6110cee..3c0a80f2672b92e789cd35dd0720cfbd7cc4c767 100644 (file)
@@ -84,9 +84,10 @@ charjSource[SymbolTable symtab, OutputMode m]
     this.mode_ = m;
 }
     :   ^(CHARJ_SOURCE (p=packageDeclaration)? 
-        (i+=importDeclaration)*
-        (r+=readonlyDeclaration)*
-        (t+=typeDeclaration)*)
+        ((i+=importDeclaration)
+        |(r+=readonlyDeclaration)
+        |externDeclaration
+        |(t+=typeDeclaration))*)
         -> {emitCC()}? charjSource_cc(basename={basename()}, pd={$p.names}, imports={$i}, types={$t}, ros={$r}, debug={debug()})
         -> {emitCI()}? charjSource_ci(basename={basename()}, pd={$p.names}, imports={$i}, types={$t}, ros={$r}, debug={debug()})
         -> {emitH()}? charjSource_h(basename={basename()}, pd={$p.names}, imports={$i}, types={$t}, ros={$r}, debug={debug()})
@@ -113,6 +114,11 @@ readonlyDeclaration
         -> {emitCC()}? {$lvd.st;}
         ->
     ;
+
+externDeclaration
+    :   ^(EXTERN qualifiedIdentifier)
+        ->
+    ;
     
 importDeclaration
 @init {
index bdc3da6ea33fb8ee15286c41d0376e2d14ed0793..a1d56b00145f7058e173eaf7478970470cdea3f8 100644 (file)
@@ -91,6 +91,7 @@ scope ScopeStack; // default scope
         (packageDeclaration)? 
         (importDeclaration
         | typeDeclaration { $cs = $typeDeclaration.sym; }
+        | externDeclaration
         | readonlyDeclaration)*)
     ;
 
@@ -122,6 +123,10 @@ readonlyDeclaration
     :   ^(READONLY localVariableDeclaration)
     ;
 
+externDeclaration
+    :   ^(EXTERN qualifiedIdentifier)
+    ;
+
 typeDeclaration returns [ClassSymbol sym]
 scope ScopeStack; // top-level type scope
     :   ^(TYPE classType IDENT
index 9d5b521c527df89540861d75e1a9980d24fd4736..509b16fa9b46e02bda9deabcd7ffc09038647882 100644 (file)
@@ -28,6 +28,7 @@ package charj.translator;
 
 topdown
     :   enterPackage
+    |   externDeclaration
     |   enterClass
     |   enterMethod
     |   enterBlock
@@ -59,6 +60,13 @@ enterPackage
         }
     ;
 
+externDeclaration
+    :   ^(EXTERN IDENT) {
+            ExternalSymbol sym = new ExternalSymbol(symtab, $IDENT.text);
+            currentScope.define(sym.name, sym);
+        }
+    ;
+
 enterBlock
     :   BLOCK {
             $BLOCK.scope = new LocalScope(symtab, currentScope);
index e799fa1da3de1e0265fa1c54326b2ac851b0693c..b761d794a9467db967501e1f6378aaf208196438 100644 (file)
@@ -218,7 +218,11 @@ primaryExpression returns [Type type]
                 $IDENT.symbolType = $type;
                 //System.out.println("Resolved type of " + $IDENT.text + ": " + $type + ", symbol is " + $IDENT.def);
             } else {
-                System.out.println("Couldn't resolve IDENT type: " + $IDENT.text);
+                if (!$IDENT.text.equals("thishandle") &&
+                        !$IDENT.text.equals("thisIndex") &&
+                        !$IDENT.text.equals("thisProxy")) {
+                    System.out.println("ERROR: Couldn't resolve IDENT type: " + $IDENT.text);
+                }
             }
         }
     |   THIS {
@@ -258,7 +262,7 @@ primaryExpression returns [Type type]
                 memberNode.symbolType = $type;
                 parentNode.def = s;
                 parentNode.symbolType = $type;
-            } else {
+            } else if (!(et instanceof ExternalSymbol)) {
                 System.out.println("Couldn't resolve access " + memberText);
             }
         }
@@ -366,14 +370,16 @@ type returns [Type sym]
 }
 @after {
     $start.symbolType = scope.resolveType(typeText);
-    //System.out.println("\ntype string: " + typeText);
-    //System.out.println("direct scope: " + scope);
-    //System.out.println("symbolType: " + $start.symbolType);
     if (proxy && $start.symbolType != null) $start.symbolType = new ProxyType(symtab, $start.symbolType);
     if (pointer && $start.symbolType != null) $start.symbolType = new PointerType(symtab, $start.symbolType);
        if (proxySection && $start.symbolType != null) $start.symbolType = new ProxySectionType(symtab, $start.symbolType);
     $sym = $start.symbolType;
-    if ($sym == null) System.out.println("Couldn't resolve type: " + typeText);
+    if ($sym == null) {
+        //System.out.println("type string: " + typeText);
+        //System.out.println("direct scope: " + scope);
+        //System.out.println("symbolType: " + $start.symbolType);
+        System.out.println("ERROR: Couldn't resolve type " + typeText);
+    }
 }
     :   VOID {
             scope = $VOID.scope;
@@ -386,17 +392,18 @@ type returns [Type sym]
     |   ^(OBJECT_TYPE { scope = $OBJECT_TYPE.scope; }
             ^(QUALIFIED_TYPE_IDENT (^(IDENT (^(TEMPLATE_INST
                 (t1=type {tparams.add($t1.sym);} | lit1=literalVal {tparams.add($lit1.type);} )*))?
-                {typeText.add(new TypeName($IDENT.text, tparams));}))+) .*)
+                {typeText.add(new TypeName($IDENT.text, tparams)); }))+) .*)
     |   ^(REFERENCE_TYPE { scope = $REFERENCE_TYPE.scope; }
-            ^(QUALIFIED_TYPE_IDENT (^(IDENT  {typeText.add(new TypeName($IDENT.text));} .*))+) .*)
+            ^(QUALIFIED_TYPE_IDENT (^(IDENT {typeText.add(new TypeName($IDENT.text));} .*))+) .*)
     |   ^(PROXY_TYPE { scope = $PROXY_TYPE.scope; proxy = true; }
             ^(QUALIFIED_TYPE_IDENT (^(IDENT {typeText.add(new TypeName($IDENT.text));} .*))+) .*)
        |       ^(ARRAY_SECTION_TYPE { scope = $ARRAY_SECTION_TYPE.scope; proxySection = true; }
                        ^(QUALIFIED_TYPE_IDENT (^(IDENT {typeText.add(new TypeName($IDENT.text));} .*))+) .*)
     |   ^(POINTER_TYPE { scope = $POINTER_TYPE.scope; pointer = true; }
             ^(QUALIFIED_TYPE_IDENT (^(IDENT (^(TEMPLATE_INST
-            (t1=type {tparams.add($t1.sym);} | lit1=literalVal {tparams.add($lit1.type);} )*))?
-            {typeText.add(new TypeName($IDENT.text, tparams));}))+) .*)
+                        (t1=type {tparams.add($t1.sym);}
+                        |lit1=literalVal {tparams.add($lit1.type);} )*))?)
+            {typeText.add(new TypeName($IDENT.text, tparams));})+) .*)
     ;
 
 classType
diff --git a/tests/charm++/commtest/broadcast/Makefile b/tests/charm++/commtest/broadcast/Makefile
new file mode 100644 (file)
index 0000000..9cfebfc
--- /dev/null
@@ -0,0 +1,25 @@
+# Makefile for compiling Comlib tests
+
+CHARMC=../../../../bin/charmc $(OPTS)
+
+OBJS = broadcast.o
+
+all: broadcast
+
+broadcast: $(OBJS)
+       $(CHARMC) -language charm++ -o broadcast $(OBJS) -module comlib
+
+broadcast.decl.h: broadcast.ci
+       $(CHARMC)  broadcast.ci
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o broadcast charmrun *.log *.sum *.sts *~
+
+broadcast.o: broadcast.C broadcast.decl.h
+       $(CHARMC) -c -g broadcast.C
+
+test: all
+       ./charmrun ./broadcast +p4 10
+
+bgtest: all
+       ./charmrun ./broadcast +p4 10 +x2 +y2 +z2 +cth1 +wth1
diff --git a/tests/charm++/commtest/broadcast/broadcast.C b/tests/charm++/commtest/broadcast/broadcast.C
new file mode 100644 (file)
index 0000000..19a8d88
--- /dev/null
@@ -0,0 +1,128 @@
+#include "broadcast.decl.h"
+
+#include <comlib.h>
+#include <cassert>
+#include <unistd.h>
+/*
+ * Test of Broadcast Strategy
+ */
+
+CProxy_Main mainProxy;
+CProxy_Broadcast broadcastProxy;
+int numEl;
+
+ComlibInstanceHandle stratBroadcast;
+
+class broadcastMessage : public CMessage_broadcastMessage {
+public:
+  int length;
+  char* msg;
+};
+
+// mainchare
+
+class Main : public CBase_Main
+{
+private:
+  int nDone;
+
+public:
+
+  Main(CkArgMsg *m) {    
+    nDone = 0;
+       if (m->argc>1) numEl = atoi(m->argv[1]);
+       else numEl = 100;
+
+
+   // comm_debug = 1;
+    delete m;
+
+    mainProxy = thishandle;
+       
+    broadcastProxy = CProxy_Broadcast::ckNew();
+    
+   // ComlibAssociateProxy(stratBroadcast, broadcastProxy                              );
+       
+   // create broadcast strategy using the hypercube topology
+    BroadcastStrategy *strategy = new BroadcastStrategy(USE_TREE);
+  //  PipeBroadcastStrategy *strategy = new PipeBroadcastStrategy(broadcastProxy,USE_TREE);
+    stratBroadcast = ComlibRegister(strategy);
+
+//     CkPrintf("Main: Sleeping %d \n", CkNumPes());
+//     usleep(50*1000*1000);
+//     broadcastProxy.TestBroadcast();
+       broadcastProxy.IntermediateCall();
+       CkPrintf("Main: Started %d \n", CkNumPes());
+  }
+
+  void Intermediate(){
+    nDone++;
+    if (nDone == CkNumPes()){ nDone = 0;
+      
+       broadcastProxy.TestBroadcast();
+       }
+  }
+  
+
+  void exit() {
+    nDone++;
+    if (nDone == CkNumPes())
+      CkExit();
+  }
+
+};
+
+class Broadcast : public CBase_Broadcast {
+private:
+  CProxy_Broadcast localProxy;
+
+public:
+
+  Broadcast() {
+
+//     usleep(50*1000*1000);
+    CkPrintf("element %d \n", CkMyPe());
+    localProxy = thisProxy;
+//   ComlibAssociateProxy(stratBroadcast, localProxy);
+  }
+
+  Broadcast(CkMigrateMessage *m) {}
+    
+  void TestBroadcast() {
+
+  
+//     usleep(50*1000*1000);
+         if (CkMyPe() == 0) {
+         ComlibAssociateProxy(stratBroadcast, localProxy);
+   //   CkPrintf("Registered element %d of %d \n", CkMyPe(), CkNumPes());
+      char msg[] = "|This is a short broadcast message|";
+      broadcastMessage* b = new(strlen(msg)+1,0) broadcastMessage;
+       
+      memcpy(b->msg, msg, strlen(msg)+1);
+      b->length = strlen(msg);
+//     usleep(50*1000*1000);
+      localProxy.receive(b);
+    }
+       
+  }
+
+  void receive(broadcastMessage* m) {
+
+   // CkPrintf("Received using commlib %d of %d \n", CkMyPe(), CkNumPes());
+    CkPrintf("Message: %s arrived at element %d\n", m->msg, CkMyPe());
+   // assert(strcmp(m->msg,"|This is a short broadcast message|") == 0);
+    mainProxy.exit();
+  
+  }
+
+  void IntermediateCall() {
+
+    CkPrintf("Intermediate %d of %d \n", CkMyPe(), CkNumPes());
+    //CkPrintf("Message: %s arrived at element %d\n", m->msg, CkMyPe());
+   // assert(strcmp(m->msg,"|This is a short broadcast message|") == 0);
+    mainProxy.Intermediate();
+  }
+
+};
+
+#include "broadcast.def.h"
diff --git a/tests/charm++/commtest/broadcast/broadcast.ci b/tests/charm++/commtest/broadcast/broadcast.ci
new file mode 100644 (file)
index 0000000..2cccfcc
--- /dev/null
@@ -0,0 +1,25 @@
+mainmodule broadcast {
+                        
+  readonly CProxy_Main mainProxy;      
+  readonly CProxy_Broadcast broadcastProxy;
+  readonly int numEl;
+       readonly ComlibInstanceHandle stratBroadcast;
+
+  message broadcastMessage {
+    char msg[];
+  };
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void Intermediate(void);
+    entry void exit();         
+  };
+
+group Broadcast {
+    entry Broadcast();                 
+    entry void TestBroadcast(void);
+    entry void IntermediateCall(void);
+    entry void receive(broadcastMessage* m);
+  };
+
+};
index 550e3aac85b157143b3f795d439e21e9ae88b6d1..f5bdbe5d171c6b3ff1b91ad56c86d3f371476daf 100644 (file)
@@ -1,5 +1,6 @@
 
 #include <stdio.h>
+#include <comlib.h>
 #include "hello.decl.h"
 #include "StreamingStrategy.h"
 #include "MeshStreamingStrategy.h"
@@ -46,10 +47,10 @@ public:
        //strat->enableShortArrayMessagePacking();
        //strat->disableIdleFlush();
        
-       mstrat->enableShortArrayMessagePacking();
+//     mstrat->enableShortArrayMessagePacking();
        
-       ComlibInstanceHandle cinst = CkGetComlibInstance();
-       cinst.setStrategy(strat); 
+//     ComlibInstanceHandle cinst = CkGetComlibInstance();
+       ss_inst = ComlibRegister(strat); 
        
        //ComlibInstanceHandle cinst1 = CkGetComlibInstance();
        
@@ -96,7 +97,8 @@ public:
         
         // CkPrintf("Hi[%d] from element %d\n",hiNo,thisIndex);
         CProxy_Hello array_proxy = thisProxy;
-        ComlibDelegateProxy(&array_proxy);
+        //ComlibDelegateProxy(&array_proxy);
+               ComlibAssociateProxy(ss_inst, array_proxy);
         
         int next = thisIndex+1;
         if(next >= nElements)
index 1bcd8e37efe893fa3bf6e56ea11c2fbe4bc21f3a..0171fa71c49299ee9cfde69f5c4219e26a9eb0c9 100644 (file)
@@ -23,11 +23,11 @@ TheMain::TheMain(CkArgMsg *msg) {
   called = 0;
   arr = CProxy_Test::ckNew(numEl);
 
-  cinst = CkGetComlibInstance();
+//  cinst = CkGetComlibInstance();
   mainProxy = thishandle;
 
-  CharmStrategy *strategy = new PipeBroadcastStrategy(USE_HYPERCUBE, arr);
-  cinst.setStrategy(strategy);
+  PipeBroadcastStrategy *strategy = new PipeBroadcastStrategy(USE_HYPERCUBE, arr);
+  cinst = ComlibRegister(strategy);
   CkPrintf("Main: calling send on %d elements\n",numEl);
   arr.send();
   //arr[2].send();
@@ -50,8 +50,12 @@ void Test::send() {
   MyMess *mess = new (LENGTH,0) MyMess;
   mess->data[0] = CkMyPe();
   for (int i=1; i<LENGTH; ++i) mess->data[i] = i+1000;
-  CProxy_Test copy = thisArrayID;
-  ComlibDelegateProxy(&copy);
+  CProxy_Test copy = thisProxy;
+  // CProxy_Test copy = thisArrayID;
+  ComlibAssociateProxy(cinst, copy);
+  
+ // ComlibDelegateProxy(&copy);
   CkPrintf("[%d-%d] sending broadcast\n",CkMyPe(),thisIndex);
   copy.receive(mess);
 }