Charj: merge grammar changes for messages and reductions
authorAaron Becker <akbecker@gmail.com>
Tue, 19 Jun 2012 18:54:20 +0000 (13:54 -0500)
committerAaron Becker <akbecker@gmail.com>
Tue, 19 Jun 2012 18:54:20 +0000 (13:54 -0500)
19 files changed:
src/langs/charj/src/charj/translator/Accel.g [new file with mode: 0644]
src/langs/charj/src/charj/translator/CFGBuilder.g
src/langs/charj/src/charj/translator/Charj.g
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/CharjAST.java
src/langs/charj/src/charj/translator/CharjEmitter.g
src/langs/charj/src/charj/translator/CharjPostAnalysis.g
src/langs/charj/src/charj/translator/CharjPreAnalysis.g
src/langs/charj/src/charj/translator/InitPUPCollector.g
src/langs/charj/src/charj/translator/MSA.g [new file with mode: 0644]
src/langs/charj/src/charj/translator/MessageType.java [new file with mode: 0644]
src/langs/charj/src/charj/translator/MethodSymbol.java
src/langs/charj/src/charj/translator/SymbolDefiner.g
src/langs/charj/src/charj/translator/SymbolResolver.g
src/langs/charj/tests/fib/Fib.cj
src/langs/charj/tests/functional/Main.cj
src/langs/charj/tests/leanmd/leanmd.cj
src/langs/charj/tests/unit/MulticastMessage.cj [new file with mode: 0644]
src/langs/charj/tests/unit/Reduction.cj

diff --git a/src/langs/charj/src/charj/translator/Accel.g b/src/langs/charj/src/charj/translator/Accel.g
new file mode 100644 (file)
index 0000000..1623494
--- /dev/null
@@ -0,0 +1,91 @@
+
+tree grammar Accel;
+
+options {
+    tokenVocab = Charj;
+    ASTLabelType = CharjAST;
+    filter = true;
+}
+
+@header {
+    package charj.translator;
+}
+
+@members {
+    Scope currentScope;
+    ClassSymbol currentClass = null;
+    MethodSymbol currentMethod = null;
+}
+
+topdown
+    :   enterClass
+    |   enterMethod
+    |   atoms
+    ;
+
+bottomup
+    :   exitMethod
+    |   exitClass
+    ;
+
+classType
+    :   CLASS
+    |   CHARE
+    |   GROUP
+    |   NODEGROUP
+    |   MAINCHARE
+    |   ^(CHARE_ARRAY ARRAY_DIMENSION)
+    ;
+
+enterClass
+    :   ^(TYPE classType IDENT
+        (^('extends' .*))?
+        (^('implements' .*))?
+        (^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | PRIMITIVE_VAR_DECLARATION | DIVCON_METHOD_DECL |
+            OBJECT_VAR_DECLARATION | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*))*)
+        {
+            currentClass = (ClassSymbol)$IDENT.def.type;
+            currentClass.isMainChare = $classType.text.equals("mainchare");
+        }
+    ;
+
+exitClass
+    :   ^(TYPE classType IDENT
+        (^('extends' .*))?
+        (^('implements' .*))?
+        (^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | PRIMITIVE_VAR_DECLARATION | DIVCON_METHOD_DECL |
+            OBJECT_VAR_DECLARATION | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*))*)
+        {
+            currentClass = null;
+        }
+    ;
+
+enterMethod
+    :   ^(ENTRY_FUNCTION_DECL ^(ml=MODIFIER_LIST .*) type IDENT .*)
+        {
+            currentMethod = (MethodSymbol)$IDENT.def.type;
+            if ($ml.hasAccelModifier()) currentMethod.accel = true;
+        }
+    ;
+
+exitMethod
+    :   ^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL
+            | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*)
+        {
+            currentMethod = null;
+        }
+    ;
+
+type
+    :   VOID
+    |   ^((OBJECT_TYPE|PROXY_TYPE|REFERENCE_TYPE|POINTER_TYPE
+          |MESSAGE_TYPE|ARRAY_SECTION_TYPE) .*)
+    ;
+
+atoms
+    :  (id=IDENT) {
+            if (currentMethod != null && currentMethod.accel) {
+                currentMethod.addAccelIdent($id);
+            }
+       }
+    ;
index 56b99b12f560bf67c9c414ebbbcf9cd1562a1a00..7213586f3d5e2c46bfdc5f680f900e984626dde5 100644 (file)
@@ -198,6 +198,8 @@ type
             ^(QUALIFIED_TYPE_IDENT (^(IDENT .*))+) .*)
        |       ^(ARRAY_SECTION_TYPE 
                        ^(QUALIFIED_TYPE_IDENT (^(IDENT .*))+) .*)
+       |       ^(MESSAGE_TYPE 
+                       ^(QUALIFIED_TYPE_IDENT (^(IDENT .*))+) .*)
     |   ^(POINTER_TYPE 
             ^(QUALIFIED_TYPE_IDENT (^(IDENT (^(TEMPLATE_INST
                         (t1=type | lit1=literalVal)*))?))+) .*)
index 33f28b736fda3c86887581eedd99b361cced5268..a35c85f34ce964de38f2484cab7f471a7df0e9ad 100644 (file)
@@ -57,6 +57,9 @@ tokens {
     NODEGROUP               = 'nodegroup'       ;
     ENUM                    = 'enum'            ;
     READONLY                = 'readonly'        ;
+    ACCELERATED             = 'accelerated'     ;
+    THREADED                = 'threaded'        ;
+    REDUCTIONTARGET         = 'reductiontarget' ;
 
     OVERLAP                 = 'overlap'         ;
     WHEN                    = 'when'            ;
@@ -70,10 +73,14 @@ tokens {
     GETMYNODE               = 'getMyNode'       ;
     GETNUMPES               = 'getNumPes'       ;
     GETNUMNODES             = 'getNumNodes'     ;
+    CONTRIBUTE              = 'contribute'      ;
 
     THISINDEX              = 'thisIndex'       ;
     THISPROXY              = 'thisProxy'       ;
 
+    MESSAGE                 = 'message'          ;
+    MULTICAST_MESSAGE       = 'multicast_message';
+
     FOR                     = 'for'             ;
     WHILE                   = 'while'           ;
     IF                      = 'if'              ;
@@ -226,6 +233,7 @@ tokens {
        ARRAY_SECTION_TYPE;
        ARRAY_SECTION;
        ARRAY_SECTION_INIT;
+    MESSAGE_TYPE;
     PRIMITIVE_VAR_DECLARATION;
     OBJECT_VAR_DECLARATION;
     VAR_DECLARATOR;
@@ -296,6 +304,7 @@ typeDeclaration
     |   interfaceDefinition
     |   enumDefinition
     |   chareDefinition
+    |   messageDefinition
     ;
 
 templateList
@@ -342,6 +351,13 @@ enumDefinition
         -> ^(ENUM IDENT ^('implements' typeList)? enumConstants classScopeDeclaration*)
     ;
 
+messageDefinition
+    :   MESSAGE IDENT '{' messageScopeDeclaration* '}' ';'?
+        -> ^(MESSAGE IDENT messageScopeDeclaration*)
+    |   MULTICAST_MESSAGE IDENT '{' messageScopeDeclaration* '}' ';'?
+        -> ^(MULTICAST_MESSAGE IDENT messageScopeDeclaration*)
+    ;
+
 enumConstants
     :   enumConstant (','! enumConstant)*
     ;
@@ -354,6 +370,11 @@ typeList
     :   type (','! type)*
     ;
 
+messageScopeDeclaration
+    :  primitiveVariableDeclaration
+       |       objectVariableDeclaration
+    ;
+
 classScopeDeclaration
     :   functionMethodDeclaration
        |       constructorDeclaration
@@ -486,6 +507,8 @@ modifier
     |   ENTRY
     |   SDAGENTRY
     |   TRACED
+    |   ACCELERATED
+    |   THREADED
     |   PRIVATE
     |   ABSTRACT
     |   NATIVE
@@ -516,6 +539,8 @@ constructorType
         ->  ^(OBJECT_TYPE qualifiedTypeIdent domainExpression?)
        |       MOD qualifiedTypeIdent AT domainExpression
                ->      ^(ARRAY_SECTION_TYPE qualifiedTypeIdent domainExpression)
+    |   qualifiedTypeIdent TILDE 
+        ->  ^(MESSAGE_TYPE qualifiedTypeIdent)
     ;
 
 simpleType
@@ -530,6 +555,8 @@ objectType
         ->  ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
        |       qualifiedTypeIdent '[' MOD ']' AT
                ->      ^(ARRAY_SECTION_TYPE qualifiedTypeIdent)
+       |       qualifiedTypeIdent '[' TILDE ']' AT
+               ->      ^(MESSAGE_TYPE qualifiedTypeIdent)
     ;
 
 qualifiedTypeIdent
@@ -718,6 +745,8 @@ nonBlockStatement
         ->  ^(EXIT expression?)
     |   EXITALL '(' ')' ';'
         ->  EXITALL
+    |   CONTRIBUTE '(' expression ',' qualifiedIdentifier ',' expression ')' ';'
+        -> ^(CONTRIBUTE expression qualifiedIdentifier expression)
     ;           
         
 
index 7a97d6356fd8e1156783f72c4ec4e7c4a9fb0005..d501876ba688acb85718ebfaf1f94e24a204deaf 100644 (file)
@@ -2,12 +2,12 @@ group Charj;
 
 charjSource_ci(basename, pd, imports, types, ros, debug) ::=
 <<
+mainmodule <basename> {
 
 // interface for <basename>
 <imports; separator="\n">
 <types; separator="\n\n">
 
-module <basename>_readonly {
 <if(ros)>
     <charjReadonly_ci(pds = pd, ros = ros)>
 <endif>
@@ -18,10 +18,10 @@ module <basename>_readonly {
 
 charjReadonly_ci(pds, ros) ::=
 <<
-<if(first(pds))>namespace <first(pds)>
-{
-    <charjReadonly_ci(pds = rest(pds), ros = ros)>
-} // namespace <first(pds)>
+//<if(first(pds))>namespace <first(pds)>
+//{
+<charjReadonly_ci(pds = rest(pds), ros = ros)>
+//} // namespace <first(pds)>
 <else>
 <ros; separator="\n">
 <endif>
@@ -39,12 +39,13 @@ charjSource_h(basename, pd, imports, types, ros, debug) ::=
  * It is not meant to be edited by hand and may be overwritten by charjc. *
  **************************************************************************/
 
+#include "<basename>.decl.h"
 <imports; separator="\n">
 <types; separator="\n\n">
 <if(ros)>
 /* Readonly variables */
 <readonlys_h(pds = pd, ros = ros)>
-#include "<basename>_readonly.decl.h"
+//#include "<basename>_readonly.decl.h"
 <endif>
 
 
@@ -66,6 +67,7 @@ charjSource_cc(basename, pd, imports, types, ros, debug) ::=
 <endif>
 
 
+#include "<basename>.def.h"
 >>
 
 readonlys_h(pds, ros) ::=
@@ -95,7 +97,7 @@ readonlys_cc_inner(pds, ros, basename) ::=
 readonlys_cc(pds, ros, basename) ::=
 <<
 <readonlys_cc_inner(pds = pds, ros = ros, basename = basename)>
-#include "<basename>_readonly.def.h"
+//#include "<basename>_readonly.def.h"
 
 >>
 
@@ -141,6 +143,41 @@ chare_epilogue_h(sym) ::=
 <type_epilogue_h(sym)>
 >>
 
+message_h(basename, ident, msds) ::=
+<<
+//#include "<basename>.decl.h"
+class <ident> : public CMessage_<ident>
+{
+    <msds>
+};
+>>
+
+message_ci(ident, msds) ::=
+<<
+message <ident>
+{
+    <msds>
+};
+>>
+
+multicastMessage_h(basename, ident, msds) ::=
+<<
+#include "ckmulticast.h"
+//#include "<basename>.decl.h"
+class <ident> : public CkMcastBaseMsg, public CMessage_<ident>
+{
+    <msds>
+};
+>>
+
+multicastMessage_ci(ident, msds) ::=
+<<
+message <ident>
+{
+    <msds>
+};
+>>
+
 classDeclaration_h(sym, ident, ext, csds, tident, needsPupInit) ::=
 <<
 <type_preamble_h(sym)>
@@ -258,9 +295,9 @@ CProxySection_<initSym.classType> <classSym.name>::<initSym.methodName>(CProxy_<
 
 chareDeclaration_cc(sym, ident, ext, csds, pupers, pupInits, needsMigration, inits) ::=
 <<
-#include "<ident>.decl.h"
+//#include "<ident>.decl.h"
 <chareDeclaration_cc_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds, pupers = pupers, pupInits = pupInits, needsMigration = needsMigration, inits = inits)>
-#include "<ident>.def.h"
+//#include "<ident>.def.h"
 >>
 
 chareDeclaration_cc_cont(pds, sym, ident, ext, csds, pupers, pupInits, needsMigration, inits) ::=
@@ -343,7 +380,7 @@ void <sym.name>::_initTrace() {
 chareDeclaration_h(sym, ident, ext, csds, needsPupInit, needsMigration) ::=
 <<
 <chare_preamble_h(sym)>
-#include "<ident>.decl.h"
+//#include "<ident>.decl.h"
 <chareDeclaration_h_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds, needsPupInit = needsPupInit, needsMigration = needsMigration)>
 <chare_epilogue_h(sym)>
 >>
@@ -385,17 +422,17 @@ class <ident>: public CBase_<ident> {
 
 chareDeclaration_ci(basename, sym, chareType, arrayDim, ident, ext, csds, entries) ::=
 <<
-<if(sym.isMainChare)>main<endif>module <ident> {
+//<if(sym.isMainChare)>main<endif>module <ident> {
 <if(ext)>
-    extern module <ext>;
+    //extern module <ext>;
 <endif>
-    <sym.Externs:{ext| extern module <ext>;
+    //<sym.Externs:{ext| extern module <ext>;
 <if(sym.isMainChare)>
-extern module <basename>_readonly;
+//extern module <basename>_readonly;
 <endif>
-    }>
+//    }>
     <chareDeclaration_ci_cont(pds = sym.packageNames, chareType = chareType, arrayDim = arrayDim, ident = ident, ext = ext, csds = csds, entries = entries)>
-}
+//}
 >>
 
 
@@ -620,7 +657,7 @@ mod_list_h(accmods, localmods, charjmods, othermods) ::=
 
 mod_list_ci(accmods, localmods, charjmods, othermods) ::=
 <<
-<if(charjmods)><charjmods; separator=" "> <endif>
+entry <if(charjmods)>[<charjmods; separator=", ">] <endif>
 >>
 
 local_var_decl(modList, type, declList, domainExps) ::=
@@ -811,6 +848,11 @@ exitall() ::=
 CkExit();
 >>
 
+contribute(data, type, target) ::=
+<<
+    contribute(<data>, CkCallback(CkReductionTarget(<type>)), <target>);
+>>
+
 range_constructor(range, others, len) ::=
 <<
 <if(range)>
index eebdd999fc115f372f6feb5562e284f8bebd69e7..5d59f6661270482b9d15c5b3f01d2f830b0cb970 100644 (file)
@@ -161,4 +161,11 @@ public class CharjAST extends CommonTree
             e.printStackTrace();
         }
     }
+
+    // Does this subtree contain an accelerator modifier?
+    public boolean hasAccelModifier()
+    {
+        return false;
+    }
+
 }
index 777a699c167150ee75b2afc840ea440859b1dd75..94a9b4876e758bafb42c97a306e50afe290f5a90 100644 (file)
@@ -174,6 +174,14 @@ typeDeclaration
             ext={$su.st},
             csds={$csds})
         -> 
+    |   ^(MESSAGE IDENT (msds+=messageScopeDeclaration)*)
+        -> {emitH()}? message_h(basename={basename()}, ident={$IDENT.text}, msds={$msds})
+        -> {emitCI()}? message_ci(ident={$IDENT.text}, msds={$msds})
+        ->
+    |   ^(MULTICAST_MESSAGE IDENT (msds+=messageScopeDeclaration)*)
+        -> {emitH()}? multicastMessage_h(basename={basename()}, ident={$IDENT.text}, msds={$msds})
+        -> {emitCI()}? multicastMessage_ci(ident={$IDENT.text}, msds={$msds})
+        ->
     |   ^(INTERFACE IDENT (^('extends' type+))? interfaceScopeDeclaration*)
         -> template(t={$text}) "/*INTERFACE-not implemented*/ <t>"
     |   ^(ENUM IDENT (^('implements' type+))? classScopeDeclaration*)
@@ -232,6 +240,22 @@ enumConstant
         -> template(t={$text}) "/*enumConstant-not implemented*/ <t>"
     ;
 
+messageScopeDeclaration
+    :   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList[null])
+        -> {!emitCC()}? class_var_decl(
+            modl={$modifierList.st},
+            type={$simpleType.st},
+            declList={$variableDeclaratorList.st})
+        ->
+    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList[$objectType.st])
+        -> {!emitCC()}? class_var_decl(
+            modl={$modifierList.st},
+            type={$objectType.st},
+            declList={$variableDeclaratorList.st})
+        ->
+    ;
+
+
 classScopeDeclaration
 @init
 {
@@ -513,6 +537,8 @@ returns [List names]
     :   ^(CHARJ_MODIFIER_LIST (m+=charjModifier)*)
         {
             $names = $m;
+            // Strip out null entries so we can detect empty modifier lists in the template
+            while ($names.remove(null)) {}
         }
     ;
 
@@ -548,9 +574,12 @@ accessModifier
     ;
 
 charjModifier
-    :   ENTRY -> {%{$ENTRY.text}}
-    |   SDAGENTRY -> template() "entry"
+    :   ENTRY
+    |   SDAGENTRY
     |   TRACED
+    |   ACCELERATED -> template() "accel"
+    |   THREADED -> template() "threaded"
+    |   REDUCTIONTARGET -> template() "reductiontarget"
     ;
 
 otherModifier
@@ -570,18 +599,6 @@ type
     |   VOID { $st = %{"void"}; }
     ;
 
-typeInEntryDecl
-    :   ^(SIMPLE_TYPE primitiveType domainExpression[null]?)
-        -> simple_type(typeID={$primitiveType.st}, arrDeclList={$domainExpression.st})
-    |   ^(OBJECT_TYPE qualifiedTypeIdent domainExpression[null]?)
-        -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
-    |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression[null]?)
-        -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
-    |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression[null]?)
-        -> obj_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
-    ;
-
-
 simpleType
     :   ^(SIMPLE_TYPE primitiveType domainExpression[null]?)
         -> simple_type(typeID={$primitiveType.st}, arrDeclList={$domainExpression.st})
@@ -604,6 +621,8 @@ nonProxyType
 proxyType
     :   ^(PROXY_TYPE qualifiedTypeIdent domainExpression[null]?)
         -> proxy_type(typeID={$qualifiedTypeIdent.st}, arrDeclList={$domainExpression.st})
+       |       ^(MESSAGE_TYPE qualifiedTypeIdent)
+               -> template(type={$qualifiedTypeIdent.st}) "<type>*"
        |       ^(ARRAY_SECTION_TYPE qualifiedTypeIdent domainExpression[null]?)
                -> template(type={$qualifiedTypeIdent.st}) "CProxySection_<type>"
     ;
@@ -674,8 +693,16 @@ entryFormalParameterList
 
 
 entryFormalParameter
-    :   ^(FORMAL_PARAM_STD_DECL t=typeInEntryDecl vdid=variableDeclaratorId)
-        -> entry_formal_param_decl(type={$t.st}, declID={$vdid.st})
+    :   ^(FORMAL_PARAM_STD_DECL ^(SIMPLE_TYPE primitiveType domainExpression[null]?) vdid=variableDeclaratorId)
+        -> template(type={$primitiveType.st}, declID={$vdid.st}) "<type> <declID>"
+    |   ^(FORMAL_PARAM_STD_DECL ^((OBJECT_TYPE|POINTER_TYPE|REFERENCE_TYPE) qualifiedTypeIdent domainExpression[null]?) vdid=variableDeclaratorId)
+        -> template(type={$qualifiedTypeIdent.st}, declID={$vdid.st}) "<type> __<declID>"
+    |   ^(FORMAL_PARAM_STD_DECL ^(PROXY_TYPE qualifiedTypeIdent domainExpression[null]?) vdid=variableDeclaratorId)
+        -> template(type={$qualifiedTypeIdent.st}, declID={$vdid.st}) "CProxy_<type> <declID>"
+    |   ^(FORMAL_PARAM_STD_DECL ^(MESSAGE_TYPE qualifiedTypeIdent) vdid=variableDeclaratorId)
+        -> template(type={$qualifiedTypeIdent.st}, declID={$vdid.st}) "<type>* <declID>"
+    |   ^(FORMAL_PARAM_STD_DECL ^(ARRAY_SECTION_TYPE qualifiedTypeIdent domainExpression[null]?) vdid=variableDeclaratorId)
+        -> template(type={$qualifiedTypeIdent.st}, declID={$vdid.st}) "CProxySection_<type> <declID>"
     ;
 
 
@@ -843,6 +870,8 @@ nonBlockStatement
         ->  exit(expr = {$expression.st})
     |   EXITALL
         ->  exitall()
+    |   ^(CONTRIBUTE e1=expression q=qualifiedIdentifier e2=expression)
+        -> contribute(data={$e1.st}, type={$q.st}, target={$e2.st})
     ;
         
 switchCaseLabel
index fe83eba08f46aff036bcff164ce5c1171bff9363..11d1575f4e6f76f87ffdd20d3b3831fee6d496cf 100644 (file)
@@ -92,6 +92,8 @@ typeDeclaration returns [ClassSymbol sym]
                 classScopeDeclaration*)
     |   ^('interface' IDENT (^(EXTENDS type+))?  interfaceScopeDeclaration*)
     |   ^('enum' IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
+    |   ^(MESSAGE IDENT messageScopeDeclaration*)
+    |   ^(MULTICAST_MESSAGE IDENT messageScopeDeclaration*)
     ;
 
 classType
@@ -110,7 +112,12 @@ chareType
 enumConstant
     :   ^(IDENT arguments?)
     ;
-    
+
+messageScopeDeclaration
+    :   ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
+    |   ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
+    ;
+
 classScopeDeclaration
     :   ^(FUNCTION_METHOD_DECL modifierList? genericTypeParameterList?
             type IDENT formalParameterList domainExpression? b=block)
@@ -212,7 +219,13 @@ accessModifierList
     ;
 
 charjModifierList
-    :   ^(CHARJ_MODIFIER_LIST charjModifier*)
+@init { boolean ctor = false; }
+    :   ^(CHARJ_MODIFIER_LIST charjModifier* {
+            // Non contructor entry methods are potential reduction targets
+            ctor = $CHARJ_MODIFIER_LIST.hasParentOfType(ENTRY_CONSTRUCTOR_DECL);
+        })
+        -> {ctor}? ^(CHARJ_MODIFIER_LIST charjModifier* )
+        -> ^(CHARJ_MODIFIER_LIST charjModifier* REDUCTIONTARGET)
     ;
 
 otherModifierList
@@ -235,6 +248,8 @@ charjModifier
     :   ENTRY
     |   SDAGENTRY
     |   TRACED
+    |   ACCELERATED
+    |   THREADED
     ;
 
 otherModifier
@@ -264,6 +279,7 @@ nonArraySectionObjectType returns [Type type]
        |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
+       |       ^(MESSAGE_TYPE qualifiedTypeIdent)
        |       VOID
        ;       
 
@@ -276,6 +292,7 @@ objectType returns [ClassSymbol type]
     |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
+       |       ^(MESSAGE_TYPE qualifiedTypeIdent)
        |       ^(ARRAY_SECTION_TYPE qualifiedTypeIdent domainExpression?)
     ;
 
@@ -284,6 +301,7 @@ entryArgObjectType returns [ClassSymbol type]
     |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
+    |   ^(MESSAGE_TYPE qualifiedTypeIdent)
     ;
 
 qualifiedTypeIdent returns [ClassSymbol type]
@@ -419,6 +437,7 @@ nonBlockStatement returns [boolean sdag]
     |   ^(PRINTLN expression*)
     |   ^(EXIT expression?)
     |   EXITALL
+    |   ^(CONTRIBUTE expression qualifiedIdentifier expression)
     ;
         
 switchCaseLabel
@@ -495,6 +514,7 @@ primaryExpression returns [Type type]
                 )
         )
                -> { $pe.type instanceof PointerType }? ^(ARROW primaryExpression IDENT? THIS? SUPER?)
+               -> { $pe.type instanceof MessageType }? ^(ARROW primaryExpression IDENT? THIS? SUPER?)
                ->                                                                              ^(DOT primaryExpression IDENT? THIS? SUPER?)
     |   parenthesizedExpression
     |   IDENT
index 06c853a9373836f0d97c7a5a7cf114c08c49aea8..ad7b2e57bf876c529288e8d89725d9855c9f0bdd 100644 (file)
@@ -82,6 +82,8 @@ typeDeclaration
         )
     |   ^(INTERFACE IDENT (^('extends' type+))?  interfaceScopeDeclaration*)
     |   ^(ENUM IDENT (^('implements' type+))? enumConstant+ classScopeDeclaration*)
+    |   ^(MESSAGE IDENT messageScopeDeclaration*)
+    |   ^(MULTICAST_MESSAGE IDENT messageScopeDeclaration*)
     ;
 
 chareArrayType
@@ -98,6 +100,22 @@ chareType
 enumConstant
     :   ^(IDENT arguments?)
     ;
+
+messageScopeDeclaration
+    :   ^(PRIMITIVE_VAR_DECLARATION m = modifierList? simpleType variableDeclaratorList)
+        -> {$modifierList.tree != null}? ^(PRIMITIVE_VAR_DECLARATION modifierList? simpleType variableDeclaratorList)
+        -> ^(PRIMITIVE_VAR_DECLARATION 
+            ^(MODIFIER_LIST ^(ACCESS_MODIFIER_LIST 'private') ^(LOCAL_MODIFIER_LIST) 
+                ^(CHARJ_MODIFIER_LIST) ^(OTHER_MODIFIER_LIST))
+            simpleType variableDeclaratorList)
+    |   ^(OBJECT_VAR_DECLARATION m = modifierList? objectType variableDeclaratorList)
+        -> {$modifierList.tree != null}? ^(OBJECT_VAR_DECLARATION modifierList? objectType variableDeclaratorList)
+        -> ^(OBJECT_VAR_DECLARATION  
+            ^(MODIFIER_LIST ^(ACCESS_MODIFIER_LIST 'private') ^(LOCAL_MODIFIER_LIST) 
+                ^(CHARJ_MODIFIER_LIST) ^(OTHER_MODIFIER_LIST))
+            objectType variableDeclaratorList)
+    ;
+
     
 classScopeDeclaration
     :   ^(d=FUNCTION_METHOD_DECL m=modifierList? g=genericTypeParameterList? 
@@ -218,6 +236,8 @@ charjModifier returns [boolean isEntry]
     :   ENTRY { $isEntry = true; }
     |   SDAGENTRY { $isEntry = true; }
     |   TRACED
+    |   ACCELERATED
+    |   THREADED
     ;
 
 otherModifier
@@ -255,6 +275,7 @@ objectType
     |   ^(PROXY_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(REFERENCE_TYPE qualifiedTypeIdent domainExpression?)
     |   ^(POINTER_TYPE qualifiedTypeIdent domainExpression?)
+       |       ^(MESSAGE_TYPE qualifiedTypeIdent)
        |       ^(ARRAY_SECTION_TYPE qualifiedTypeIdent domainExpression?)
     ;
 
@@ -373,6 +394,7 @@ nonBlockStatement
     |   ^(PRINTLN expression*)
     |   ^(EXIT expression?)
     |   EXITALL
+    |   ^(CONTRIBUTE expression qualifiedIdentifier expression)
     ;
         
 switchCaseLabel
index 837a6bbd8c81f25e90355e6d3d300948699b5623..845a7ba5b6a6d69ec341fb69f8c9e1c19aba6b72 100644 (file)
@@ -27,6 +27,7 @@ topdown
 
 bottomup
     :   exitMethod
+    |   exitClass
     ;
 
 classType
@@ -50,6 +51,17 @@ enterClass
         }
     ;
 
+exitClass
+    :   ^(TYPE classType IDENT
+        (^('extends' .*))?
+        (^('implements' .*))?
+        (^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | PRIMITIVE_VAR_DECLARATION | DIVCON_METHOD_DECL |
+            OBJECT_VAR_DECLARATION | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*))*)
+        {
+            currentClass = null;
+        }
+    ;
+
 enterDefaultConstructor
     :   FORMAL_PARAM_LIST
         {
@@ -62,7 +74,7 @@ enterDefaultConstructor
 
 enterMigrationConstructor
     :    ^(FORMAL_PARAM_LIST ^(FORMAL_PARAM_STD_DECL
-                ^(POINTER_TYPE ^(QUALIFIED_TYPE_IDENT IDENT)) .
+                ^(MESSAGE_TYPE ^(QUALIFIED_TYPE_IDENT IDENT)) .
             ))
         {
             if (($FORMAL_PARAM_LIST.hasParentOfType(CONSTRUCTOR_DECL) ||
diff --git a/src/langs/charj/src/charj/translator/MSA.g b/src/langs/charj/src/charj/translator/MSA.g
new file mode 100644 (file)
index 0000000..fc2f54d
--- /dev/null
@@ -0,0 +1,117 @@
+
+tree grammar MSA;
+
+options {
+    tokenVocab = Charj;
+    ASTLabelType = CharjAST;
+    filter = true;
+}
+
+@header {
+    package charj.translator;
+}
+
+@members {
+    Scope currentScope;
+    ClassSymbol currentClass = null;
+    MethodSymbol currentMethod = null;
+
+    public boolean accessorIsMSA(CharjAST ast)
+    {
+        return false;
+    }
+
+    public boolean expressionIsMSASync(CharjAST ast)
+    {
+        return false;
+    }
+}
+
+topdown
+    :   enterClass
+    |   enterMethod
+    |   possibleAccess
+    |   possibleSync
+    ;
+
+bottomup
+    :   exitMethod
+    |   exitClass
+    ;
+
+classType
+    :   CLASS
+    |   CHARE
+    |   GROUP
+    |   NODEGROUP
+    |   MAINCHARE
+    |   ^(CHARE_ARRAY ARRAY_DIMENSION)
+    ;
+
+enterClass
+    :   ^(TYPE classType IDENT
+        (^('extends' .*))?
+        (^('implements' .*))?
+        (^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | PRIMITIVE_VAR_DECLARATION | DIVCON_METHOD_DECL |
+            OBJECT_VAR_DECLARATION | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*))*)
+        {
+            currentClass = (ClassSymbol)$IDENT.def.type;
+        }
+    ;
+
+exitClass
+    :   ^(TYPE classType IDENT
+        (^('extends' .*))?
+        (^('implements' .*))?
+        (^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL | PRIMITIVE_VAR_DECLARATION | DIVCON_METHOD_DECL |
+            OBJECT_VAR_DECLARATION | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) .*))*)
+        {
+            currentClass = null;
+        }
+    ;
+
+enterMethod
+    :   ^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL
+            | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) modifierList? type IDENT .*)
+        {
+            currentMethod = (MethodSymbol)$IDENT.def.type;
+        }
+    ;
+
+exitMethod
+    :   ^((FUNCTION_METHOD_DECL | ENTRY_FUNCTION_DECL
+            | CONSTRUCTOR_DECL | ENTRY_CONSTRUCTOR_DECL) modifierList? type IDENT .*)
+        {
+            currentMethod = null;
+        }
+    ;
+
+possibleAccess
+    :  ^(aa=ARRAY_ELEMENT_ACCESS .*)
+        {
+            if (accessorIsMSA($aa)) {
+                currentMethod.hasMSA = true;
+                currentMethod.addMSAAccess($aa);
+            }
+        }
+    ;
+
+possibleSync
+    :   ^(mc=METHOD_CALL .*)
+        {
+            if (expressionIsMSASync($mc)) {
+                currentMethod.hasMSA = true;
+                currentMethod.addMSASync($mc);
+            }
+        }
+    ;
+
+modifierList
+    :   ^(MODIFIER_LIST .*)
+    ;
+
+type
+    :   VOID
+    |   ^((OBJECT_TYPE|PROXY_TYPE|REFERENCE_TYPE|POINTER_TYPE
+          |MESSAGE_TYPE|ARRAY_SECTION_TYPE) .*)
+    ;
diff --git a/src/langs/charj/src/charj/translator/MessageType.java b/src/langs/charj/src/charj/translator/MessageType.java
new file mode 100644 (file)
index 0000000..69b8bf5
--- /dev/null
@@ -0,0 +1,19 @@
+
+package charj.translator;
+
+public class MessageType extends Symbol implements Type {
+    public Type baseType;
+
+    public MessageType(SymbolTable symtab, Type _baseType) {
+        super(symtab, _baseType.getTypeName() + "*@", null);
+        baseType = _baseType;
+    }
+
+    public String getTypeName() {
+        return baseType.getTypeName() + "*@";
+    }
+
+    public String getTranslatedTypeName() {
+        return baseType.getTypeName() + "*";
+    }
+}
index 1967ff34a4fada521f3ce841175029e83ed0004a..75922198bfa538208d704572fc20a34356f766f2 100644 (file)
@@ -27,6 +27,8 @@ public class MethodSymbol
     public boolean isCtor = false;
     public boolean isTraced = false;
     public boolean hasSDAG = false;
+    public boolean hasMSA = false;
+    public boolean accel = false;
 
     public CharjAST sdagFPL;
 
@@ -175,4 +177,16 @@ public class MethodSymbol
         }
         return inits;
     }
+
+    public void addAccelIdent(CharjAST ast)
+    {
+    }
+
+    public void addMSASync(CharjAST ast)
+    {
+    }
+
+    public void addMSAAccess(CharjAST ast)
+    {
+    }
 }
index ae11c322d8b0aec026bee2a09e4574cbe3649def..f2d28ce79f25fa7672c8d70d6237fefcbeb50cfa 100644 (file)
@@ -321,6 +321,13 @@ type returns [Type namedType]
                 Type base = currentScope.resolveType(typeName);
                 $namedType = base == null ? null : new PointerType(symtab, base);
             }
+    |   ^(MESSAGE_TYPE ^(QUALIFIED_TYPE_IDENT (^(i1=IDENT {typeName.add(new TypeName($i1.text));} .*))+) .*)
+            {
+                $MESSAGE_TYPE.scope = currentScope;
+                Type base = currentScope.resolveType(typeName);
+                $namedType = base == null ? null : new MessageType(symtab, base);
+            }
+
     |   ^(ARRAY_SECTION_TYPE ^(QUALIFIED_TYPE_IDENT (^(i1=IDENT {typeName.add(new TypeName($i1.text));} .*))+) .*)
                        {
                 $ARRAY_SECTION_TYPE.scope = currentScope;
index 70f519ae601912fa6fb596b936f6c884e90c55be..857aa4988ce90c1055d664f0c12463a7ac05cbe3 100644 (file)
@@ -49,7 +49,9 @@ enterMethod
             {
                 if (currentMethod.isEntry) {
                     Type argType = (Type)$argid.def.type;
-                    currentMethod.addEntryArg(argType.getTypeName(), $argid.text);
+                    if (argType instanceof PointerType) {
+                        currentMethod.addEntryArg(argType.getTypeName(), $argid.text);
+                    }
                 }
             }
             ))*)
@@ -255,6 +257,7 @@ primaryExpression returns [Type type]
             if (et instanceof ProxyType) et = ((ProxyType)et).baseType;
             if (et instanceof PointerType) et = ((PointerType)et).baseType;
                        if (et instanceof ProxySectionType) et = ((ProxySectionType)et).baseType;
+                       if (et instanceof MessageType) et = ((MessageType)et).baseType;
             ClassSymbol cxt = (ClassSymbol)et;
             Symbol s;
             if (cxt == null) {
@@ -409,6 +412,8 @@ type returns [Type sym]
             ^(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));} .*))+) .*)
+       |       ^(MESSAGE_TYPE { scope = $MESSAGE_TYPE.scope; pointer = 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; }
index 36bc4ce4cafe0a1dc614698be40545a70631aedd..80fb41f6a58b432c5f18c15f32c9428e4a064431 100644 (file)
@@ -1,10 +1,12 @@
 
 readonly Main@ main;
 
+extern atoi;
+
 public mainchare Main {
     int n;
 
-    public entry Main(CkArgMsg m) {
+    public entry Main(CkArgMsg[~]@ m) {
         if (m.argc < 2) n = 16;
         else n = atoi(m.argv[1]);
         main = thisProxy;
index 67708ad2559f5b1f96a3241a17c132ea672c28e5..15ea2df83e47e14231e6832ef859ec2b462a9f92 100644 (file)
@@ -2,7 +2,7 @@
 package tests.unit;
 
 mainchare Main {
-    public entry Main(CkArgMsg args) {
+    public entry Main(CkArgMsg[~]@ args) {
     }
 
     public entry void run_tests() {
index 1c2d90eb8c86af9f19fe30fe1f3358817d9439ad..2fe88de8cc927606ff6393628b3a0e717c5ecef5 100644 (file)
@@ -4,7 +4,7 @@
 #define VDW_B            (1.031093844 * pow(10.0, -77))
 
 #define ENERGY_VAR        (1.0 * pow(10.0,-5))
-#powdefine PARTICLES_PER_CELL   300
+#define PARTICLES_PER_CELL   300
 
 #define DEFAULT_DELTA         1// interact femtoseconds
 
 #define KAWAY_X               1
 #define KAWAY_Y               1
 #define KAWAY_Z               1
-#define NBRS_X              (2*KAWAY_X+1)
-#define NBRS_Y            (2*KAWAY_YWAY_Y+1)
-#define NBRS_Z            (2*KAWAY_Z+1)
+#define NBRS_X                (2*KAWAY_X+1)
+#define NBRS_Y                  (2*KAWAY_Y+1)
+#define NBRS_Z                  (2*KAWAY_Z+1)
 #define NUM_NEIGHBORS        (NBRS_X * NBRS_Y * NBRS_Z)
 
-#define CELLARRAY_DIM_X      3
-#definedefine CELLARRAY_DIM_Y      3
-#define CELLARRAY_DIM_Z      3
-#define         PTP_CUT_OFF        12 // cut off for atom to atom interactions
-#definedefinee CELL_MARGIN        4  // constant diff between cutoff and cell size#define CELL_SIZE_X        (PTP_CUT_OFF + CELL_MARGIN)/KAWAY_X
-#definedefineene CELL_SIZE_Y        (PTP_CUT_OFF + CELL_MARGIN)/KAWAY_Y
-#define CELL_SIZE_YL_SIZE_Z        (PTP_CUT_OFF + CELL_MARGIN)/KAWAY_Z
-#define CELL_ORIGIN_YIN_X      0
-#define CELL_ORIGIN_Y      0
-#define CELL_ORIGIN_Z                              0
+#define CELLARRAY_DIM_X       3
+#define CELLARRAY_DIM_Y       3
+#define CELLARRAY_DIM_Z       3
+#define PTP_CUT_OFF             12
+#define CELL_MARGIN             4  
+#define CELL_SIZE_Y             ((PTP_CUT_OFF + CELL_MARGIN)/KAWAY_Y)
+#define CELL_SIZE_Z             ((PTP_CUT_OFF + CELL_MARGIN)/KAWAY_Z)
+#define CELL_ORIGIN_X             0
+#define CELL_ORIGIN_Y             0
+#define CELL_ORIGIN_Z             0
 
 #define MIGRATE_STEPCOUNT    20
-#define DEFAULT_FINALSTEPCOUNT1001
+#define DEFAULT_FINALSTEPCOUNT 1001
 #define MAX_VELOCITY      30.0
 
-#define WRAP_X(a)(((a)+cellArrayyDimX)%cellArrayDimX)
+#define WRAP_X(a)(((a)+cellArrayDimX)%cellArrayDimX)
 #define WRAP_Y(a)(((a)+cellArrayDimY)%cellArrayDimXDimY)
 #define WRAP_Z(a)(((a)+cellArrayDimZ)%cellArrayDimZ)
 #define BLOCK_SIZE 512
 
+extern srand48;
 extern drand48;
 extern pow;
 extern fabs;
 extern abs;
+extern atoi;
+extern CkSectionInfo;
+extern ParticleDataMsg;
 
 readonly Main@ mainProxy;       //central controller
-readonly Cell@ cellArray;       //array that houses atoms
-readonly Compute@ computeArray; //computational kernels
-readonly CkGroupID mCastGrpID;  //multicast group handle
+//readonly Cell@ cellArray;       //array that houses atoms
+//readonly Compute@ computeArray; //computational kernels
+//readonly CkGroupID mCastGrpID;  //multicast group handle
 
 readonly int cellArrayDimX;         // X dimension of the Cell array
 readonly int cellArrayDimY;         // Y dimension of the Cell array
-readonly int cellArrayDimYArrayDimZ;// Z dimension of the Cell array
+readonly int cellArrayDimZ;         // Z dimension of the Cell array
 readonly int finalStepCount;        // number of steps in the simulaion
 readonly int firstLdbStep;          // begin load balancing after this many steps
 readonly int ldbPeriod;             // load balancing period
 
-
 class vec3 {
     double x, y, z;
     void copy(vec3 v2) {
@@ -77,17 +80,19 @@ class vec3 {
     }
 }
 
+multicast_message ParticleDataMsg {
+    Array<vec3> part;
+}
+
 class Particle {
     double mass;
-    vec3 pos, acc, vel;
+    vec3 pos;
+    vec3 acc;
+    vec3 vel;
 }
 
-multicast_message ParticleDataMsg {
-    Array<vec3> part;
-}
-        
-mainchare Main {
-    entry Main(CkArgMsg m) {
+public mainchare Main {
+    public entry Main(CkArgMsg[~]@ m) {
         CkPrintf("\nLENNARD JONES MOLECULAR DYNAMICS START UP ...\n");
 
         //set variable values to a default set
@@ -97,13 +102,14 @@ mainchare Main {
         finalStepCount = DEFAULT_FINALSTEPCOUNT;
         firstLdbStep = DEFAULT_FIRST_LDB;
         ldbPeriod = DEFAULT_LDB_PERIOD;
+/*
 
         mainProxy = thisProxy;
 
         //branch factor for spanning tree of multicast
         int bFactor = 4;
         //creating the multicast spanning tree
-        mCastGrpID = CProxy_CkMulticastMgr.ckNew(bFactor);
+        mCastGrpID = CkMulticastMgr@.ckNew(bFactor);
 
         int numPes = CkNumPes();
         int currPe = -1;
@@ -114,7 +120,8 @@ mainchare Main {
         //read user parameters
         //number of celles/cells in each dimension
         if (m.argc > cur_arg) {
-            cellArrayDimX=atoi(m.argv[cur_arg++]);
+            cellArrayDimX = atoi(m.argv[cur_arg++]);
+        }
             cellArrayDimY=atoi(m.argv[cur_arg++]);
             cellArrayDimZ=atoi(m.argv[cur_arg++]);
             CkPrintf("Cell Array Dimension X:%d Y:%d Z:%d of size %d %d %d\n",cellArrayDimX,cellArrayDimY,cellArrayDimZ,CELL_SIZE_X,CELL_SIZE_Y,CELL_SIZE_Z);
@@ -159,9 +166,11 @@ mainchare Main {
 
         thisProxy@run();
         delete m;
+        */
     }
 
     entry void run() {
+        /*
         when computesCreated() {
             computeArray@doneInserting();
             CkPrintf("Computes: %d .... created\n", (NUM_NEIGHBORS/2+1)*cellArrayDimX*cellArrayDimY*cellArrayDimZ);
@@ -182,6 +191,7 @@ mainchare Main {
             }
             CkExit();
         }
+        */
     }
 }
 
@@ -193,13 +203,12 @@ chare_array [3d] Cell {
     int stepTime;
     int updateCount;
     Array<double> energy;
-    Compute[%]@ mCastSecProxy;
+//    Compute[%]@ mCastSecProxy;
 
     entry Cell() {
+    /*
         int i;
         inbrs = NUM_NEIGHBORS;
-        //load balancing to be called when AtSync is called
-        usesAtSync = CmiTrue;
 
         myNumParts = PARTICLES_PER_CELL;
         // starting random generator
@@ -211,6 +220,9 @@ chare_array [3d] Cell {
             particles[i] = new Particle();
             particles[i].mass = HYDROGEN_MASS;
 
+            //FIXME: for some reason these array accesses are not type-checked to
+            // be PointerType. Figure out why and fix.
+
             //give random values for position and velocity
             particles[i].pos.x = drand48() * CELL_SIZE_X + thisIndex.x * CELL_SIZE_X;
             particles[i].pos.y = drand48() * CELL_SIZE_Y + thisIndex.y * CELL_SIZE_Y;
@@ -225,8 +237,10 @@ chare_array [3d] Cell {
         stepTime = 0; 
         energy = new Array<double>([2]);
         energy[0] = energy[1] = 0;
+    */
     }
 
+/*
     entry void createComputes() {
         int num;  
 
@@ -274,7 +288,7 @@ chare_array [3d] Cell {
                 computesList[num][3] = px1; computesList[num][4] = py1; computesList[num][5] = pz1;
             }
         } // end of for loop
-        contribute(0,CkReduction.nop,CkCallback(Main.computesCreated),mainProxy);
+        contribute(0,CkReduction.nop,CkCallback(Main.computesCreated,mainProxy));
     }
 
     entry void createSection() {
@@ -453,21 +467,27 @@ chare_array [3d] Cell {
                 CkReduction.sum_double,
                 CkCallback(Main.energySumK, mainProxy));
     } 
+*/
 }
 
 chare_array [6d] Compute {
     Array<double> energy;
     int stepCount, cellCount;
-    CkSectionInfo mcast1, mcast2;
+    // FIXME: CkSectionInfo mcast1, mcast2;
+    //CkSectionInfo mcast1;
+    //CkSectionInfo mcast2;
     ParticleDataMsg bufferedMsg;
 
     entry Compute() {
         cellCount = 0;
         stepCount = 0;
         energy = new Array<double>([2]);
-        energy[0] = energy[1] = 0;
+        // FIXME: energy[0] = energy[1] = 0;
+        energy[0] = 0;
+        energy[1] = 0;
     }
 
+/*
     void interact(ParticleDataMsg msg) {
         double energyP = 0;
 
@@ -666,5 +686,5 @@ chare_array [6d] Compute {
         delete separation;
         return energy;
     }
+*/
 }
-
diff --git a/src/langs/charj/tests/unit/MulticastMessage.cj b/src/langs/charj/tests/unit/MulticastMessage.cj
new file mode 100644 (file)
index 0000000..79fbe46
--- /dev/null
@@ -0,0 +1,5 @@
+
+multicast_message m {
+    Array<int> x;
+    int y;
+}
index f1e1d36fe3ecf98cd21b608f016dea1351f02777..3de8ddfc59b6850ac9c650b4102941bcd33e340d 100644 (file)
@@ -1,30 +1,25 @@
 
 readonly ReductionMain@ mainProxy;
-readonly int units;
-readonly double d;
 
 public mainchare ReductionMain {
-      public entry ReductionMain(CkArgMsg msg) {
-          mainProxy = thisProxy;
-          if (msg.argc < 2) CkExit();
-          units = atoi(msg.argv[1]);
-          d = atof(msg.argv[2]);
-      }
-
-      public entry void reportIn(CkReductionMsg msg) {
-      }
+    public entry ReductionMain(CkArgMsg[~]@ msg) {
+        mainProxy = thisProxy;
+        int size = 10;
+        if (msg.argc < 2) size = atoi(msg.argv[1]);
+        Reducer@ arr = new Reducer@(size);
+        arr@doWork();
+    }
 
-      public entry void done() {
-          CkPrintf("Add done\n");
-          CkExit();
-      }
+    public entry void done(int result) {
+        CkPrintf("All done, result is %d\n", result);
+        CkExit();
+    }
 }
 
 public chare_array [1D] Reducer {
-    private float myfloat;
-
-    void dowork() {
-        double out = d + (double)thisIndex;
-        contribute(2*sizeof(double), out, CkReduction::sum_double);
+    entry void dowork() {
+        contribute(thisIndex,
+            CkReduction.sum_int,
+            CkCallback(Main.done, mainProxy));
     }
 }