Skip to content

Commit

Permalink
- Added command-line switch to set the vectorization limit used by
Browse files Browse the repository at this point in the history
  Static.crefVectorize.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5904 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Aug 10, 2010
1 parent c6f0127 commit 6e356d9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Compiler/RTOpts.mo
Expand Up @@ -197,5 +197,9 @@ public function setNoSimplify
external "C";
end setNoSimplify;

public function vectorizationLimit
output Integer limit;
end vectorizationLimit;

end RTOpts;

20 changes: 10 additions & 10 deletions Compiler/Static.mo
Expand Up @@ -10450,7 +10450,7 @@ public function crefVectorize
input DAE.Type inType;
input Option<DAE.Exp> splicedExp;
input DAE.ExpType crefIdType "the type of the last cref ident, without considering subscripts. picked up from splicedExpData and used for crefs in vectorized exp";
input Boolean applyLimits "if true, only perform for small sized arrays (dimsize <20)";
input Boolean applyLimits "if true, only perform for small sized arrays (dimsize < vectorization limit (default 20))";
output DAE.Exp outExp;
algorithm
outExp := matchcontinue (performVectorization,inExp,inType,splicedExp,crefIdType,applyLimits)
Expand All @@ -10477,14 +10477,14 @@ algorithm
e = crefVectorize(doVect,e,t,NONE,crefIdType,applyLimits);
then e;

// component reference and an array type with dimensions less than 20
// component reference and an array type with dimensions less than vectorization limit
case (_,DAE.CREF(componentRef = cr_2,ty = t2),
(tOrg as (DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds)),arrayType =
(t as (DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds2))),_))),_)),
SOME(exp1 as DAE.CREF(componentRef = cr,ty = exptp)),crefIdType,applyLimits)
equation
b1 = (ds < 20);
b2 = (ds2 < 20);
b1 = (ds < RTOpts.vectorizationLimit());
b2 = (ds2 < RTOpts.vectorizationLimit());
true = boolAnd(b1, b2) or not applyLimits;
e = elabCrefSlice(cr,crefIdType);
e = tryToConvertArrayToMatrix(e);
Expand All @@ -10494,26 +10494,26 @@ algorithm
case(_, exp2 as (DAE.CREF(componentRef = cr_2,ty = t2)), (tOrg as (DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds)),arrayType = t),_)), SOME(exp1 as DAE.CREF(componentRef = cr,ty = exptp)),crefIdType,applyLimits)
equation
false = Types.isArray(t);
true = (ds < 20) or not applyLimits;
true = (ds < RTOpts.vectorizationLimit()) or not applyLimits;
e = elabCrefSlice(cr,crefIdType);
then
e;

/* matrix sizes > 20 is not vectorized */
/* matrix sizes > vectorization limit is not vectorized */
case (_,DAE.CREF(componentRef = cr,ty = exptp),(DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds)),arrayType = (t as (DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds2))),_))),_),_,crefIdType,applyLimits)
equation
b1 = (ds < 20);
b2 = (ds2 < 20);
b1 = (ds < RTOpts.vectorizationLimit());
b2 = (ds2 < RTOpts.vectorizationLimit());
true = boolAnd(b1, b2) or not applyLimits;
e = createCrefArray2d(cr, 1, ds, ds2, exptp, t,crefIdType);
then
e;

/* vectorsizes > 20 is not vectorized */
/* vectorsizes > vectorization limit is not vectorized */
case (_,DAE.CREF(componentRef = cr,ty = exptp),(DAE.T_ARRAY(arrayDim = DAE.DIM(integerOption = SOME(ds)),arrayType = t),_),_,crefIdType,applyLimits)
equation
false = Types.isArray(t);
true = (ds < 20) or not applyLimits;
true = (ds < RTOpts.vectorizationLimit()) or not applyLimits;
e = createCrefArray(cr, 1, ds, exptp, t,crefIdType);
then
e;
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/optmanager.cpp
Expand Up @@ -64,6 +64,7 @@ extern "C"
options.insert(std::pair<std::string,bool>("reportMatchingError",false));
options.insert(std::pair<std::string,bool>("envCache",true));
options.insert(std::pair<std::string,bool>("collectZCFromSmooth", true)); // If true zero crossings are collected from expr in smooth(N, expr)
options.insert(std::pair<std::string,bool>("noVectorization", false));
//options.insert(std::pair<std::string,bool>("dummy",false));

/* for(stringMap::const_iterator it = options.begin(); it != options.end(); ++it)
Expand Down
22 changes: 22 additions & 0 deletions Compiler/runtime/rtopts.c
Expand Up @@ -61,6 +61,7 @@ int simulation_cg;
int silent;
char* simulation_code_target = "gcc";
char* class_to_instantiate = "";
int vectorization_limit;

/*
* adrpo 2007-06-11
Expand Down Expand Up @@ -115,6 +116,7 @@ void RTOpts_5finit(void)
annotation_version = "2.x";
showErrorMessages = 0;
noSimplify = 0;
vectorization_limit = 20;
}

/*
Expand Down Expand Up @@ -449,6 +451,18 @@ RML_BEGIN_LABEL(RTOpts__args)
class_to_instantiate = (char*)malloc(strlen(arg) * sizeof(char));
strcpy(class_to_instantiate, arg + 3);
break;
// vectorization limit used by Static.crefVectorize.
case 'v':
if (arg[2] != '=') {
fprintf(stderr, "# Flag Usage: +v=<vectorization limit>");
RML_TAILCALLK(rmlFC); /* fail */
}
vectorization_limit = (int)atoi(&arg[3]);
if (vectorization_limit < 0) {
vectorization_limit = 20;
fprintf(stderr, "Warning, invalid vectorization limit (using default limit %ld\n", vectorization_limit);
}
break;
default:
fprintf(stderr, "# Unknown option: %s\n", arg);
RML_TAILCALLK(rmlFC); /* fail */
Expand Down Expand Up @@ -672,3 +686,11 @@ RML_BEGIN_LABEL(RTOpts__getNoSimplify)
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL


RML_BEGIN_LABEL(RTOpts__vectorizationLimit)
{
rmlA0 = mk_icon(vectorization_limit);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

0 comments on commit 6e356d9

Please sign in to comment.