Skip to content

Commit 640d11e

Browse files
th-skamepernod
andauthored
[algorithm] Add AdvancedTimer calls for profiling in hot stages of the algorithm (#99)
* [algorithm] Remove projection operation on tip in the InsertionAlgorithm- completely unnecessary * [algorithm] Changed FindClosestProximityAlgorithm to find the closest proximity back on the from geometry * [algorithm] Auto-format code * [algorithm] Rewrite some comments * [algorithm] Place shared operations at the top * [algorithm] Add a bool to enable/disable the puncture sequence * [algorithm] Add a bool to enable/disable insertion sequence * [algorithm] Add a bool to enable/disable shaft collision sequence * [algorithm] auto format code * [algorithm] Absorb the FindClosestProximity for shaft collision * [algorithm] Add an experimental component in the algorithm * [algorithm] Remove FindClosestProximityAlgorithm * [cmake] Remove FindClosestProximityAlgorithm from CMakeLists * [algorithm] Make sanity checks happen only when appropriate for some data * [algorithm] Place geometry checks in InsertionAlgorithm when they make sense * [timer] Add the name of the AABBBroadPhase component during profiling * [timer] Add a timer to the doDetection function * [timer] Add a timer inside the doUpdate broadphase function * [timer] Add advanced timers in the InsertionAlgorithm --------- Co-authored-by: epernod <erik.pernod@gmail.com>
1 parent aa7174d commit 640d11e

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/CollisionAlgorithm/BaseAABBBroadPhase.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ class SOFA_COLLISIONALGORITHM_API BaseAABBBroadPhase : public BaseGeometry::Broa
6161
}
6262

6363
inline void doUpdate() {
64-
sofa::helper::AdvancedTimer::stepBegin("========================= AABBBroadPhase do update =========================");
64+
sofa::helper::AdvancedTimer::stepBegin("AABBBroadPhase::doUpdate - "+this->getName());
6565
m_Bmin = l_geometry->getPosition(0);
6666
m_Bmax = m_Bmin;
6767

6868
//updates bounding box area
69-
// sofa::helper::AdvancedTimer::stepBegin("========================= BBox area update in AABBBroadPhase do update =========================");
69+
sofa::helper::AdvancedTimer::stepBegin("AABBBroadPhase BBox area update - "+this->getName());
7070
for (unsigned j=1;j<l_geometry->getSize();j++) {
7171
type::Vec3 pos = l_geometry->getPosition(j);
7272

@@ -78,7 +78,7 @@ class SOFA_COLLISIONALGORITHM_API BaseAABBBroadPhase : public BaseGeometry::Broa
7878
}
7979

8080
}
81-
// sofa::helper::AdvancedTimer::stepEnd("========================= BBox area update in AABBBroadPhase do update =========================");
81+
sofa::helper::AdvancedTimer::stepEnd("AABBBroadPhase BBox area update - "+this->getName());
8282

8383
//fixes cell size
8484
for (int i = 0 ; i < 3 ; i++) {
@@ -98,9 +98,9 @@ class SOFA_COLLISIONALGORITHM_API BaseAABBBroadPhase : public BaseGeometry::Broa
9898
}
9999
}
100100

101-
// sofa::helper::AdvancedTimer::stepBegin("========================= CLEAR MAP =========================");
101+
sofa::helper::AdvancedTimer::stepBegin("AABBBroadPhase clear map - "+this->getName());
102102
newContainer();
103-
// sofa::helper::AdvancedTimer::stepEnd("========================= CLEAR MAP =========================");
103+
sofa::helper::AdvancedTimer::stepEnd("AABBBroadPhase clear map - "+this->getName());
104104

105105
// center in -0.5 cellwidth
106106
m_Bmin -= m_cellSize * 0.5;
@@ -112,11 +112,11 @@ class SOFA_COLLISIONALGORITHM_API BaseAABBBroadPhase : public BaseGeometry::Broa
112112
return;
113113
}
114114

115-
// sofa::helper::AdvancedTimer::stepBegin("========================= Elements rangés dans boites in AABB doUpdate =========================");
115+
sofa::helper::AdvancedTimer::stepBegin("AABBBroadPhase updateElemInBoxes - " + this->getName());
116116
updateElemInBoxes();
117+
sofa::helper::AdvancedTimer::stepEnd("AABBBroadPhase updateElemInBoxes - " + this->getName());
117118

118-
// sofa::helper::AdvancedTimer::stepEnd("========================= Elements rangés dans boites in AABB doUpdate =========================");
119-
sofa::helper::AdvancedTimer::stepEnd("========================= AABBBroadPhase do update =========================");
119+
sofa::helper::AdvancedTimer::stepEnd("AABBBroadPhase::doUpdate - "+this->getName());
120120
}
121121

122122

src/CollisionAlgorithm/CollisionPipeline.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ class SOFA_COLLISIONALGORITHM_API CollisionLoop : public core::objectmodel::Base
6666

6767
void processObject(simulation::Node*, core::objectmodel::BaseObject* obj) {
6868
if (CollisionAlgorithm * component = dynamic_cast<CollisionAlgorithm *>(obj)) {
69-
// std::string timerName = std::string("-- Do detection : ") + obj->getName();
70-
71-
// sofa::helper::AdvancedTimer::stepBegin(timerName.c_str());
69+
sofa::helper::AdvancedTimer::stepBegin("doDetection - "+obj->getName());
7270
component->doDetection();
73-
// sofa::helper::AdvancedTimer::stepEnd(timerName.c_str());
71+
sofa::helper::AdvancedTimer::stepEnd("doDetection - "+obj->getName());
7472
}
7573
}
7674

src/CollisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class SOFA_COLLISIONALGORITHM_API InsertionAlgorithm : public BaseAlgorithm
139139
if (m_couplingPts.empty() && l_surfGeom)
140140
{
141141
// Operations on surface geometry
142+
sofa::helper::AdvancedTimer::stepBegin("Puncture detection - "+this->getName());
143+
142144
auto findClosestProxOnSurf =
143145
Operations::FindClosestProximity::Operation::get(l_surfGeom);
144146
auto projectOnSurf = Operations::Project::Operation::get(l_surfGeom);
@@ -185,8 +187,11 @@ class SOFA_COLLISIONALGORITHM_API InsertionAlgorithm : public BaseAlgorithm
185187
}
186188
}
187189
}
190+
sofa::helper::AdvancedTimer::stepEnd("Puncture detection - "+this->getName());
188191

189192
// Shaft collision sequence - Disable if coupling points have been added
193+
sofa::helper::AdvancedTimer::stepBegin("Shaft collision - "+this->getName());
194+
190195
if (d_enableShaftCollision.getValue() && m_couplingPts.empty() && l_shaftGeom)
191196
{
192197
auto createShaftProximity =
@@ -220,10 +225,13 @@ class SOFA_COLLISIONALGORITHM_API InsertionAlgorithm : public BaseAlgorithm
220225
}
221226
}
222227
}
228+
sofa::helper::AdvancedTimer::stepEnd("Shaft collision - "+this->getName());
223229
}
224230
else
225231
{
226232
// Insertion sequence
233+
sofa::helper::AdvancedTimer::stepBegin("Needle insertion - " + this->getName());
234+
227235
if (!d_enableInsertion.getValue() || !l_tipGeom || !l_volGeom || !l_shaftGeom) return;
228236

229237
ElementIterator::SPtr itTip = l_tipGeom->begin();
@@ -322,8 +330,11 @@ class SOFA_COLLISIONALGORITHM_API InsertionAlgorithm : public BaseAlgorithm
322330
Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo());
323331
prunePointsAheadOfTip(m_couplingPts, itShaft->element());
324332
}
333+
sofa::helper::AdvancedTimer::stepEnd("Needle insertion - " + this->getName());
325334
}
326335

336+
sofa::helper::AdvancedTimer::stepBegin("Reproject coupling points - "+this->getName());
337+
327338
if (d_enableInsertion.getValue() && !m_couplingPts.empty() && l_shaftGeom)
328339
{
329340
// Reprojection on shaft geometry sequence
@@ -343,6 +354,7 @@ class SOFA_COLLISIONALGORITHM_API InsertionAlgorithm : public BaseAlgorithm
343354
// because the needle has exited abruptly. Thus, we clear the coupling points.
344355
if (insertionOutput.size() == 0) m_couplingPts.clear();
345356
}
357+
sofa::helper::AdvancedTimer::stepEnd("Reproject coupling points - "+this->getName());
346358

347359
d_collisionOutput.endEdit();
348360
d_insertionOutput.endEdit();

0 commit comments

Comments
 (0)