Skip to content

Commit 9cd5dc1

Browse files
committed
- Added setVectorizationLimit as an API command.
- Cleaned up implementation of vectorization limit in RTOpts, and sprinkled some comments on it. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5915 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 55d6d0b commit 9cd5dc1

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

Compiler/Interactive.mo

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,23 @@ algorithm
16651665
then
16661666
(top_names_str,newst);
16671667

1668+
case (ISTMTS(interactiveStmtLst =
1669+
{IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "setVectorizationLimit"),
1670+
functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.INTEGER(value = limit)},
1671+
argNames = {})))}), st)
1672+
local
1673+
Integer limit;
1674+
Boolean res;
1675+
equation
1676+
RTOpts.setVectorizationLimit(limit);
1677+
then
1678+
("true", st);
1679+
1680+
case (ISTMTS(interactiveStmtLst =
1681+
{IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "setVectorizationLimit")))}),st)
1682+
then
1683+
("false", st);
1684+
16681685
end matchcontinue;
16691686
end evaluateGraphicalApi2;
16701687

Compiler/RTOpts.mo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,17 @@ public function setNoSimplify
198198
end setNoSimplify;
199199

200200
public function vectorizationLimit
201+
"Returns the vectorization limit that is used to determine how large an array
202+
can be before it no longer is expanded by Static.crefVectorize."
201203
output Integer limit;
204+
external "C";
202205
end vectorizationLimit;
203206

207+
public function setVectorizationLimit
208+
"Sets the vectorization limit, see vectorizationLimit above."
209+
input Integer limit;
210+
external "C";
211+
end setVectorizationLimit;
212+
204213
end RTOpts;
205214

Compiler/runtime/rtopts.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int simulation_cg;
6161
int silent;
6262
char* simulation_code_target = "gcc";
6363
char* class_to_instantiate = "";
64-
int vectorization_limit;
64+
long vectorization_limit;
6565

6666
/*
6767
* adrpo 2007-06-11
@@ -259,6 +259,16 @@ int check_debug_flag(char const* strdata)
259259
return flg;
260260
}
261261

262+
void set_vectorization_limit(long limit)
263+
{
264+
if(limit < 0) {
265+
vectorization_limit = 20;
266+
fprintf(stderr, "Warning, invalid vectorization limit (using default limit %ld\n", vectorization_limit);
267+
} else {
268+
vectorization_limit = limit;
269+
}
270+
}
271+
262272
#define VERSION_OPT1 "++v"
263273
#define VERSION_OPT2 "+version"
264274
#define ANNOTATION_VERSION "+annotationVersion"
@@ -457,11 +467,7 @@ RML_BEGIN_LABEL(RTOpts__args)
457467
fprintf(stderr, "# Flag Usage: +v=<vectorization limit>");
458468
RML_TAILCALLK(rmlFC); /* fail */
459469
}
460-
vectorization_limit = (int)atoi(&arg[3]);
461-
if (vectorization_limit < 0) {
462-
vectorization_limit = 20;
463-
fprintf(stderr, "Warning, invalid vectorization limit (using default limit %ld\n", vectorization_limit);
464-
}
470+
set_vectorization_limit(atol(&arg[3]));
465471
break;
466472
default:
467473
fprintf(stderr, "# Unknown option: %s\n", arg);
@@ -694,3 +700,11 @@ RML_BEGIN_LABEL(RTOpts__vectorizationLimit)
694700
RML_TAILCALLK(rmlSC);
695701
}
696702
RML_END_LABEL
703+
704+
RML_BEGIN_LABEL(RTOpts__setVectorizationLimit)
705+
{
706+
long limit = (long)RML_IMMEDIATE(RML_UNTAGFIXNUM(rmlA0));
707+
set_vectorization_limit(limit);
708+
RML_TAILCALLK(rmlSC);
709+
}
710+
RML_END_LABEL

0 commit comments

Comments
 (0)