Skip to content

Commit

Permalink
Added TimingInfo struct to febiolib_types.h file.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMaas1978 committed Sep 12, 2024
1 parent a7cb50b commit 84e3a64
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 31 deletions.
56 changes: 33 additions & 23 deletions FEBioLib/FEBioModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,11 +1691,31 @@ bool FEBioModel::Reset()
return true;
}

TimingInfo FEBioModel::GetTimingInfo()
{
TimingInfo ti;
ti.total_time = 0.0;
ti.input_time = m_InputTime.GetTime(); ti.total_time += ti.input_time;
ti.init_time = m_InitTime .GetTime(); ti.total_time += ti.init_time;
ti.solve_time = GetTimer(TimerID::Timer_ModelSolve)->GetTime(); ti.total_time += ti.solve_time;

double sum = 0;
ti.io_time = m_IOTimer.GetTime(); sum += ti.io_time;
ti.total_linsol = GetTimer(TimerID::Timer_LinSolve )->GetTime(); sum += ti.total_linsol;
ti.total_reform = GetTimer(TimerID::Timer_Reform )->GetTime(); sum += ti.total_reform;
ti.total_stiff = GetTimer(TimerID::Timer_Stiffness)->GetTime(); sum += ti.total_stiff;
ti.total_rhs = GetTimer(TimerID::Timer_Residual )->GetTime(); sum += ti.total_rhs;
ti.total_update = GetTimer(TimerID::Timer_Update )->GetTime(); sum += ti.total_update;
ti.total_qn = GetTimer(TimerID::Timer_QNUpdate )->GetTime(); sum += ti.total_qn;
ti.total_other = ti.solve_time - sum;
return ti;
}


//=============================================================================
// S O L V E
//=============================================================================

//-----------------------------------------------------------------------------
void FEBioModel::on_cb_solved()
{
FEAnalysis* step = GetCurrentStep();
Expand Down Expand Up @@ -1741,30 +1761,20 @@ void FEBioModel::on_cb_solved()
Logfile::MODE old_mode = m_log.SetMode(Logfile::LOG_FILE);

// sum up all the times spend in the linear solvers
double total_time = 0.0;
double input_time = m_InputTime.GetTime(); total_time += input_time;
double init_time = m_InitTime .GetTime(); total_time += init_time;
double solve_time = GetTimer(TimerID::Timer_ModelSolve)->GetTime(); total_time += solve_time;
double io_time = m_IOTimer.GetTime();
double total_linsol = GetTimer(TimerID::Timer_LinSolve )->GetTime();
double total_reform = GetTimer(TimerID::Timer_Reform )->GetTime();
double total_stiff = GetTimer(TimerID::Timer_Stiffness)->GetTime();
double total_rhs = GetTimer(TimerID::Timer_Residual )->GetTime();
double total_update = GetTimer(TimerID::Timer_Update )->GetTime();
double total_qn = GetTimer(TimerID::Timer_QNUpdate )->GetTime();
TimingInfo ti = GetTimingInfo();

feLog(" T I M I N G I N F O R M A T I O N\n\n");
Timer::time_str(input_time , sztime); feLog("\tInput time ...................... : %s (%lg sec)\n\n", sztime, input_time);
Timer::time_str(init_time , sztime); feLog("\tInitialization time ............. : %s (%lg sec)\n\n", sztime, init_time);
Timer::time_str(solve_time , sztime); feLog("\tSolve time ...................... : %s (%lg sec)\n\n", sztime, solve_time);
Timer::time_str(io_time , sztime); feLog("\t IO-time (plot, dmp, data) .... : %s (%lg sec)\n\n", sztime, io_time);
Timer::time_str(total_reform, sztime); feLog("\t reforming stiffness .......... : %s (%lg sec)\n\n", sztime, total_reform);
Timer::time_str(total_stiff , sztime); feLog("\t evaluating stiffness ......... : %s (%lg sec)\n\n", sztime, total_stiff);
Timer::time_str(total_rhs , sztime); feLog("\t evaluating residual .......... : %s (%lg sec)\n\n", sztime, total_rhs);
Timer::time_str(total_update, sztime); feLog("\t model update ................. : %s (%lg sec)\n\n", sztime, total_update);
Timer::time_str(total_qn , sztime); feLog("\t QN updates ................... : %s (%lg sec)\n\n", sztime, total_qn);
Timer::time_str(total_linsol, sztime); feLog("\t time in linear solver ........ : %s (%lg sec)\n\n", sztime, total_linsol);
Timer::time_str(total_time , sztime); feLog("\tTotal elapsed time .............. : %s (%lg sec)\n\n", sztime, total_time);
Timer::time_str(ti.input_time , sztime); feLog("\tInput time ...................... : %s (%lg sec)\n\n", sztime, ti.input_time);
Timer::time_str(ti.init_time , sztime); feLog("\tInitialization time ............. : %s (%lg sec)\n\n", sztime, ti.init_time);
Timer::time_str(ti.solve_time , sztime); feLog("\tSolve time ...................... : %s (%lg sec)\n\n", sztime, ti.solve_time);
Timer::time_str(ti.io_time , sztime); feLog("\t IO-time (plot, dmp, data) .... : %s (%lg sec)\n\n", sztime, ti.io_time);
Timer::time_str(ti.total_reform, sztime); feLog("\t reforming stiffness .......... : %s (%lg sec)\n\n", sztime, ti.total_reform);
Timer::time_str(ti.total_stiff , sztime); feLog("\t evaluating stiffness ......... : %s (%lg sec)\n\n", sztime, ti.total_stiff);
Timer::time_str(ti.total_rhs , sztime); feLog("\t evaluating residual .......... : %s (%lg sec)\n\n", sztime, ti.total_rhs);
Timer::time_str(ti.total_update, sztime); feLog("\t model update ................. : %s (%lg sec)\n\n", sztime, ti.total_update);
Timer::time_str(ti.total_qn , sztime); feLog("\t QN updates ................... : %s (%lg sec)\n\n", sztime, ti.total_qn);
Timer::time_str(ti.total_linsol, sztime); feLog("\t time in linear solver ........ : %s (%lg sec)\n\n", sztime, ti.total_linsol);
Timer::time_str(ti.total_time , sztime); feLog("\tTotal elapsed time .............. : %s (%lg sec)\n\n", sztime, ti.total_time);

m_log.SetMode(old_mode);

Expand Down
11 changes: 3 additions & 8 deletions FEBioLib/FEBioModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SOFTWARE.*/
#include <FECore/FECoreKernel.h>
#include <FEBioLib/Logfile.h>
#include "febiolib_api.h"
#include "febiolib_types.h"

//-----------------------------------------------------------------------------
// Dump level determines the times the restart file is written
Expand All @@ -44,14 +45,6 @@ enum FE_Dump_Level {
FE_DUMP_MUST_POINTS // create a dump file only on must-points
};

//-----------------------------------------------------------------------------
struct ModelStats {
int ntimeSteps; //!< total nr of time steps
int ntotalIters; //!< total nr of equilibrium iterations
int ntotalRHS; //!< total nr of right hand side evaluations
int ntotalReforms; //!< total nr of stiffness reformations
};

//-----------------------------------------------------------------------------
//! The FEBio model specializes the FEModel class to implement FEBio specific
//! functionality.
Expand All @@ -73,6 +66,8 @@ class FEBIOLIB_API FEBioModel : public FEMechModel
//! Resets data structures
bool Reset() override;

TimingInfo GetTimingInfo();

public: // --- I/O functions ---

//! input data from file
Expand Down
49 changes: 49 additions & 0 deletions FEBioLib/febiolib_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once

struct ModelStats {
int ntimeSteps; //!< total nr of time steps
int ntotalIters; //!< total nr of equilibrium iterations
int ntotalRHS; //!< total nr of right hand side evaluations
int ntotalReforms; //!< total nr of stiffness reformations
};

struct TimingInfo {
double total_time;
double input_time;
double init_time;
double solve_time;
double io_time;
double total_linsol;
double total_reform;
double total_stiff;
double total_rhs;
double total_update;
double total_qn;
double total_other;
};

0 comments on commit 84e3a64

Please sign in to comment.