Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

[BE] Do not run clockPartitioning unless needed #2211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions Compiler/BackEnd/SynchronousFeatures.mo
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,29 @@ encapsulated package SynchronousFeatures
- sub-clock partitioning"


public import Absyn;
public import BackendDAE;
public import DAE;

protected import BackendDAEOptimize;
protected import BackendDAEUtil;
protected import BackendDump;
protected import ExpressionDump;
protected import BackendEquation;
protected import BackendVariable;
protected import ComponentReference;
protected import DAEUtil;
protected import DAEDump;
protected import Error;
protected import Flags;
protected import List;
protected import Util;
protected import Types;
protected import Expression;
protected import HashTable;
protected import MMath;
import Absyn;
import BackendDAE;
import DAE;

protected
import BackendDAEOptimize;
import BackendDAEUtil;
import BackendDump;
import ExpressionDump;
import BackendEquation;
import BackendVariable;
import ComponentReference;
import DAEUtil;
import DAEDump;
import Error;
import Expression;
import Flags;
import Global;
import HashTable;
import List;
import MMath;
import Types;
import Util;

// =============================================================================
// clock partitioning
Expand All @@ -68,7 +70,14 @@ public function clockPartitioning
"Finds independent partitions of the equation system by base-clock partitioning and TLM."
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
protected
Option<Boolean> isSynchronous;
algorithm
isSynchronous := getGlobalRoot(Global.isSynchronous);
if isNone(isSynchronous) then
outDAE := inDAE;
return;
end if;
outDAE := match inDAE
local
BackendDAE.EqSystem syst;
Expand Down
15 changes: 15 additions & 0 deletions Compiler/FrontEnd/Static.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6472,6 +6472,8 @@ public function elabBuiltinHandler
output DAE.Exp outExp;
output DAE.Properties outProperties;
end HandlerFunc;
protected
Boolean isSynchronous=false;
algorithm
outHandler := match (inIdent)
case "smooth" then elabBuiltinSmooth;
Expand Down Expand Up @@ -6515,42 +6517,52 @@ algorithm
case "Clock"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinClock;
case "hold"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinHold;
case "shiftSample"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinShiftSample;
case "backSample"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinBackSample;
case "noClock"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinNoClock;
case "transition"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinTransition;
case "initialState"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinInitialState;
case "activeState"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinActiveState;
case "ticksInState"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinTicksInState;
case "timeInState"
equation
true = intGe(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD), 33);
isSynchronous = true;
then elabBuiltinTimeInState;
case "sourceInfo"
equation
Expand All @@ -6569,6 +6581,9 @@ algorithm
true = Config.acceptMetaModelicaGrammar();
then elabBuiltinIsPresent;
end match;
if isSynchronous then
setGlobalRoot(Global.isSynchronous, SOME(true));
end if;
end elabBuiltinHandler;

public function isBuiltinFunc "Returns true if the function name given as argument
Expand Down
1 change: 1 addition & 0 deletions Compiler/Global/Global.mo
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ constant Integer currentInstVar = 22;
constant Integer operatorOverloadingCache = 23;
constant Integer optionSimCode = 24;
constant Integer interactiveCache = 25;
constant Integer isSynchronous = 26;

// indexes in System.tick
// ----------------------
Expand Down
43 changes: 22 additions & 21 deletions Compiler/Script/CevalScriptBackend.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,7 @@ protected function runFrontEndWork
output FCore.Graph env;
output DAE.DAElist dae;
algorithm
setGlobalRoot(Global.isSynchronous, NONE());
(cache,env,dae) := matchcontinue (inCache,inEnv,className)
local
Absyn.Restriction restriction;
Expand Down Expand Up @@ -3473,29 +3474,29 @@ algorithm
// create the path till packagetool
str2 := stringAppendList({omhome,pd,"lib",pd,"omc",pd,"SEMLA",pd,"packagetool",str1});
if System.regularFileExists(str2) then
// create the list of arguments for packagetool
str3 := "-librarypath \"" + System.dirname(fileName) + "\" -version \"1.0\" -language \"3.2\" -encrypt \"true\"";
call := stringAppendList({str2," ",str3});
logFile := "packagetool.log";
// remove the logFile if it already exists.
if System.regularFileExists(logFile) then
System.removeFile(logFile);
end if;
// run the packagetool command
if 0 == System.systemCall(call, logFile) then
success := true;
else
success := false;
end if;
// read the logFile
if System.regularFileExists(logFile) then
commandOutput := System.readFile(logFile);
end if;
else
Error.addMessage(Error.ENCRYPTION_NOT_SUPPORTED, {str2});
// create the list of arguments for packagetool
str3 := "-librarypath \"" + System.dirname(fileName) + "\" -version \"1.0\" -language \"3.2\" -encrypt \"true\"";
call := stringAppendList({str2," ",str3});
logFile := "packagetool.log";
// remove the logFile if it already exists.
if System.regularFileExists(logFile) then
System.removeFile(logFile);
end if;
// run the packagetool command
if 0 == System.systemCall(call, logFile) then
success := true;
else
success := false;
end if;
// read the logFile
if System.regularFileExists(logFile) then
commandOutput := System.readFile(logFile);
end if;
else
Error.addMessage(Error.ENCRYPTION_NOT_SUPPORTED, {str2});
commandOutput := "";
success := false;
end if;
end if;
else
Error.addMessage(Error.FILE_NOT_FOUND_ERROR, {fileName});
commandOutput := "";
Expand Down