Opened 10 years ago
Closed 4 years ago
#3244 closed defect (fixed)
Removing unnecessary vectorization of assignments in Front-end.
Reported by: | Mahder Alemseged Gebremedhin | Owned by: | Willi Braun |
---|---|---|---|
Priority: | normal | Milestone: | 1.16.0 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: |
Description
Currently we vectorize assignment statements in the front end. This is not really necessary and should be avoided since we end up having to reconstruct the arrays at runtime.
function testfunc input Real t; output Real o = t; protected Real[2] r1,r2; algorithm r1 := {1.0,2.0}; r2 := r1; // This shouldn't be vectorized end testfunc; model vectortest Real i; equation i = testfunc(time); end vectortest;
The assignment r2 := r1;
gets expanded to r2 := {r1[1], r1[2]};
by the front end. This ends up with code
array_alloc_scalar_real_array(&tmp1, 2, (modelica_real)(*real_array_element_addr(&_r1, 1, (modelica_integer) 1)), (modelica_real)(*real_array_element_addr(&_r1, 1, (modelica_integer) 2))); copy_real_array_data(tmp1, &_r2);
instead of what we get for the non vectorized version
copy_real_array_data(r1, &_r2);
The case becomes worse when the arrays are bigger and in loops.
so I fixed it now except I had one model failing due to some issues with linear and non linear systems in the back-end (plus two cpp tests but those are compilation issues of generated code and should be easy to fix)
Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravityWithPointMasses2 is the culprit.
Willi it's all yours now. The patch for the changes to the front end and expected outputs for some models in the testsuite is attached.
Attachments (1)
Change History (2)
by , 10 years ago
Attachment: | NoExpandAssignments.patch added |
---|
comment:1 by , 4 years ago
Component: | Backend → New Instantiation |
---|---|
Milestone: | Future → 1.16.0 |
Resolution: | → fixed |
Status: | new → closed |
The new frontend does not scalarize such assignments.
Patch file with the changes