From c788c525ea04cf8dc66ece6b72766d5a31f5208f Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 23 Jul 2013 18:34:23 +0000 Subject: [PATCH] Added timing statements in new code --- gtsam/inference/EliminateableFactorGraph-inst.h | 5 +++++ gtsam/inference/EliminationTreeUnordered-inst.h | 3 ++- gtsam/inference/JunctionTree-inl.h | 1 + gtsam/inference/JunctionTreeUnordered-inst.h | 3 ++- gtsam/inference/VariableSlots.h | 4 +++- gtsam/linear/GaussianBayesTreeUnordered.cpp | 1 + gtsam/linear/GaussianFactorGraphUnordered.cpp | 1 + gtsam/linear/GaussianMultifrontalSolver.cpp | 3 +-- gtsam/linear/JacobianFactorUnordered.cpp | 3 +++ 9 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gtsam/inference/EliminateableFactorGraph-inst.h b/gtsam/inference/EliminateableFactorGraph-inst.h index 7064169f1..88546c5cc 100644 --- a/gtsam/inference/EliminateableFactorGraph-inst.h +++ b/gtsam/inference/EliminateableFactorGraph-inst.h @@ -30,6 +30,7 @@ namespace gtsam { OptionalOrdering ordering, const Eliminate& function, OptionalVariableIndex variableIndex) const { if(ordering && variableIndex) { + gttic(eliminateSequential); // Do elimination std::pair, boost::shared_ptr > result = EliminationTreeType(asDerived(), *variableIndex, *ordering).eliminate(function); @@ -60,6 +61,7 @@ namespace gtsam { OptionalOrdering ordering, const Eliminate& function, OptionalVariableIndex variableIndex) const { if(ordering && variableIndex) { + gttic(eliminateMultifrontal); // Do elimination with given ordering std::pair, boost::shared_ptr > result = JunctionTreeType(EliminationTreeType(asDerived(), *variableIndex, *ordering)).eliminate(function); @@ -90,6 +92,7 @@ namespace gtsam { const OrderingUnordered& ordering, const Eliminate& function, OptionalVariableIndex variableIndex) const { if(variableIndex) { + gttic(eliminatePartialSequential); // Do elimination return EliminationTreeType(asDerived(), *variableIndex, ordering).eliminate(function); } else { @@ -105,6 +108,7 @@ namespace gtsam { const OrderingUnordered& ordering, const Eliminate& function, OptionalVariableIndex variableIndex) const { if(variableIndex) { + gttic(eliminatePartialMultifrontal); // Do elimination return JunctionTreeType(EliminationTreeType(asDerived(), *variableIndex, ordering)).eliminate(function); } else { @@ -126,6 +130,7 @@ namespace gtsam { { if(marginalizedVariableOrdering) { + gttic(marginalMultifrontalBayesNet); // An ordering was provided for the marginalized variables, so we can first eliminate them // in the order requested. std::pair, boost::shared_ptr > eliminated = diff --git a/gtsam/inference/EliminationTreeUnordered-inst.h b/gtsam/inference/EliminationTreeUnordered-inst.h index e0116d4fd..acb62d6cc 100644 --- a/gtsam/inference/EliminationTreeUnordered-inst.h +++ b/gtsam/inference/EliminationTreeUnordered-inst.h @@ -80,7 +80,7 @@ namespace gtsam { EliminationTreeUnordered::EliminationTreeUnordered(const FactorGraphType& graph, const VariableIndexUnordered& structure, const OrderingUnordered& order) { - gttic(ET_Create1); + gttic(EliminationTree_Contructor); // Number of factors and variables - NOTE in the case of partial elimination, n here may // be fewer variables than are actually present in the graph. @@ -187,6 +187,7 @@ namespace gtsam { std::pair, boost::shared_ptr > EliminationTreeUnordered::eliminate(Eliminate function) const { + gttic(EliminationTree_eliminate); // Allocate result boost::shared_ptr result = boost::make_shared(); diff --git a/gtsam/inference/JunctionTree-inl.h b/gtsam/inference/JunctionTree-inl.h index 850195f24..7a790875b 100644 --- a/gtsam/inference/JunctionTree-inl.h +++ b/gtsam/inference/JunctionTree-inl.h @@ -31,6 +31,7 @@ namespace gtsam { /* ************************************************************************* */ template void JunctionTree::construct(const FG& fg, const VariableIndex& variableIndex) { + gttic(JT_construct); gttic(JT_symbolic_ET); const typename EliminationTree::shared_ptr symETree = EliminationTree::Create(fg, variableIndex); diff --git a/gtsam/inference/JunctionTreeUnordered-inst.h b/gtsam/inference/JunctionTreeUnordered-inst.h index 5b8c7aafb..898792e31 100644 --- a/gtsam/inference/JunctionTreeUnordered-inst.h +++ b/gtsam/inference/JunctionTreeUnordered-inst.h @@ -195,6 +195,7 @@ namespace gtsam { JunctionTreeUnordered JunctionTreeUnordered::FromEliminationTree(const ETREE& eliminationTree) { + gttic(JunctionTree_FromEliminationTree); // Here we rely on the BayesNet having been produced by this elimination tree, such that the // conditionals are arranged in DFS post-order. We traverse the elimination tree, and inspect // the symbolic conditional corresponding to each node. The elimination tree node is added to @@ -238,7 +239,7 @@ namespace gtsam { std::pair, boost::shared_ptr > JunctionTreeUnordered::eliminate(const Eliminate& function) const { - gttic(JunctionTreeUnordered_eliminate); + gttic(JunctionTree_eliminate); // Do elimination (depth-first traversal). The rootsContainer stores a 'dummy' BayesTree node // that contains all of the roots as its children. rootsContainer also stores the remaining // uneliminated factors passed up from the roots. diff --git a/gtsam/inference/VariableSlots.h b/gtsam/inference/VariableSlots.h index ccef55296..b13e5ebb1 100644 --- a/gtsam/inference/VariableSlots.h +++ b/gtsam/inference/VariableSlots.h @@ -84,7 +84,9 @@ public: /* ************************************************************************* */ template -VariableSlots::VariableSlots(const FG& factorGraph) { +VariableSlots::VariableSlots(const FG& factorGraph) +{ + gttic(VariableSlots_constructor); static const bool debug = false; // Compute a mapping (called variableSlots) *from* each involved diff --git a/gtsam/linear/GaussianBayesTreeUnordered.cpp b/gtsam/linear/GaussianBayesTreeUnordered.cpp index 42cd08b22..641385c94 100644 --- a/gtsam/linear/GaussianBayesTreeUnordered.cpp +++ b/gtsam/linear/GaussianBayesTreeUnordered.cpp @@ -109,6 +109,7 @@ namespace gtsam { /* ************************************************************************* */ VectorValuesUnordered GaussianBayesTreeUnordered::optimize() const { + gttic(GaussianBayesTree_optimize); internal::OptimizeData rootData; // Will hold final solution treeTraversal::DepthFirstForest(*this, rootData, internal::OptimizePreVisitor, internal::OptimizePostVisitor); return rootData.results; diff --git a/gtsam/linear/GaussianFactorGraphUnordered.cpp b/gtsam/linear/GaussianFactorGraphUnordered.cpp index b6bffee58..902b6cf28 100644 --- a/gtsam/linear/GaussianFactorGraphUnordered.cpp +++ b/gtsam/linear/GaussianFactorGraphUnordered.cpp @@ -198,6 +198,7 @@ namespace gtsam { /* ************************************************************************* */ VectorValuesUnordered GaussianFactorGraphUnordered::optimize(const Eliminate& function) const { + gttic(GaussianFactorGraph_optimize); return BaseEliminateable::eliminateMultifrontal(boost::none, function)->optimize(); } diff --git a/gtsam/linear/GaussianMultifrontalSolver.cpp b/gtsam/linear/GaussianMultifrontalSolver.cpp index af4fe90ec..22d352f2c 100644 --- a/gtsam/linear/GaussianMultifrontalSolver.cpp +++ b/gtsam/linear/GaussianMultifrontalSolver.cpp @@ -50,13 +50,12 @@ GaussianBayesTree::shared_ptr GaussianMultifrontalSolver::eliminate() const { /* ************************************************************************* */ VectorValues::shared_ptr GaussianMultifrontalSolver::optimize() const { - gttic(optimize); + gttic(GaussianMultifrontalSolver_optimize); VectorValues::shared_ptr values; if (useQR_) values = VectorValues::shared_ptr(new VectorValues(junctionTree_->optimize(&EliminateQR))); else values= VectorValues::shared_ptr(new VectorValues(junctionTree_->optimize(&EliminatePreferCholesky))); - gttoc(optimize); return values; } diff --git a/gtsam/linear/JacobianFactorUnordered.cpp b/gtsam/linear/JacobianFactorUnordered.cpp index 28c419a86..6c14700ab 100644 --- a/gtsam/linear/JacobianFactorUnordered.cpp +++ b/gtsam/linear/JacobianFactorUnordered.cpp @@ -218,6 +218,7 @@ namespace gtsam { // Cast or convert to Jacobians std::vector jacobians = _convertOrCastToJacobians(graph); + gttic(Order_slots); // Order variable slots - we maintain the vector of ordered slots, as well as keep a list // 'unorderedSlots' of any variables discovered that are not in the ordering. Those will then // be added after all of the ordered variables. @@ -252,6 +253,7 @@ namespace gtsam { for(VariableSlots::const_iterator item = variableSlots->begin(); item != variableSlots->end(); ++item) orderedSlots.push_back(item); } + gttoc(Order_slots); // Count dimensions vector varDims; @@ -497,6 +499,7 @@ namespace gtsam { std::pair, boost::shared_ptr > EliminateQRUnordered(const GaussianFactorGraphUnordered& factors, const OrderingUnordered& keys) { + gttic(EliminateQRUnordered); // Combine and sort variable blocks in elimination order JacobianFactorUnordered::shared_ptr jointFactor; try {