-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- initial commit for GraphvizDump template
- new debug-flag: +d=graphvizDump - this activates additional graphical output (as *.dot files) for backend dumps (currently only +d=dumpinitialsystem is supported) - this is currently only useable with small/simple models git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18386 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
9 changed files
with
663 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
package GraphvizDump | ||
|
||
import interface GraphvizDumpTV; | ||
import CodegenUtil.*; | ||
|
||
template test(array<Integer> i, Boolean b) ::= | ||
match b | ||
case true then "true" | ||
else "false" | ||
end match | ||
end test; | ||
|
||
template dumpBackendDAE(BackendDAE.BackendDAE backendDAE, String suffix) | ||
::= | ||
match backendDAE | ||
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then | ||
let _ = textFile(dumpDependence(dae, suffix), '<%info.fileNamePrefix%>_<%suffix%>_dependence.dot') | ||
let _ = textFile(dumpMatching(dae, suffix), '<%info.fileNamePrefix%>_<%suffix%>_matching.dot') | ||
//let _ = textFile(dumpSorting(dae, suffix), '<%info.fileNamePrefix%>_<%suffix%>_sorting.dot') | ||
|
||
//this top-level template always returns an empty result | ||
//since generated texts are written to files directly | ||
'' | ||
end match | ||
end dumpBackendDAE; | ||
|
||
template dumpDependence(BackendDAE.BackendDAE backendDAE, String suffix) | ||
::= | ||
match backendDAE | ||
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then | ||
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 => | ||
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 => | ||
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]' | ||
;separator="\n") | ||
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 => | ||
'eq<%clusterID%>_<%eqID%> [label="<%BackendDump.equationString(eq)%>", shape="box"]' | ||
;separator="\n") | ||
<< | ||
subgraph cluster_<%clusterID%> { | ||
label = "system #<%clusterID%>"; | ||
color=white | ||
<%varDeclaration%> | ||
<%eqDeclaration%> | ||
<%dumpDependence2(clusterID, eqSystem.m)%> | ||
} | ||
>> | ||
;separator="\n\n") | ||
|
||
<< | ||
digraph G { | ||
label="<%info.fileNamePrefix%> [<%suffix%> - dependence]"; | ||
rankdir=LR; | ||
<%systems%> | ||
} | ||
>> | ||
end dumpDependence; | ||
|
||
template dumpDependence2(Integer clusterID, Option<BackendDAE.IncidenceMatrix> m) | ||
::= | ||
match m | ||
case SOME(incMatrix) then | ||
let incNodes = (arrayList(incMatrix) |> varList hasindex eqID fromindex 1 => | ||
let foo = (varList |> varID => | ||
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];' | ||
;separator="\n") | ||
'<%foo%>' | ||
;separator="\n") | ||
'<%incNodes%>' | ||
else | ||
'// no incidence matrix' | ||
end dumpDependence2; | ||
|
||
template dumpMatching(BackendDAE.BackendDAE backendDAE, String suffix) | ||
::= | ||
match backendDAE | ||
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then | ||
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 => | ||
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 => | ||
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]' | ||
;separator="\n") | ||
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 => | ||
<< | ||
eq<%clusterID%>_<%eqID%> [label="<%BackendDump.equationString(eq)%>", shape="box"] | ||
>> | ||
;separator="\n") | ||
<< | ||
subgraph cluster_<%clusterID%> { | ||
label = "system #<%clusterID%>"; | ||
color=white | ||
<%varDeclaration%> | ||
<%eqDeclaration%> | ||
<%connections(clusterID, eqSystem.matching, eqSystem.m)%> | ||
} | ||
>> | ||
;separator="\n\n") | ||
|
||
<< | ||
digraph G { | ||
label="<%info.fileNamePrefix%> [<%suffix%> - matching]"; | ||
rankdir=LR; | ||
<%systems%> | ||
} | ||
>> | ||
end dumpMatching; | ||
|
||
template connections(Integer clusterID, BackendDAE.Matching matching, Option<BackendDAE.IncidenceMatrix> m) | ||
::= | ||
match m | ||
case SOME(incMatrix) then | ||
match matching | ||
case matching as BackendDAE.MATCHING(ass2=ass2) then | ||
let incNodes = (arrayList(incMatrix) |> varList hasindex eqID fromindex 1 => | ||
let foo = (varList |> varID => | ||
if intEq(listGet(arrayList(ass2), eqID), varID) then | ||
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="bold", arrowhead="none"];' | ||
else | ||
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];' | ||
;separator="\n") | ||
'<%foo%>' | ||
;separator="\n") | ||
'<%incNodes%>' | ||
else | ||
let incNodes = (arrayList(incMatrix) |> varList hasindex eqID fromindex 1 => | ||
let foo = (varList |> varID => | ||
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="dashed", arrowhead="none"];' | ||
;separator="\n") | ||
'<%foo%>' | ||
;separator="\n") | ||
<< | ||
// no matching | ||
<%incNodes%> | ||
>> | ||
else | ||
match matching | ||
case matching as BackendDAE.MATCHING(ass2=ass2) then | ||
let matchedNodes = (arrayList(ass2) |> varID hasindex eqID fromindex 1 => | ||
'var<%clusterID%>_<%varID%> -> eq<%clusterID%>_<%eqID%> [style="bold", arrowhead="none"];' | ||
;separator="\n") | ||
<< | ||
// no incidence matrix | ||
<%matchedNodes%> | ||
>> | ||
else | ||
<< | ||
// no incidence matrix | ||
// no matching | ||
>> | ||
end connections; | ||
|
||
template dumpSorting(BackendDAE.BackendDAE backendDAE, String suffix) | ||
::= | ||
match backendDAE | ||
case dae as BackendDAE.DAE(eqs=eqs, shared=BackendDAE.SHARED(info=info as BackendDAE.EXTRA_INFO(__))) then | ||
let systems = (eqs |> eqSystem as BackendDAE.EQSYSTEM(__) hasindex clusterID fromindex 1 => | ||
let varDeclaration = (BackendVariable.varList(eqSystem.orderedVars) |> var as BackendDAE.VAR(__) hasindex varID fromindex 1 => | ||
'var<%clusterID%>_<%varID%> [label="<%crefStr(var.varName)%>"]' | ||
;separator="\n") | ||
let eqDeclaration = (BackendEquation.equationList(eqSystem.orderedEqs) |> eq hasindex eqID fromindex 1 => | ||
'eq<%clusterID%>_<%eqID%> [label="<%BackendDump.equationString(eq)%>", shape="box"]' | ||
;separator="\n") | ||
<< | ||
subgraph cluster_<%clusterID%> { | ||
label = "system #<%clusterID%>"; | ||
color=white | ||
<%varDeclaration%> | ||
<%dumpStrongComponent(clusterID, eqSystem.matching)%> | ||
} | ||
>> | ||
;separator="\n\n") | ||
|
||
<< | ||
digraph G { | ||
label="<%info.fileNamePrefix%> [<%suffix%> - sorting]"; | ||
rankdir=LR; | ||
<%systems%> | ||
} | ||
>> | ||
end dumpSorting; | ||
|
||
template dumpStrongComponent(Integer clusterID, BackendDAE.Matching matching) | ||
::= | ||
match matching | ||
case matching as BackendDAE.MATCHING(comps=comps) then | ||
let cmpNodes = (comps |> comp hasindex eqID fromindex 1 => | ||
match comp | ||
case c as SINGLEEQUATION(__) then | ||
'var<%clusterID%>_<%c.var%>' | ||
case c as EQUATIONSYSTEM(__) then | ||
let foo = (c.vars |> v => 'var<%clusterID%>_<%v%>' ;separator=" <-> ") | ||
'<%foo%>' | ||
else | ||
'asd' | ||
;separator=" -> ") | ||
'<%cmpNodes%>' | ||
end dumpStrongComponent; | ||
|
||
end GraphvizDump; |
Oops, something went wrong.