Skip to content

Commit

Permalink
Added parallelism attribute to all variables.
Browse files Browse the repository at this point in the history
Absyn.ATTR (flowPrefix, streamPrefix, variability, direction, arrayDim)
                                 |
                                 V
Absyn.ATTR (flowPrefix, streamPrefix, parallelism, variability, direction, arrayDim)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10903 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed Jan 16, 2012
1 parent c4f26c7 commit 4804f62
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 269 deletions.
39 changes: 35 additions & 4 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -647,13 +647,21 @@ uniontype ElementAttributes "- Component attributes"
Boolean streamPrefix "stream" ;
// Boolean inner_ "inner";
// Boolean outer_ "outer";
Parallelism parallelism "for OpenCL/CUDA parglobal, parlocal ...";
Variability variability "variability ; parameter, constant etc." ;
Direction direction "direction" ;
ArrayDim arrayDim "arrayDim" ;
end ATTR;

end ElementAttributes;

public
uniontype Parallelism "Parallelism"
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 Parallelism;

public
uniontype Variability "Variability"
record VAR end VAR;
Expand Down Expand Up @@ -4337,21 +4345,45 @@ merge the derived ElementAttributes with the optional ElementAttributes returned
algorithm outoEle := match(ele, oEle)
local
Boolean b1,b2,bStream1,bStream2,bStream;
Parallelism p1,p2;
Variability v1,v2;
Direction d1,d2;
ArrayDim ad1,ad2;
case(ele,NONE()) then SOME(ele);
case(ATTR(b1,bStream1,v1,d1,ad1), SOME(ATTR(b2,bStream2,v2,d2,ad2)))
case(ATTR(b1,bStream1,p1,v1,d1,ad1), SOME(ATTR(b2,bStream2,p2,v2,d2,ad2)))
equation
b1 = boolOr(b1,b2);
bStream = boolOr(bStream1,bStream2);
p1 = propagateAbsynParallelism(p1,p2);
v1 = propagateAbsynVariability(v1,v2);
d1 = propagateAbsynDirection(d1,d2);
then
SOME(ATTR(b1,bStream,v1,d1,ad1));
SOME(ATTR(b1,bStream,p1,v1,d1,ad1));
end match;
end mergeElementAttributes;

//mahge930: Not sure what to do here for now.
protected function propagateAbsynParallelism "
Helper function for mergeElementAttributes
"
input Parallelism p1;
input Parallelism p2;
output Parallelism p3;
algorithm v3 := matchcontinue(p1,p2)
case(p1,NON_PARALLEL()) then p1;
case(NON_PARALLEL(),p2) then p2;
case(p1,p2)
equation
equality(p1 = p2);
then p1;
case(_,_)
equation
print(" failure in propagateAbsynParallelism, parglobal-parlocal mismatch");
then
fail();
end matchcontinue;
end propagateAbsynParallelism;

protected function propagateAbsynVariability "
Helper function for mergeElementAttributes
"
Expand Down Expand Up @@ -4379,7 +4411,7 @@ algorithm v3 := matchcontinue(v1,v2)
then v1;
case(_,_)
equation
print(" failure in propagateAbsynDirection, inner outer mismatch");
print(" failure in propagateAbsynDirection, input-output mismatch");
then
fail();
end matchcontinue;
Expand Down Expand Up @@ -5485,5 +5517,4 @@ algorithm
case ELEMENTITEM(element=_) then ();
end match;
end filterAnnotationItem;

end Absyn;
24 changes: 23 additions & 1 deletion Compiler/FrontEnd/Dump.mo
Expand Up @@ -6502,15 +6502,18 @@ algorithm
local
Boolean flowPrefix;
Boolean streamPrefix;
Absyn.Parallelism parallelism;
Absyn.Variability variability;
Absyn.Direction direction;
Absyn.ArrayDim arrayDim;
case Absyn.ATTR(flowPrefix,streamPrefix,variability,direction,arrayDim)
case Absyn.ATTR(flowPrefix,streamPrefix,parallelism,variability,direction,arrayDim)
equation
Print.printBuf("record Absyn.ATTR flowPrefix = ");
Print.printBuf(Util.if_(flowPrefix, "true", "false"));
Print.printBuf(", streamPrefix = ");
Print.printBuf(Util.if_(streamPrefix, "true", "false"));
Print.printBuf(", parallelism = ");
printParallelismAsCorbaString(parallelism);
Print.printBuf(", variability = ");
printVariabilityAsCorbaString(variability);
Print.printBuf(", direction = ");
Expand All @@ -6522,6 +6525,25 @@ algorithm
end match;
end printElementAttributesAsCorbaString;

protected function printParallelismAsCorbaString
input Absyn.Parallelism parallelism;
algorithm
_ := match parallelism
case Absyn.PARGLOBAL()
equation
Print.printBuf("record Absyn.PARGLOBAL end Absyn.PARGLOBAL;");
then ();
case Absyn.PARLOCAL()
equation
Print.printBuf("record Absyn.PARLOCAL end Absyn.PARLOCAL;");
then ();
case Absyn.NON_PARALLEL()
equation
Print.printBuf("record Absyn.NON_PARALLEL end Absyn.NON_PARALLEL;");
then ();
end match;
end printParallelismAsCorbaString;

protected function printVariabilityAsCorbaString
input Absyn.Variability var;
algorithm
Expand Down
6 changes: 4 additions & 2 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -384,13 +384,14 @@ algorithm
local
Boolean f, s;
Absyn.Variability v;
Absyn.Parallelism p;
Absyn.ArrayDim adim,extraADim;
Absyn.Direction dir;
SCode.Flow sf;
SCode.Stream ss;
SCode.Variability sv;

case (Absyn.ATTR(f, s, v, dir, adim),extraADim)
case (Absyn.ATTR(f, s, p, v, dir, adim),extraADim)
equation
sf = SCode.boolFlow(f);
ss = SCode.boolStream(s);
Expand Down Expand Up @@ -1254,6 +1255,7 @@ algorithm
Absyn.Annotation absann;
SCode.Annotation ann;
Absyn.Variability variability;
Absyn.Parallelism parallelism;
Absyn.Info i,info;
String str;
SCode.Element cls;
Expand Down Expand Up @@ -1323,7 +1325,7 @@ algorithm
case (cc,_,_,_,_,Absyn.COMPONENTS(components = {}),info) then {};

case (cc,finalPrefix,io,repl,vis,Absyn.COMPONENTS(attributes =
(attr as Absyn.ATTR(flowPrefix = fl,streamPrefix=st,variability = variability,direction = di,arrayDim = ad)),typeSpec = t,
(attr as Absyn.ATTR(flowPrefix = fl,streamPrefix=st,parallelism=parallelism,variability = variability,direction = di,arrayDim = ad)),typeSpec = t,
components = (Absyn.COMPONENTITEM(component = Absyn.COMPONENT(name = n,arrayDim = d,modification = m),comment = comment,condition=cond) :: xs)),info)
equation
true = SCodeCheck.checkIdentNotEqTypeName(n, t, info);
Expand Down
198 changes: 0 additions & 198 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -13020,204 +13020,6 @@ algorithm
end userDefOperatorDeoverloadBinary;


/*
protected function userDefOperatorDeoverloadBinary2
input Env.Cache inCache;
input Env.Env inEnv;
input Absyn.Exp inExp;
input Boolean inImplicit;
input Option<Interactive.SymbolTable> inInteractiveInteractiveSymbolTableOption;
input Boolean performVectorization;
input Prefix.Prefix inPrefix;
input Absyn.Info info;
output Env.Cache outCache;
output Option<tuple<DAE.Exp,DAE.Properties>> expProps;
output Option<Interactive.SymbolTable> outInteractiveInteractiveSymbolTableOption;

algorithm

(outCache,expProps,outInteractiveInteractiveSymbolTableOption) :=
matchcontinue (inCache,inEnv,inExp,inImplicit,inInteractiveInteractiveSymbolTableOption,performVectorization,inPrefix,info)
local
Boolean impl,doVect;
String str1;
Absyn.Path path,path2;
list<Absyn.Path> operNames;
Env.Env operatorEnv,env;
SCode.Element operatorCl;
Env.Cache cache,cache2;
list<DAE.Type> types;
Option<Interactive.SymbolTable> st,st_1;
DAE.Exp exp_1;
DAE.Properties prop;
Absyn.Exp e,e1,e2;
Absyn.Operator op;
Prefix.Prefix pre;
DAE.Dimensions dims;
Absyn.ComponentRef comRef;

//Arrays of Complex types. Expand.
case (cache,env,(e as Absyn.BINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_ARRAY(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),dims,_),_),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

// Try left side first (specification ?????) r + s, s + r
// are operators Comutative?? (+, and ....) , r + 1 == 1 + r
case (cache,env,(e as Absyn.BINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

//Try overloaded constructor (implicit)
case (cache,env,(e as Absyn.BINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);

str1 = "'constructor'";
path2 = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path2, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1 as DAE.CALL(path2,_,_),prop))) = elabCallArgs3(cache2,env,types,path2,{e2},{},impl,st_1,pre,info);

comRef = Absyn.pathToCref(path2);
e2 = Absyn.CALL(comRef, Absyn.FUNCTIONARGS({e2}, {}));

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path2 = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path2, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path2,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

//overloaded binary operator. left side did not resolve. Try right side (specification ?????)
case (cache,env,(e as Absyn.BINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation

(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e2,impl,st,doVect,pre,info);


str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

case (cache,env,(e as Absyn.LBINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);


case (cache,env,(e as Absyn.LBINARY(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e2,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

case (cache,env,(e as Absyn.RELATION(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);

case (cache,env,(e as Absyn.RELATION(exp1 = e1,op = op,exp2 = e2)),impl,st,doVect,pre,info)
equation
(cache,_,DAE.PROP(DAE.T_COMPLEX(ClassInf.RECORD(path),_, _,_),_),st_1) = elabExp(cache,env,e2,impl,st,doVect,pre,info);

str1 = "'" +& Dump.opSymbolCompact(op) +& "'";
path = Absyn.joinPaths(path, Absyn.IDENT(str1));

(cache2,operatorCl,operatorEnv) = Lookup.lookupClass(cache,env,path, false);
true = SCode.isOperator(operatorCl);

operNames = SCodeUtil.getListofQualOperatorFuncsfromOperator(operatorCl);
(cache2,types) = Lookup.lookupFunctionsListInEnv(cache2, operatorEnv, operNames, info, {});

(cache2,SOME((exp_1,prop))) = elabCallArgs3(cache2,env,types,path,{e1,e2},{},impl,st_1,pre,info);
then
(cache,SOME((exp_1,prop)),st_1);
end matchcontinue;

end userDefOperatorDeoverloadBinary2;
*/


protected function operatorDeoverloadBinary
input Absyn.Operator inOperator1;
Expand Down

0 comments on commit 4804f62

Please sign in to comment.