Skip to content

Commit

Permalink
Unroll vectorized connect equations (#10906)
Browse files Browse the repository at this point in the history
- Unroll vectorized connect equations when using the normal connect
  handling, to treat them the same as any other for loop containing
  connect equations.

Fixes #10840
  • Loading branch information
perost committed Jun 29, 2023
1 parent e87df02 commit 02127e9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -1145,7 +1145,7 @@ algorithm
eq := Equation.FOR(iter, SOME(range), {eq}, scope, src);
end while;
then
eq :: equations;
splitForLoop(eq, EMPTY_PREFIX, equations, settings);

end match;
end for;
Expand Down
1 change: 1 addition & 0 deletions testsuite/flattening/modelica/scodeinst/Makefile
Expand Up @@ -858,6 +858,7 @@ NonexistentRedeclareModifier1.mo \
NonexistentRedeclareModifier2.mo \
NoScalarize1.mo \
NoScalarize2.mo \
NoScalarizeConnect1.mo \
OperationAdd1.mo \
OperationAddEW1.mo \
OperationDiv1.mo \
Expand Down
42 changes: 42 additions & 0 deletions testsuite/flattening/modelica/scodeinst/NoScalarizeConnect1.mo
@@ -0,0 +1,42 @@
// name: NoScalarizeConnect1
// keywords:
// status: correct
// cflags: -d=newInst --newBackend
//

connector C
Real e;
flow Real f;
end C;

model M
C c1, c2;
equation
connect(c1, c2);
end M;

model NoScalarizeConnect1
M m[3];
end NoScalarizeConnect1;

// Result:
// class NoScalarizeConnect1
// Real[3] m.c2.f;
// Real[3] m.c2.e;
// Real[3] m.c1.f;
// Real[3] m.c1.e;
// equation
// m[3].c1.e = m[3].c2.e;
// (-m[3].c1.f) - m[3].c2.f = 0.0;
// m[2].c1.e = m[2].c2.e;
// (-m[2].c1.f) - m[2].c2.f = 0.0;
// m[1].c1.e = m[1].c2.e;
// (-m[1].c1.f) - m[1].c2.f = 0.0;
// for $i1 in 1:3 loop
// m[$i1].c2.f = 0.0;
// end for;
// for $i1 in 1:3 loop
// m[$i1].c1.f = 0.0;
// end for;
// end NoScalarizeConnect1;
// endResult

0 comments on commit 02127e9

Please sign in to comment.