Block decomposition: (likely) performance improvement in static file in relation to temp terms

Compute temporary terms for derivatives of “evaluate” mode, even though those
derivatives are not computed. This is because the temporary terms may be useful
for subsequent blocks.

By the way, add an explanatory comment for the equivalent code in dynamic file.
master
Sébastien Villemot 2022-07-21 17:30:03 +02:00
parent a97a41f6c0
commit d4c453c422
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 15 additions and 4 deletions

View File

@ -740,7 +740,11 @@ DynamicModel::writeDynamicPerBlockHelper(int blk, ostream &output, temporary_ter
// The Jacobian if we have to solve the block
// Write temporary terms for derivatives
/* Write temporary terms for derivatives.
Also note that in the case of evaluate blocks, derivatives are not
computed in deterministic mode; still their temporary terms must be
computed even in that mode, because they may be needed in subsequent
blocks. */
write_eq_tt(blocks[blk].size);
if constexpr(isCOutput(output_type))

View File

@ -243,13 +243,20 @@ StaticModel::writeStaticPerBlockHelper(int blk, ostream &output, temporary_terms
exit(EXIT_FAILURE);
}
}
/* Write temporary terms for derivatives.
This is done even for evaluate blocks, whose derivatives are not
computed at runtime; still those temporary terms may be needed by
subsequent blocks (not calling write_eq_tt() would not be a bug though,
because those terms would not be added to temporary_terms_union and would
therefore not be used; still, its probably better performance-wise to
use those temporary terms). */
write_eq_tt(blocks[blk].size);
// The Jacobian if we have to solve the block
if (simulation_type != BlockSimulationType::evaluateBackward
&& simulation_type != BlockSimulationType::evaluateForward)
{
// Write temporary terms for derivatives
write_eq_tt(blocks[blk].size);
ostringstream i_output, j_output, v_output;
for (int line_counter { ARRAY_SUBSCRIPT_OFFSET(output_type) };
const auto &[indices, d] : blocks_derivatives[blk])