Skip to content

Commit

Permalink
Convert AdvancedTimer timers to macro to support Tracy (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored Jan 16, 2024
1 parent 45fe928 commit 40ed0c6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const MechanicalParams*
const DataVecCoord& datax,
const DataVecDeriv& v)
{
ScopedAdvancedTimer timer("AdaptiveBeamForceFieldAndMass_addForce");
SCOPED_TIMER("AdaptiveBeamForceFieldAndMass_addForce");
SOFA_UNUSED(v);

auto f = sofa::helper::getWriteOnlyAccessor(dataf);
Expand Down
22 changes: 10 additions & 12 deletions src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <sofa/core/visual/VisualParams.h>

#include <sofa/simulation/AnimateBeginEvent.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
#include <sofa/core/ConstraintParams.h>
#include <sofa/core/MechanicalParams.h>
Expand Down Expand Up @@ -202,23 +201,23 @@ void AdaptiveBeamMapping< TIn, TOut>::clear(int size)
template <class TIn, class TOut>
void AdaptiveBeamMapping< TIn, TOut>::apply(const MechanicalParams* mparams, Data<VecCoord>& dOut, const Data<InVecCoord>& dIn)
{
ScopedAdvancedTimer timer("AdaptiveBeamMapping_Apply");
SCOPED_TIMER("AdaptiveBeamMapping_Apply");

auto out = sofa::helper::getWriteOnlyAccessor(dOut);
const InVecCoord& in = dIn.getValue();

m_isXBufferUsed=false;

AdvancedTimer::stepBegin("pointsRedistribution");
// When using an adaptatif controller, one need to redistribute the points at each time step
if (d_useCurvAbs.getValue() && !d_contactDuplicate.getValue())
computeDistribution();

AdvancedTimer::stepEnd("pointsRedistribution");
{
SCOPED_TIMER("computeDistribution");
if (d_useCurvAbs.getValue() && !d_contactDuplicate.getValue())
computeDistribution();
}

AdvancedTimer::stepBegin("resizeToModel&Out");
if (!m_isSubMapping)
{
SCOPED_TIMER("resizeToModel&Out");
if (d_nbPointsPerBeam.getValue() > 0)
{
this->toModel->resize(m_pointBeamDistribution.size());
Expand All @@ -230,7 +229,6 @@ void AdaptiveBeamMapping< TIn, TOut>::apply(const MechanicalParams* mparams, Dat
out.resize(d_points.getValue().size());
}
}
AdvancedTimer::stepEnd("resizeToModel&Out");

MultiVecCoordId x = VecCoordId::position();
MultiVecCoordId xfree = VecCoordId::freePosition();
Expand Down Expand Up @@ -293,7 +291,7 @@ template <class TIn, class TOut>
void AdaptiveBeamMapping< TIn, TOut>::applyJ(const core::MechanicalParams* mparams, Data<VecDeriv>& dOut, const Data<InVecDeriv>& dIn)
{
SOFA_UNUSED(mparams);
ScopedAdvancedTimer timer("AdaptiveBeamMapping_applyJ");
SCOPED_TIMER("AdaptiveBeamMapping_applyJ");

auto out = sofa::helper::getWriteOnlyAccessor(dOut);
const InVecDeriv& in= dIn.getValue();
Expand Down Expand Up @@ -379,7 +377,7 @@ void AdaptiveBeamMapping< TIn, TOut>::applyJT(const core::MechanicalParams* mpar
{
SOFA_UNUSED(mparams);

ScopedAdvancedTimer timer("AdaptiveBeamMapping_applyJT");
SCOPED_TIMER("AdaptiveBeamMapping_applyJT");
auto out = sofa::helper::getWriteOnlyAccessor(dOut);
const VecDeriv& in= dIn.getValue();

Expand Down Expand Up @@ -422,7 +420,7 @@ void AdaptiveBeamMapping< TIn, TOut>::applyJT(const core::ConstraintParams* cpar
{
SOFA_UNUSED(cparams);

ScopedAdvancedTimer timer("AdaptiveBeamMapping_ApplyJT");
SCOPED_TIMER("AdaptiveBeamMapping_ApplyJT");
auto out = sofa::helper::getWriteOnlyAccessor(dOut);
const OutMatrixDeriv& in = dIn.getValue();
const Data<InVecCoord>& dataInX = *this->getFromModel()->read(ConstVecCoordId::position());
Expand Down
10 changes: 4 additions & 6 deletions src/BeamAdapter/component/mapping/BeamLengthMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <sofa/core/visual/VisualParams.h>

#include <sofa/simulation/AnimateBeginEvent.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/core/MechanicalParams.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
#include <iomanip>
Expand All @@ -64,7 +63,6 @@ using sofa::core::State;
using helper::ReadAccessor;
using helper::WriteAccessor;
using sofa::core::ConstVecCoordId;
using sofa::helper::AdvancedTimer;
using sofa::core::MultiVecCoordId;
using sofa::core::VecCoordId;
using sofa::core::VecDerivId;
Expand Down Expand Up @@ -124,7 +122,7 @@ void BeamLengthMapping< TIn, TOut>::reset()
template <class TIn, class TOut>
void BeamLengthMapping< TIn, TOut>::apply(const MechanicalParams* mparams, Data<VecCoord>& dOut, const Data<InVecCoord>& dIn)
{
sofa::helper::ScopedAdvancedTimer timer("AdaptiveBeamMappingApply");
SCOPED_TIMER("AdaptiveBeamMappingApply");

VecCoord& out = *dOut.beginEdit();
const InVecCoord& in = dIn.getValue();
Expand Down Expand Up @@ -157,7 +155,7 @@ void BeamLengthMapping< TIn, TOut>::applyJ(const core::MechanicalParams* mparams
{
SOFA_UNUSED(mparams);

sofa::helper::ScopedAdvancedTimer timer("AdaptiveBeamMappingApplyJ");
SCOPED_TIMER("AdaptiveBeamMappingApplyJ");

VecDeriv& out = *dOut.beginEdit();
const InVecDeriv& in= dIn.getValue();
Expand Down Expand Up @@ -230,7 +228,7 @@ void BeamLengthMapping< TIn, TOut>::applyJT(const core::MechanicalParams* mparam
{
SOFA_UNUSED(mparams);

sofa::helper::ScopedAdvancedTimer timer("AdaptiveBeamMappingMechanicalApplyJT");
SCOPED_TIMER("AdaptiveBeamMappingMechanicalApplyJT");
InVecDeriv& out = *dOut.beginEdit();
const VecDeriv& in= dIn.getValue();

Expand Down Expand Up @@ -344,7 +342,7 @@ void BeamLengthMapping< TIn, TOut>::applyJT(const core::ConstraintParams* cparam
{
SOFA_UNUSED(cparams);

sofa::helper::ScopedAdvancedTimer timer("AdaptiveBeamMappingConstrainApplyJT");
SCOPED_TIMER("AdaptiveBeamMappingConstrainApplyJT");

InMatrixDeriv& out = *dOut.beginEdit();
const OutMatrixDeriv& in = dIn.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <sofa/core/visual/VisualParams.h>
#include <sofa/core/behavior/MechanicalState.h>
#include <sofa/core/visual/VisualParams.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/core/objectmodel/BaseContext.h>
#include <sofa/helper/logging/Message.h>
#include <sofa/type/RGBAColor.h>
Expand All @@ -43,7 +42,6 @@
namespace beamadapter::mapping
{
using sofa::core::objectmodel::BaseContext ;
using sofa::helper::AdvancedTimer;
using sofa::helper::WriteAccessor;
using sofa::type::RGBAColor ;
using sofa::core::objectmodel::ComponentState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MultiAdaptiveBeamMapping< TIn, TOut>::MultiAdaptiveBeamMapping()
template <class TIn, class TOut>
void MultiAdaptiveBeamMapping< TIn, TOut>::apply(const core::MechanicalParams* mparams /* PARAMS FIRST */, Data<VecCoord>& dOut, const Data<InVecCoord>& dIn)
{
ScopedAdvancedTimer timer("MultiAdaptiveBeamMapping_apply");
SCOPED_TIMER("MultiAdaptiveBeamMapping_apply");

auto out = sofa::helper::getWriteOnlyAccessor(dOut);
if(!isBarycentricMapping)
Expand All @@ -96,7 +96,7 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::apply(const core::MechanicalParams* m
template <class TIn, class TOut>
void MultiAdaptiveBeamMapping< TIn, TOut>::applyJ(const core::MechanicalParams* mparams /* PARAMS FIRST */, Data<VecDeriv>& dOut, const Data<InVecDeriv>& dIn)
{
ScopedAdvancedTimer timer("MultiAdaptiveBeamMapping_applyJ");
SCOPED_TIMER("MultiAdaptiveBeamMapping_applyJ");

for (unsigned int subMap=0; subMap<m_subMappingList.size(); subMap++)
{
Expand All @@ -110,7 +110,7 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::applyJ(const core::MechanicalParams*
template <class TIn, class TOut>
void MultiAdaptiveBeamMapping< TIn, TOut>::applyJT(const core::MechanicalParams* mparams /* PARAMS FIRST */, Data<InVecDeriv>& dOut, const Data<VecDeriv>& dIn)
{
ScopedAdvancedTimer timer("MultiAdaptiveBeamMapping_applyJT");
SCOPED_TIMER("MultiAdaptiveBeamMapping_applyJT");

for (unsigned int subMap=0; subMap<m_subMappingList.size(); subMap++)
{
Expand All @@ -131,7 +131,7 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::applyJT(const core::MechanicalParams*
template <class TIn, class TOut>
void MultiAdaptiveBeamMapping< TIn, TOut>::applyJT(const core::ConstraintParams* cparams /* PARAMS FIRST */, Data<InMatrixDeriv>& dOut, const Data<OutMatrixDeriv>& dIn)
{
ScopedAdvancedTimer timer("MultiAdaptiveBeamMapping_applyJT");
SCOPED_TIMER("MultiAdaptiveBeamMapping_applyJT");

for (unsigned int subMap=0; subMap<m_subMappingList.size(); subMap++)
{
Expand Down

0 comments on commit 40ed0c6

Please sign in to comment.