Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3458 closed defect (fixed)

Code generation fails for 10 MultiBody examples and more after latest BackEnd changes

Reported by: Rüdiger Franke Owned by: Lennart Ochel
Priority: critical Milestone: 1.9.4
Component: Backend Version:
Keywords: Cc: Lennart Ochel, Adrian Pop

Description

Today the Cpp runtime failed to generate a simulator for 10 MultiBody examples from MSL 3.2.1. See e.g.

Modelica.Mechanics.MultiBody.Examples.Elementary.SpringWithMass

It appears that the information about array dims is missing in daeExpBinary (file CodegenCppCommon.tpl).

Moreover the nonlinear solver failed for Modelica.Fluid.Examples.InverseParameterization that had just been fixed yesterday in MSL.

Also some tests have been deactivated to get the backend changes into the main repository, including Cpp FMU generation and PumpingSystem -- the startup logo of OMEdit.

I wonder if it is justified to break so many things in the main repository. This is critical for users like us who want to stay tuned with recent additions.

Change History (16)

comment:1 by Rüdiger Franke, 9 years ago

It is even more critical for contributors like us -- where can one contribute if the main repository is broken?

comment:2 by Adrian Pop, 9 years ago

Sorry about this. I talked with Lennart and we decided that he should commit his split of the backend transformations for simulation and initialization as he was waiting with it for a while now and is really needed. We knew that some models in the testsuite fail but only a few.
We didn't know the impact it would have on the CPP runtime.

Hopefully this will get fixed very soon.

Last edited 9 years ago by Adrian Pop (previous) (diff)

comment:3 by Lennart Ochel, 9 years ago

Sorry for the inconvenience. I gave notice about that in the last OpenModelica developer meeting. I also mentioned there that it could cause some regressions. I work hard on fixing the issues ASAP. The good thing about it is that my changes improve also the cpp runtime.
BTW: I Don't agree that there are many issues left. I worked several weeks on fixing a lot of issues before I pushed the changes.

in reply to:  1 comment:4 by Lennart Ochel, 9 years ago

Replying to rfranke:

It is even more critical for contributors like us -- where can one contribute if the main repository is broken?

You could fork the latest stable version and work on that until we have a new stable version.

comment:5 by Lennart Ochel, 9 years ago

Cc: Adrian Pop added
Owner: changed from somebody to Lennart Ochel
Status: newassigned

comment:6 by Rüdiger Franke, 9 years ago

There seem two issues with the failed MultiBody tests, see e.g. Modelica.Mechanics.MultiBody.Examples.Elementary.SpringWithMass. One is a missing implementation for array casts. The second issue is that daeExpBinary doesn't match

   case MUL_MATRIX_PRODUCT(ty=T_ARRAY(dims=dims))

See CodegenCppCommon.tpl, line 2291. The C runtime just uses

   case MUL_MATRIX_PRODUCT(__)

Why does ty=T_ARRAY(dims=dims) not match?

comment:7 by Adrian Pop, 9 years ago

@rfranke, i guess is not T_ARRAY in there but something else?

comment:8 by Rüdiger Franke, 9 years ago

But what could be there?

The operation at hand is:

$TMP_54 = (*Real[3, 4]*)({{$STATESET1.A[1,1], $STATESET1.A[1,2], $STATESET1.A[1,3], $STATESET1.A[1,4]}, {$STATESET1.A[2,1], $STATESET1.A[2,2], $STATESET1.A[2,3], $STATESET1.A[2,4]}, {$STATESET1.A[3,1], $STATESET1.A[3,2], $STATESET1.A[3,3], $STATESET1.A[3,4]}}) * {body.Q[4], body.Q[3], body.Q[2], body.Q[1]}

Meaning the binary operation multiplies Real[3,4] with Real[4], resulting in Real[3]. Isn't that T_ARRAY?

Hudson is currently checking an implementation for cast_array. The remaining issue is that the not matching T_ARRAY results in the Cpp code:

  _$TMP_54.assign(daeExpBinary:ERR);

This should be:

  StatArrayDim1<double, 3> tmp29;
  multiply_array<double>(tmp27, tmp28, tmp29);  
  _$TMP_54.assign(tmp29);

But for this one needs to know the dimensionality of 1 and ideally also the size of 3. This is why T_ARRAY should match.

Alternatively, avoiding any sizing and maybe also resulting in faster code:

  multiply_array<double>(tmp27, tmp28, _$TMP_54);  

But can daeExpBinary know that the result will be assigned afterwards, in order to avoid the creating of a temporary array tmp29?

comment:9 by Adrian Pop, 9 years ago

One needs to print what's in there as it might be wrong. I'll have a look myself.

comment:10 by Rüdiger Franke, 9 years ago

It's T_REAL!??

comment:11 by Adrian Pop, 9 years ago

It seems so as the code generated was:

void SpringWithMassInitialize::initEquation_57()
{
  ....
  double tmp27; // scalar
  cast_int_array_to_double(&tmp26, &tmp27); // used as array
  ....
}

The types of expressions left and right seems to be OK but the type inside the operator is wrong.

comment:12 by Adrian Pop, 9 years ago

The type issues should be fixed in: d78c1bfa80e52f9fca8f58b116517a5bd5551d47/OMCompiler.
Added test for it in:
52d2ee5090879e5187686ff7b3d0070ea4398822/OpenModelica-testsuite.
I'll start the coverage job to see where we are now.

comment:13 by Rüdiger Franke, 9 years ago

That was it. Having thought into daeExpBinary, it appeared appropriate to clean it up in 1dff76a87c9266e809fa7ecaa63b7138c4da43fe/OMCompiler.

comment:14 by Rüdiger Franke, 9 years ago

Resolution: fixed
Status: assignedclosed

comment:15 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:16 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.