Skip to content
Snippets Groups Projects
Verified Commit d4c453c4 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

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.
parent a97a41f6
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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, it’s 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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment