perf(allocations): reduced overall allocations by 95%, increaseed jacobian applicatin by 2x
This commit uses global pre allocated work space to dramatically reduce memory usage and allocation time
This commit is contained in:
21
sandbox.cpp
21
sandbox.cpp
@@ -77,10 +77,11 @@ int main(
|
||||
|
||||
constexpr double radius = utils::RADIUS;
|
||||
constexpr double mass = utils::MASS;
|
||||
constexpr double angularMomentum = 0.05;
|
||||
constexpr double angularMomentum = 0.1;
|
||||
constexpr double gravitationalConstant = utils::G;
|
||||
const double polytropicConstant =
|
||||
2.0 * gravitationalConstant * radius * radius / std::numbers::pi_v<double>;
|
||||
std::println("K = {}", polytropicConstant);
|
||||
const double centralDensity =
|
||||
std::numbers::pi_v<double> * mass / (4.0 * radius * radius * radius);
|
||||
|
||||
@@ -105,7 +106,7 @@ int main(
|
||||
);
|
||||
|
||||
auto preconditioner = preconditioning::makePreconditioner();
|
||||
auto linearSolver = solver::linear::FGMRES({.restartLength = 40, .printLevel = -1});
|
||||
auto linearSolver = solver::linear::FGMRES({.restartLength = 40, .printLevel = 1});
|
||||
const auto contextStart = std::chrono::steady_clock::now();
|
||||
auto context = solver::makeContext(
|
||||
std::move(stellarModel), std::move(discretization), std::move(preconditioner), std::move(linearSolver)
|
||||
@@ -149,6 +150,18 @@ int main(
|
||||
int rank = 0;
|
||||
MPI_Comm_rank(event.communicator, &rank);
|
||||
if (rank == 0) {
|
||||
if (event.geometryPreflight.has_value()) {
|
||||
const auto &geometry = *event.geometryPreflight;
|
||||
std::cout << " geometry preflight = " << event.geometryPreflightSeconds
|
||||
<< " s, samples = " << geometry.sampledQuadraturePointCount;
|
||||
if (geometry.limitedByGeometry) {
|
||||
std::cout << ", safe step = " << geometry.stepSize
|
||||
<< ", boundary = " << geometry.boundaryStepSize
|
||||
<< ", limiting rank = " << geometry.limitingRank
|
||||
<< ", element = " << geometry.limitingElement;
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
std::cout << " step = " << event.acceptedStepLength
|
||||
<< ", trials = " << event.lineSearchTrials
|
||||
<< ", |F| = " << event.residualNorm
|
||||
@@ -200,11 +213,13 @@ int main(
|
||||
<< " s\n";
|
||||
const auto &diagnostics = report.diagnostics();
|
||||
std::cout << "Totals: linear = " << diagnostics.totalLinearSolveSeconds
|
||||
<< " s, geometry preflight = " << diagnostics.totalGeometryPreflightSeconds
|
||||
<< " s, line search = " << diagnostics.totalLineSearchSeconds
|
||||
<< " s, trial preparation = " << diagnostics.totalTrialPreparationSeconds
|
||||
<< " s, accepted refresh = " << diagnostics.totalPreconditionerRefreshSeconds
|
||||
<< " s, rollback = " << diagnostics.totalRollbackSeconds
|
||||
<< " s, inadmissible trials = " << diagnostics.inadmissibleLineSearchTrials
|
||||
<< " s, geometry-limited iterations = " << diagnostics.geometryLimitedIterations
|
||||
<< ", inadmissible trials = " << diagnostics.inadmissibleLineSearchTrials
|
||||
<< ", non-finite trials = " << diagnostics.nonFiniteLineSearchTrials
|
||||
<< ", insufficient-decrease trials = " << diagnostics.insufficientDecreaseTrials << '\n';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user