In the performance testing I've done so far, a large fraction of CPU time is spent in the sCKT::terr() function (in wrspice/src/ckt/ckt.cc). It can consume as much as a quarter of the total runtime.
Most of the time spent in the function is spent executing a number of tight loops, from the line "// Now divided differences" to the closing brace at the end of the "for (;;)" loop. These loops are entirely controlled by the value of CKTorder, which (as far as I can tell) is always 2 (or occasionally 1). It's therefore possible to unroll the loops for selected cases of CKTorder, leading to code like:
switch (CKTorder) {
case 1:
diff[2] = *(CKTstates[2] + qcap);
diff[1] = *(CKTstates[1] + qcap);
// ...
break;
case 2:
// ...
}
This results in an appreciable performance gain...
In the performance testing I've done so far, a large fraction of CPU time is spent in the sCKT::terr() function (in wrspice/src/ckt/ckt.cc). It can consume as much as a quarter of the total runtime.
Most of the time spent in the function is spent executing a number of tight loops, from the line "// Now divided differences" to the closing brace at the end of the "for (;;)" loop. These loops are entirely controlled by the value of CKTorder, which (as far as I can tell) is always 2 (or occasionally 1). It's therefore possible to unroll the loops for selected cases of CKTorder, leading to code like: