Skip to content

Commit

Permalink
+ Merging The parallel extensions.
Browse files Browse the repository at this point in the history
  + parallel variables are handled in the Front-end now.
  - some checks and restrictions remain, but nothing that
    affects the normal OM compilation.
  * so far so good. 
  

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11154 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed Feb 15, 2012
1 parent 5af302a commit 954bf43
Show file tree
Hide file tree
Showing 21 changed files with 457 additions and 211 deletions.
12 changes: 7 additions & 5 deletions Compiler/BackEnd/PartFn.mo
Expand Up @@ -539,6 +539,7 @@ algorithm
DAE.ComponentRef cref;
DAE.VarKind kind;
DAE.VarDirection direction;
DAE.VarParallelism parallelism;
DAE.VarVisibility protection;
DAE.Type ty;
Option<DAE.Exp> binding;
Expand All @@ -557,12 +558,12 @@ algorithm
DAE.ElementSource source "the origin of the element";
list<DAE.Function> dae;

case(DAE.VAR(cref,kind,direction,protection,ty,binding,dims,flowPrefix,streamPrefix,source,
case(DAE.VAR(cref,kind,direction,parallelism,protection,ty,binding,dims,flowPrefix,streamPrefix,source,
variableAttributesOption,absynCommentOption,innerOuter),dae)
equation
(binding,dae) = elabExpOption(binding,dae);
then
(DAE.VAR(cref,kind,direction,protection,ty,binding,dims,flowPrefix,streamPrefix,source,
(DAE.VAR(cref,kind,direction,parallelism,protection,ty,binding,dims,flowPrefix,streamPrefix,source,
variableAttributesOption,absynCommentOption,innerOuter),dae);

case(DAE.DEFINE(cref,e,source),dae)
Expand Down Expand Up @@ -1233,7 +1234,7 @@ algorithm
equation
i = ComponentReference.printComponentRefStr(cref);
// TODO: FIXME: binding?
res = DAE.TYPES_VAR(i,DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.INPUT(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),ty,DAE.UNBOUND(),NONE());
res = DAE.TYPES_VAR(i,DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.NON_PARALLEL(), SCode.VAR(),Absyn.INPUT(),Absyn.NOT_INNER_OUTER()),SCode.PUBLIC(),ty,DAE.UNBOUND(),NONE());
then
res;
case(_)
Expand Down Expand Up @@ -1377,6 +1378,7 @@ algorithm
DAE.ComponentRef componentRef " The variable name";
DAE.VarKind kind "varible kind: variable, constant, parameter, discrete etc." ;
DAE.VarDirection direction "input, output or bidir" ;
DAE.VarParallelism parallelism "parglobal,parlocal,non_parallel";
DAE.VarVisibility protection "if protected or public";
DAE.Type ty "Full type information required";
DAE.Exp binding "Binding expression e.g. for parameters ; value of start attribute" ;
Expand All @@ -1389,13 +1391,13 @@ algorithm
DAE.ElementSource source "the origin of the element";

case({},_,_,_,_) then {};
case(DAE.VAR(componentRef,kind,direction,protection,ty,SOME(binding),dims,flowPrefix,streamPrefix,source,
case(DAE.VAR(componentRef,kind,direction,parallelism,protection,ty,SOME(binding),dims,flowPrefix,streamPrefix,source,
variableAttributesOption,absynCommentOption,innerOuter) :: cdr,dae,p,inputs,current)
equation
((binding,_)) = Expression.traverseExp(binding,fixCall,(p,inputs,dae,current));
cdr_1 = fixCalls(cdr,dae,p,inputs,current);
then
DAE.VAR(componentRef,kind,direction,protection,ty,SOME(binding),dims,flowPrefix,streamPrefix,source,
DAE.VAR(componentRef,kind,direction,parallelism,protection,ty,SOME(binding),dims,flowPrefix,streamPrefix,source,
variableAttributesOption,absynCommentOption,innerOuter) :: cdr_1;

case(DAE.DEFINE(cref,e,source) :: cdr,dae,p,inputs,current)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Builtin.mo
Expand Up @@ -252,7 +252,7 @@ protected constant SCode.Element booleanType = SCode.CLASS("Boolean",commonPrefi

/* The builtin variable time. See also variableIsBuiltin */
protected constant DAE.Var timeVar = DAE.TYPES_VAR("time",
DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.VAR(),Absyn.INPUT(),Absyn.NOT_INNER_OUTER()),
DAE.ATTR(SCode.NOT_FLOW(),SCode.NOT_STREAM(),SCode.NON_PARALLEL(),SCode.VAR(),Absyn.INPUT(),Absyn.NOT_INNER_OUTER()),
SCode.PUBLIC(),DAE.T_REAL_DEFAULT,DAE.UNBOUND(),NONE()) "- The `time\' variable" ;

protected constant DAE.Type stringIntInt2string =
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/CevalFunction.mo
Expand Up @@ -1625,7 +1625,7 @@ protected function makeFunctionVariable
algorithm
outVar := DAE.TYPES_VAR(
inName,
DAE.ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER()),
DAE.ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER()),
SCode.PUBLIC(), inType, inBinding, NONE());
end makeFunctionVariable;

Expand Down
14 changes: 11 additions & 3 deletions Compiler/FrontEnd/DAE.mo
Expand Up @@ -85,6 +85,12 @@ public uniontype VarDirection
record BIDIR "neither input or output" end BIDIR;
end VarDirection;

public uniontype VarParallelism
record PARGLOBAL "Global variables for CUDA and OpenCL" end PARGLOBAL;
record PARLOCAL "Shared for CUDA and local for OpenCL" end PARLOCAL;
record NON_PARALLEL "Non parallel/Normal variables" end NON_PARALLEL;
end VarParallelism;

public uniontype VarVisibility
record PUBLIC "public variables" end PUBLIC;
record PROTECTED "protected variables" end PROTECTED;
Expand Down Expand Up @@ -155,6 +161,7 @@ public uniontype Element
ComponentRef componentRef " The variable name";
VarKind kind "varible kind: variable, constant, parameter, discrete etc." ;
VarDirection direction "input, output or bidir" ;
VarParallelism parallelism "parglobal, parlocal, or non_parallel";
VarVisibility protection "if protected or public";
Type ty "Full type information required";
Option<Exp> binding "Binding expression e.g. for parameters ; value of start attribute";
Expand Down Expand Up @@ -653,16 +660,17 @@ uniontype Attributes "- Attributes"
record ATTR
SCode.Flow flowPrefix "flow" ;
SCode.Stream streamPrefix "stream" ;
SCode.Parallelism parallelism "parallelism";
SCode.Variability variability "variability" ;
Absyn.Direction direction "direction" ;
Absyn.InnerOuter innerOuter "inner, outer, inner outer or unspecified";
end ATTR;
end Attributes;

public
constant Attributes dummyAttrVar = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());
constant Attributes dummyAttrParam = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.PARAM(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());
constant Attributes dummyAttrConst = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.CONST(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());
constant Attributes dummyAttrVar = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());
constant Attributes dummyAttrParam = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.NON_PARALLEL(), SCode.PARAM(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());
constant Attributes dummyAttrConst = ATTR(SCode.NOT_FLOW(), SCode.NOT_STREAM(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR(), Absyn.NOT_INNER_OUTER());

public uniontype BindingSource "where this binding came from: either default binding or start value"
record BINDING_FROM_DEFAULT_VALUE "the binding came from the default value" end BINDING_FROM_DEFAULT_VALUE;
Expand Down
51 changes: 48 additions & 3 deletions Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -638,6 +638,29 @@ algorithm
end matchcontinue;
end dumpDirection;

protected function dumpParallelism "function: dumpParallelism
Dump VarParallelism."
input DAE.VarParallelism inVarParallelism;
algorithm
_ := matchcontinue (inVarParallelism)
case DAE.NON_PARALLEL()
equation
Print.printBuf(" ");
then
();
case DAE.PARGLOBAL()
equation
Print.printBuf(" parglobal ");
then
();
case DAE.PARLOCAL()
equation
Print.printBuf(" parlocal ");
then
();
end matchcontinue;
end dumpParallelism;

public function dumpDirectionStr "function: dumpDirectionStr
Dump VarDirection to a string"
input DAE.VarDirection inVarDirection;
Expand Down Expand Up @@ -794,6 +817,7 @@ algorithm
DAE.ComponentRef id;
DAE.VarKind kind;
DAE.VarDirection dir;
DAE.VarParallelism prl;
DAE.Type typ;
DAE.Flow flowPrefix;
DAE.Stream streamPrefix;
Expand All @@ -807,6 +831,7 @@ algorithm
case DAE.VAR(componentRef = id,
kind = kind,
direction = dir,
parallelism = prl,
ty = typ,
binding = NONE(),
flowPrefix = flowPrefix,
Expand All @@ -817,6 +842,7 @@ algorithm
equation
dumpKind(kind);
dumpDirection(dir);
dumpParallelism(prl);
Print.printBuf(Types.unparseType(typ));
Print.printBuf(" ");
ComponentReference.printComponentRef(id);
Expand All @@ -829,6 +855,7 @@ algorithm
case DAE.VAR(componentRef = id,
kind = kind,
direction = dir,
parallelism = prl,
ty = typ,
binding = SOME(e),
flowPrefix = flowPrefix,
Expand All @@ -839,6 +866,7 @@ algorithm
equation
dumpKind(kind);
dumpDirection(dir);
dumpParallelism(prl);
Print.printBuf(Types.unparseType(typ));
Print.printBuf(" ");
ComponentReference.printComponentRef(id);
Expand All @@ -862,6 +890,18 @@ algorithm
end match;
end dumpVarVisibilityStr;

public function dumpVarParallelismStr "function: dumVarParallelismStr
Dump VarParallelism to a string"
input DAE.VarParallelism inVarParallelism;
output String outString;
algorithm
outString := match (inVarParallelism)
case DAE.NON_PARALLEL() then "";
case DAE.PARGLOBAL() then "parglobal ";
case DAE.PARLOCAL() then "parlocal ";
end match;
end dumpVarParallelismStr;

public function dumpCommentOptionStr "function: dumpCommentOptionStr
Dump Comment option to a string."
input Option<SCode.Comment> inAbsynCommentOption;
Expand Down Expand Up @@ -3146,10 +3186,11 @@ protected function dumpVarStream "function: dumpVarStream
algorithm
outStream := matchcontinue (inElement, printTypeDimension, inStream)
local
String s1,s2,s3,s4,comment_str,s5,s6,s7,s3_subs,sFinal;
String s1,s2,s3,s4,comment_str,s5,s6,s7,s3_subs,sFinal,sPrl;
DAE.ComponentRef id;
DAE.VarKind kind;
DAE.VarDirection dir;
DAE.VarParallelism prl;
DAE.Type typ;
DAE.Flow flowPrefix;
DAE.Stream streamPrefix;
Expand All @@ -3164,6 +3205,7 @@ algorithm
case (DAE.VAR(componentRef = id,
kind = kind,
direction = dir,
parallelism = prl,
protection=prot,
ty = typ,
dims = dims,
Expand All @@ -3181,15 +3223,17 @@ algorithm
s3_subs = unparseDimensions(dims, printTypeDimension);
s4 = ComponentReference.printComponentRefStr(id);
s7 = dumpVarVisibilityStr(prot);
sPrl = dumpVarParallelismStr(prl);
comment_str = dumpCommentOptionStr(comment);
s5 = dumpVariableAttributesStr(dae_var_attr);
str = IOStream.appendList(str, {" ",s7,sFinal,s1,s2,s3,s3_subs," ",s4,s5,comment_str,";\n"});
str = IOStream.appendList(str, {" ",s7,sFinal,sPrl,s1,s2,s3,s3_subs," ",s4,s5,comment_str,";\n"});
then
str;
// we have a binding
case (DAE.VAR(componentRef = id,
kind = kind,
direction = dir,
parallelism = prl,
protection=prot,
ty = typ,
dims = dims,
Expand All @@ -3209,8 +3253,9 @@ algorithm
s5 = ExpressionDump.printExpStr(e);
comment_str = dumpCommentOptionStr(comment);
s6 = dumpVariableAttributesStr(dae_var_attr);
sPrl = dumpVarParallelismStr(prl);
s7 = dumpVarVisibilityStr(prot);
str = IOStream.appendList(str, {" ",s7,sFinal,s1,s2,s3,s3_subs," ",s4,s6," = ",s5,comment_str,";\n"});
str = IOStream.appendList(str, {" ",s7,sFinal,sPrl,s1,s2,s3,s3_subs," ",s4,s6," = ",s5,comment_str,";\n"});
then
str;
case (_,_,str) then str;
Expand Down

0 comments on commit 954bf43

Please sign in to comment.