Opened 7 years ago

Closed 7 years ago

#4751 closed defect (fixed)

Change of MAX_SIZE_LINEAR_TEARING

Reported by: Rüdiger Franke Owned by: Rüdiger Franke
Priority: critical Milestone: 1.13.0
Component: Backend Version:
Keywords: Cc: Patrick Täuber, Francesco Casella, Willi Braun, Martin Sjölund

Description

Commit ccd5c42a changed "maxSizeLinearTearing=200 as default".

This is bad for models using dense solvers, such as the default setting of the Cpp runtime. OpenModelica users need to be informed that the omc default was changed and that they may need to manually adjust maxSizeLinearTearing starting from OpenModelica 1.13. There should be a good reason for this.

What was the rationale behind the change?
Can you give me a link to the ticket or any other document discussing it?

The Cpp runtime uses the omc flag --matrixFormat=dense|sparse (see OMC flags). The max tearing size could be adjusted depending on this setting.

Meanwhile, is it possible to revert commit ccd5c42a until the consequences will have been discussed and documented?

Change History (12)

comment:1 by Patrick Täuber, 7 years ago

See #4542 for the rationale.

comment:2 by Rüdiger Franke, 7 years ago

Thank you for the link. You conclude "Thus, I suggest these as a new default. And then let's see what impact it has on other libraries."

How can the change be made less aggressive until the impact on others will be clear?

What is the approach of the C runtime regarding sparse vs dense solvers for simulation and FMI export?

in reply to:  2 comment:3 by Willi Braun, 7 years ago

It would be possible to fix this by adding again an CPP exception(e.g. PR2170). Also actually I would like to reduce such exceptions. However since, this --matrixFormat flag is also a cpp flag this would be at least more consistent. The question remains what is good value to choose? In the PR I changed it back to 4000, but would actually like to choose unlimited.

Replying to rfranke:

Thank you for the link. You conclude "Thus, I suggest these as a new default. And then let's see what impact it has on other libraries."

How can the change be made less aggressive until the impact on others will be clear?

What is the approach of the C runtime regarding sparse vs dense solvers for simulation and FMI export?

Basically the c runtime is able to handle this at runtime level to we so not need to decide it in advance. The density threshold and size threshold are used to decide it:

nnz/(double)(size*size)<=linearSparseSolverMaxDensity 
&& 
size>=linearSparseSolverMinSize

comment:4 by Willi Braun, 7 years ago

Cc: Martin Sjölund added

@sjoelund.se Would it possible to test all libraries with three different and to compare it, without pushing every second day an other default value?

comment:5 by Francesco Casella, 7 years ago

The issue at stake here is that the optimal upper limit for linear tearing should depend on the availability of a linear sparse solver in the runtime.

If a sparse solver is indeed available, then it makes sense to use it, rather than using tearing and a dense solver, for sizes above 200, as discussed in #4542. The previous default was indeed too big, as the ScalableTestSuite results clearly demonstrated. Of course the ScalableTestSuite is by no means representative of all possible models, but at least those results give some grounding to the choice of the default. The previous one, 4000, was pretty much an arbitrary number, and it was only by sheer chance that it did not affect models of interest for @rfranke.

If a sparse solver is not available, then the situation is radically different, and the limit should indeed be infinity, because there is always a huge advantage at using tearing, particularly in terms of memory usage.

So my proposal is not to add an exception for the Cpp runtime, but rather to add a rule that maxSizeLinearTearing is only considered if a sparse solver is available in the currently selected target runtime, whatever that is.

I guess the same argument holds for maxSizeNonlinearTearing

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

PR2170 hard codes 4000 for the Cpp runtime with dense solver, which is not good.

I agree with Francesco that it should be distinguished between dense and sparse solvers; infinity for dense solvers unless maxSizeLinearTearing was set to 0 to disable tearing.

comment:7 by Rüdiger Franke, 7 years ago

The following proposed code manipulates PR2170 by checking for 0 (tearing disabled) and using INT_MAX instead of 4000. Does OpenModelica have some INT_MAX constant?

    // CPP runtime: unlimited tearing threshold if dense solver is used 
    if (stringEqual(Config.simCodeTarget(), "Cpp") and
        stringEqual(Flags.getConfigString(Flags.MATRIX_FORMAT), "dense") and
        Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING) > 0 ) 
       then
       Flags.setConfigInt(Flags.MAX_SIZE_LINEAR_TEARING, INT_MAX);
    end if;

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

Alternatatively: what about changing the default for maxSizeLinearTearing back to 4000, i.e. the value known from OpenModelica <= 1.12, until new values will have been tested and checked for possible side effects?

in reply to:  8 comment:9 by Francesco Casella, 7 years ago

Replying to rfranke:

Alternatatively: what about changing the default for maxSizeLinearTearing back to 4000, i.e. the value known from OpenModelica <= 1.12, until new values will have been tested and checked for possible side effects?

This would cause a marked regression in the runtime performance of many models of the ScalableTestSuite. As of today, if a sparse solver is available there are only positive known effects and no negative known effects of this change, so I see no reason to change this back.

IMHO the right way to solve your issue is to always enable tearing if a sparse solver is not available, not to increase this limit to an artificially too high number to indirectly obtain the same result, while also obtaining it when it's not appropriate. BTW, what if you run into models with 4001 unknowns in a linear system of equations?

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

PR2176 enables tearing for dense linear and nonlinear systems locally in the tearing module. This way the maxSizeNon/LinearTearing settings don't need to be changed and no INT_MAX is needed.

comment:11 by Rüdiger Franke, 7 years ago

Owner: changed from Lennart Ochel to Rüdiger Franke
Status: newassigned

comment:12 by Rüdiger Franke, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.