Opened 8 years ago

Closed 8 years ago

#4224 closed defect (fixed)

Activated wrapFunctionCalls lets events fail with Cpp runtime

Reported by: rfranke Owned by: lochel
Priority: critical Milestone: 1.12.0
Component: Backend Version: v1.12.0
Keywords: Cc: niklwors, ptaeuber

Description (last modified by rfranke)

Commit wrapFunctionCalls is activated ... lets the event processing of the Cpp runtime fail.

See the following example:

model TrapezoidTest
  Modelica.Blocks.Sources.Trapezoid trapezoid(
    offset=1,
    period=10,
    amplitude=4,
    rising=1,
    width=4,
    falling=1,
    startTime=2)
    annotation (Placement(visible = true, transformation(extent = {{-50, 34}, {-30, 54}}, rotation = 0)));
equation
  annotation(experiment(StopTime=20));
end TrapezoidTest;

trapezoid.y stays at constant 1 throughout the simulation, instead of raising to 5 twice. The model Modelica.Blocks.Sources.Trapezoid contains the following when clause:

equation
  when integer((time - startTime)/period) > pre(count) then
    count = pre(count) + 1;
    T_start = time;
  end when;

There are two problems:

  1. The backend introduces a common subexpression for integer((time - startTime)/period), even though it only appears once and the expression hardly justifies the overhead of a common subexpression.
  1. The Cpp runtime generates no event for the when clause with common subexpression.

Change History (8)

comment:1 Changed 8 years ago by rfranke

Commit 1d06167 adds integer() to isSkipCase.

Should all event triggering mathematical functions be added here or does the Cpp runtime have to be changed to cover them in common subexpressions?

What about the Integer conversion function -- cf. String conversion?

Last edited 8 years ago by rfranke (previous) (diff)

comment:2 Changed 8 years ago by rfranke

  • Description modified (diff)

comment:3 Changed 8 years ago by jhagemann

integer() was not listed in isSkipCase because it was not necessary for the testsuite.
Also the function isSKipCase_advanced is only for testing purposes and it is not sufficiently analyzed which function call should be added to the SkipCase by now.

comment:4 Changed 8 years ago by rfranke

Is it sufficient to develop against the testsuite?
Shouldn't some structuring be made based on the Modelica specification?

For instance: MLS 3.3 rev1, section 3.7.1 defines "Numeric Functions and Conversion Functions". String and sign defined in this section belong to isSkipCase. abs that is defined at the same place of MLS belongs to isSkipCase_advanced. Integer that is defined there as well does not belong to isSkipCase???

comment:5 Changed 8 years ago by lochel

I just added all the functions from section 3.7 to module wrapFunctionCalls: OMCompiler#1408.

comment:6 Changed 8 years ago by rfranke

This look good. The testsuite appears stable. Thank you!

comment:7 Changed 8 years ago by lochel

  • Status changed from new to accepted

@rfranke Can we close this once the changes are pushed? Or is there more to fix?

comment:8 Changed 8 years ago by rfranke

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.