Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3583 closed defect (invalid)

Support for disabling Jacobians

Reported by: Martin Sjölund Owned by: Willi Braun
Priority: high Milestone: 1.9.4
Component: Backend Version:
Keywords: Cc: Francesco Casella, Willi Braun

Description

If an explicit solver is used, we do not need the information in the Jacobian. For large models, it is desirable to be able to disable generation of Jacobians on a flag.

Change History (22)

comment:1 by Lennart Ochel, 9 years ago

Do you mean something like --postOptModules-=detectJacobianSparsePattern? That's already available.

Last edited 9 years ago by Lennart Ochel (previous) (diff)

comment:2 by Francesco Casella, 9 years ago

Not only that. All the generation of code to compute the Jacobian (whether or not it is sparse or coloured) should be disabled, in the back-end, but also in the SimCode and C-compilation. It takes a lot of time and memory which is completly wasted in this case. And it gets worse with increasing model size.

comment:3 by Adrian Pop, 9 years ago

Owner: changed from somebody to Willi Braun
Status: newassigned

comment:4 by Lennart Ochel, 9 years ago

Where get those Jacobians calculated? Inside the SimCode phase?

Last edited 9 years ago by Lennart Ochel (previous) (diff)

comment:5 by Willi Braun, 9 years ago

By default we generate _only_ for linear systems symbolic jacobians, what actually is matrix A (in A*x=b), which is needed to get a direct solution of such linear system.
Is this one meant by this ticket?

Otherwise we generate the sparsity information and colouring of a system by default which is not used by explicit solver and therefore the solution from Lennart works.

comment:6 by Francesco Casella, 9 years ago

Just to make sure I get it correctly:

  • the original system (after index reduction) is an index one DAE: F(x, dx/dt, v, t) = 0
  • causalization brings it to dx/dt = f(x,t)
  • the Jacobian df/dx is computed analytically by default only if f(x,t) is linear w.r.t x
  • otherwise, it is computed by numerical differentiation, using colouring to reduce the calls to f(x+dx,t) to a minimum

Is this correct?

comment:7 by Willi Braun, 9 years ago

No, the Jacobian df/dx is computed analytically f(x,t) w.r.t. x only with the flag --generateSymbolicJacobian is set.

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

Using --postOptModules-=detectJacobianSparsePattern, there still seems to be some Jacobians generated:

Notification: Performance of postOpt calculateStrongComponentJacobians (initialization): time 0.04305/3122, GC stats:
Notification: Performance of postOpt calculateStrongComponentJacobians (simulation): time 0.003566/3161, GC stats:
Notification: Performance of postOpt calculateStateSetsJacobians (simulation): time 3.074e-05/3161, GC stats:
Notification: Performance of SimCode generated analytical Jacobians: time 116.6/3279, GC stats:

in reply to:  8 ; comment:9 by Lennart Ochel, 9 years ago

Replying to sjoelund.se:

Notification: Performance of postOpt calculateStrongComponentJacobians (initialization): time 0.04305/3122, GC stats:

This can be disabled using --initOptModules-=calculateStrongComponentJacobians.

Notification: Performance of postOpt calculateStrongComponentJacobians (simulation): time 0.003566/3161, GC stats:

This can be disabled using --postOptModules-=calculateStrongComponentJacobians.

Notification: Performance of postOpt calculateStateSetsJacobians (simulation): time 3.074e-05/3161, GC stats:

This can be disabled using --postOptModules-=calculateStateSetsJacobians.

However, I'm not sure if everything still works fine if these modules are disabled.

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

Well, those 3 are fast. What does "SimCode generated analytical Jacobians" actually do? Is it important? :)

in reply to:  10 comment:11 by Lennart Ochel, 9 years ago

Replying to sjoelund.se:

Well, those 3 are fast. What does "SimCode generated analytical Jacobians" actually do? Is it important? :)

This should disable all the symbolic Jacobians, which means that also the SimCode task "generated analytical Jacobians" should be performed in no-time since there is nothing to do, right?

in reply to:  7 comment:12 by Lennart Ochel, 9 years ago

Replying to wbraun:

No, the Jacobian df/dx is computed analytically f(x,t) w.r.t. x only with the flag --generateSymbolicJacobian is set.

BTW: Better use --postOptModules+=generateSymbolicJacobian.

in reply to:  9 comment:13 by Willi Braun, 9 years ago

Replying to sjoelund.se:

Using --postOptModules-=detectJacobianSparsePattern, there still seems to be some Jacobians generated:

[...]
Notification: Performance of SimCode generated analytical Jacobians: time 116.6/3279, GC stats:

Hm, my guess is we measure there something different that run while the SimCode phase, since there is really nothing mandatory to do in the function where this execStat is executed.

Replying to lochel:

Replying to sjoelund.se:

Notification: Performance of postOpt calculateStrongComponentJacobians (initialization): time 0.04305/3122, GC stats:

This can be disabled using --initOptModules-=calculateStrongComponentJacobians.

Notification: Performance of postOpt calculateStrongComponentJacobians (simulation): time 0.003566/3161, GC stats:

This can be disabled using --postOptModules-=calculateStrongComponentJacobians.

Notification: Performance of postOpt calculateStateSetsJacobians (simulation): time 3.074e-05/3161, GC stats:

This can be disabled using --postOptModules-=calculateStateSetsJacobians.

However, I'm not sure if everything still works fine if these modules are disabled.

But these modules are more or less necessary to perform a simulation run.
If one would deactivate --postOptModules-=calculateStateSetsJacobians there is no alternative and a simulation run with dynamic state selection will fail.
Also the module calculateStrongComponentJacobians, which basically calculates for a linear torn system the jacobian matrix (again, that's actually A, of A*x=b), then the system will be not solvable, since we have no alternative in place.

comment:14 by Francesco Casella, 9 years ago

Sorry, let me focus back on the core issue: we have a test case in which we get:

Notification: Performance of SimCode generated analytical Jacobians: time 116.6/3279, GC stats:

It is not 100% clear which Jacobians does this notification message refer to. The test in question has a (very) large linear strong component, so it might be the case that this time is spent doing what Willi explained in comment:5. Willi, can you please confirm?

If this is the case, then it should not be switched off. However, it should definitely be made more efficient!

comment:15 by Francesco Casella, 9 years ago

Please note that in this case we know a priori that the system is index 1 and a fixed choice of states is just fine.

Can we possibly cut down the back-end time by setting stateSelect.always on the system states?

in reply to:  15 comment:16 by Willi Braun, 9 years ago

Replying to casella:

Sorry, let me focus back on the core issue: we have a test case in which we get:

Notification: Performance of SimCode generated analytical Jacobians: time 116.6/3279, GC stats:

It is not 100% clear which Jacobians does this notification message refer to. The test in question has a (very) large linear strong component, so it might be the case that this time is spent doing what Willi explained in comment:5. Willi, can you please confirm?

If this is the case, then it should not be switched off. However, it should definitely be made more efficient!

The point is that we use here execStat, what internal is a tick tock time measurements and in the whole simCode phase this is the only execStat. So that time is not meaningful at all, since it contains a lot of different things which are performed from the last tick in the Backend phase to this first tock in simCode phase.
I've just added https://github.com/wibraun/OMCompiler/tree/fixSimCodeExecStat some more significant time measurement statements in the simCode phase.
My guess is that we lose the time while we creating modelInfo and all the variables.

Replying to casella:

Please note that in this case we know a priori that the system is index 1 and a fixed choice of states is just fine.

Can we possibly cut down the back-end time by setting stateSelect.always on the system states?

If the system has clear states and the index reduction has no issue to detect that, than I think we don't lose any time on dynamic state selection at all, so I guess that is not the issue here.

comment:17 by Francesco Casella, 9 years ago

Resolution: fixed
Status: assignedclosed

OK. Given the information stated so far, I can close the ticket

comment:18 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: closedreopened

I'm going to set resolution to invalid, since there was nothing to fix.

comment:19 by Lennart Ochel, 9 years ago

Resolution: invalid
Status: reopenedclosed

comment:20 by Francesco Casella, 9 years ago

Thanks for pointing this out :)

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

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:22 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.