Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions doc/modules/changes/20250916_gassmoeller

This file was deleted.

46 changes: 46 additions & 0 deletions include/aspect/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <deal.II/base/config.h>
#include <deal.II/base/mpi.h>
#include <deal.II/base/timer.h>

// C++11 related includes.
#include <functional>
Expand Down Expand Up @@ -444,6 +445,51 @@ namespace aspect
const double outer_radius);
#endif


/**
* A replacement class for TimerOutput::Scope that should avoid
* the deadlocking issues we have had for the latter.
*
* This class is modeled after the pattern used in deal.II's
* TimerOutput::Scope class but really just calls TimerOutput::enter_scope()
* in the constructor and TimerOutput::leave_scope() in the destructor whereas
* TimerOutput::Scope also checks whether there are pending exceptions
* in the destructor and only calls leave_scope() if there are not.
*/
class TimerScope
{
public:
/**
* Constructor that calls TimerOutput::enter_scope() with the given scope name.
*/
TimerScope(dealii::TimerOutput &timer_,
const std::string &section_name_)
: timer(timer_)
, section_name(section_name_)
{
timer.enter_subsection(section_name);
}

/**
* Destructor that calls TimerOutput::leave_scope().
*/
~TimerScope()
{
timer.leave_subsection(section_name);
}

private:
/**
* Reference to the TimerOutput object
*/
dealii::TimerOutput &timer;

/**
* Name of the section we need to exit
*/
const std::string section_name;
};

}

#endif
7 changes: 3 additions & 4 deletions source/mesh_deformation/fastscape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ namespace aspect
if (this->get_timestep_number() == 0)
return;

this->get_computing_timer().enter_subsection("FastScape plugin");
TimerScope timer_section(this->get_computing_timer(), "FastScape plugin");

const unsigned int current_timestep = this->get_timestep_number ();
const double aspect_timestep_in_years = this->get_timestep() / year_in_seconds;
Expand Down Expand Up @@ -890,7 +890,8 @@ namespace aspect
Assert (Utilities::MPI::this_mpi_process(this->get_mpi_communicator()) == 0,
ExcInternalError());

this->get_computing_timer().enter_subsection("Execute FastScape");

TimerScope timer_section(this->get_computing_timer(), "Execute FastScape");

// Because on the first timestep we will create an initial VTK file before running FastScape
// and a second after, we first set the visualization step to zero.
Expand Down Expand Up @@ -1004,8 +1005,6 @@ namespace aspect
#endif
}
}

this->get_computing_timer().leave_subsection("Execute FastScape");
}


Expand Down
8 changes: 2 additions & 6 deletions source/mesh_deformation/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ namespace aspect
{
AssertThrow(sim.parameters.mesh_deformation_enabled, ExcInternalError());

this->get_computing_timer().enter_subsection("Mesh deformation");
TimerScope timer (sim.computing_timer, "Mesh deformation");

old_mesh_displacements = mesh_displacements;

Expand All @@ -584,8 +584,6 @@ namespace aspect

// After changing the mesh we need to rebuild things
sim.rebuild_stokes_matrix = sim.rebuild_stokes_preconditioner = true;

this->get_computing_timer().leave_subsection("Mesh deformation");
}


Expand Down Expand Up @@ -1560,15 +1558,13 @@ namespace aspect
if (this->simulator_is_past_initialization() == false ||
this->get_timestep_number() == 0)
{
this->get_computing_timer().enter_subsection("Mesh deformation initialize");
TimerScope timer (sim.computing_timer, "Mesh deformation initialize");

make_initial_constraints();
if (this->is_stokes_matrix_free())
compute_mesh_displacements_gmg();
else
compute_mesh_displacements();

this->get_computing_timer().leave_subsection("Mesh deformation initialize");
}

if (this->is_stokes_matrix_free())
Expand Down
32 changes: 10 additions & 22 deletions source/particle/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ namespace aspect
Particles::ParticleHandler<dim> &to_particle_handler) const
{
{
this->get_computing_timer().enter_subsection("Particles: Copy");
TimerScope timer_section(this->get_computing_timer(), "Particles: Copy");

to_particle_handler.copy_from(from_particle_handler);
this->get_computing_timer().leave_subsection("Particles: Copy");
}
}

Expand Down Expand Up @@ -829,9 +829,8 @@ namespace aspect
void
Manager<dim>::generate_particles()
{
this->get_computing_timer().enter_subsection("Particles: Generate");
TimerScope timer_section(this->get_computing_timer(), "Particles: Generate");
generator->generate_particles(*particle_handler);
this->get_computing_timer().leave_subsection("Particles: Generate");
}


Expand All @@ -843,7 +842,7 @@ namespace aspect
// TODO: Change this loop over all cells to use the WorkStream interface
if (property_manager->get_n_property_components() > 0)
{
this->get_computing_timer().enter_subsection("Particles: Initialize properties");
TimerScope timer_section(this->get_computing_timer(), "Particles: Initialize properties");

particle_handler->get_property_pool().reserve(2 * particle_handler->n_locally_owned_particles());

Expand All @@ -854,12 +853,9 @@ namespace aspect

if (dealii::Utilities::MPI::n_mpi_processes(this->get_mpi_communicator()) > 1)
{
this->get_computing_timer().enter_subsection("Particles: Exchange ghosts");
TimerScope timer_section(this->get_computing_timer(), "Particles: Exchange ghosts");
particle_handler->exchange_ghost_particles();
this->get_computing_timer().leave_subsection("Particles: Exchange ghosts");
}

this->get_computing_timer().leave_subsection("Particles: Initialize properties");
}
}

Expand All @@ -873,7 +869,7 @@ namespace aspect

if (property_manager->get_n_property_components() > 0)
{
this->get_computing_timer().enter_subsection("Particles: Update properties");
TimerScope timer_section(this->get_computing_timer(), "Particles: Update properties");

Assert(dealii::internal::FEPointEvaluation::is_fast_path_supported(this->get_mapping()) == true,
ExcMessage("The particle system was optimized for deal.II mappings that support the fast evaluation path "
Expand Down Expand Up @@ -922,8 +918,6 @@ namespace aspect
}

}

this->get_computing_timer().leave_subsection("Particles: Update properties");
}
}

Expand All @@ -935,7 +929,7 @@ namespace aspect
{
{
// TODO: Change this loop over all cells to use the WorkStream interface
this->get_computing_timer().enter_subsection("Particles: Advect");
TimerScope timer_section(this->get_computing_timer(), "Particles: Advect");

Assert(dealii::internal::FEPointEvaluation::is_fast_path_supported(this->get_mapping()) == true,
ExcMessage("The particle system was optimized for deal.II mappings that support the fast evaluation path "
Expand All @@ -961,16 +955,12 @@ namespace aspect
*evaluator);
}
}

this->get_computing_timer().leave_subsection("Particles: Advect");
}

{
this->get_computing_timer().enter_subsection("Particles: Sort");
TimerScope timer_section(this->get_computing_timer(), "Particles: Sort");
// Find the cells that the particles moved to
particle_handler->sort_particles_into_subdomains_and_cells();

this->get_computing_timer().leave_subsection("Particles: Sort");
}
}

Expand Down Expand Up @@ -998,9 +988,8 @@ namespace aspect
// ghost particles.
if (dealii::Utilities::MPI::n_mpi_processes(this->get_mpi_communicator()) > 1)
{
this->get_computing_timer().enter_subsection("Particles: Exchange ghosts");
TimerScope timer_section(this->get_computing_timer(), "Particles: Exchange ghosts");
particle_handler->exchange_ghost_particles();
this->get_computing_timer().leave_subsection("Particles: Exchange ghosts");
}
this->get_pcout() << " done." << std::endl;
}
Expand Down Expand Up @@ -1325,7 +1314,7 @@ namespace aspect
}


this->get_computing_timer().enter_subsection("Particles: Initialization");
TimerScope timer_section(this->get_computing_timer(), "Particles: Initialization");

// Create a generator object depending on what the parameters specify
generator = Generator::create_particle_generator<dim> (prm);
Expand Down Expand Up @@ -1359,7 +1348,6 @@ namespace aspect
interpolator->parse_parameters(prm);
interpolator->initialize();

this->get_computing_timer().leave_subsection("Particles: Initialization");
}
prm.leave_subsection ();
}
Expand Down
4 changes: 1 addition & 3 deletions source/postprocess/current_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace aspect
AssertThrow(dim==2,
ExcMessage("Depth with mesh deformation currently only works with a 2D model."));

this->get_computing_timer().enter_subsection("Geometry model surface update");
TimerScope timer_section(this->get_computing_timer(), "Geometry model surface update");

// loop over all of the surface cells and save the elevation to a stored value.
// This needs to be sent to 1 processor, sorted, and broadcast so that every processor knows the entire surface.
Expand Down Expand Up @@ -129,8 +129,6 @@ namespace aspect
// Create a surface function for the elevations.
surface_function = std::make_unique<Functions::InterpolatedTensorProductGridData<dim-1>>(coordinates, data_table);

this->get_computing_timer().leave_subsection("Geometry model surface update");

return std::make_pair ("Storing deformed surface topography: ",
"Done");
}
Expand Down
29 changes: 9 additions & 20 deletions source/simulator/assembly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ namespace aspect
else
AssertThrow(false, ExcNotImplemented());

computing_timer.enter_subsection("Build Stokes preconditioner");
TimerScope timer (computing_timer, "Build Stokes preconditioner");
pcout << " Rebuilding Stokes preconditioner..." << std::flush;

// first assemble the raw matrices necessary for the preconditioner
Expand Down Expand Up @@ -588,8 +588,6 @@ namespace aspect
rebuild_stokes_preconditioner = false;

pcout << std::endl;

computing_timer.leave_subsection("Build Stokes preconditioner");
}


Expand Down Expand Up @@ -772,7 +770,8 @@ namespace aspect
timer_section_name += " rhs";
}

computing_timer.enter_subsection(timer_section_name);
TimerScope timer (computing_timer,
timer_section_name);

if (rebuild_stokes_matrix == true)
system_matrix = 0;
Expand Down Expand Up @@ -892,8 +891,6 @@ namespace aspect

// record that we have just rebuilt the matrix
rebuild_stokes_matrix = false;

computing_timer.leave_subsection(timer_section_name);
}


Expand All @@ -904,9 +901,9 @@ namespace aspect
LinearAlgebra::PreconditionILU &preconditioner,
const double diagonal_strengthening)
{
computing_timer.enter_subsection(advection_field.is_temperature() ?
"Build temperature preconditioner" :
"Build composition preconditioner");
TimerScope timer (computing_timer, (advection_field.is_temperature() ?
"Build temperature preconditioner" :
"Build composition preconditioner"));

const unsigned int block_idx = advection_field.block_index(introspection);

Expand All @@ -915,10 +912,6 @@ namespace aspect
data.ilu_atol = diagonal_strengthening;

preconditioner.initialize (system_matrix.block(block_idx, block_idx), data);

computing_timer.leave_subsection(advection_field.is_temperature() ?
"Build temperature preconditioner" :
"Build composition preconditioner");
}


Expand Down Expand Up @@ -1222,9 +1215,9 @@ namespace aspect
template <int dim>
void Simulator<dim>::assemble_advection_system (const AdvectionField &advection_field)
{
computing_timer.enter_subsection(advection_field.is_temperature() ?
"Assemble temperature system" :
"Assemble composition system");
TimerScope timer (computing_timer, (advection_field.is_temperature() ?
"Assemble temperature system" :
"Assemble composition system"));

const unsigned int block_idx = advection_field.block_index(introspection);
const unsigned int sparsity_block_idx = advection_field.sparsity_pattern_block_index(introspection);
Expand Down Expand Up @@ -1331,10 +1324,6 @@ namespace aspect

system_matrix.compress(VectorOperation::add);
system_rhs.compress(VectorOperation::add);

computing_timer.leave_subsection(advection_field.is_temperature() ?
"Assemble temperature system" :
"Assemble composition system");
}
}

Expand Down
4 changes: 1 addition & 3 deletions source/simulator/checkpoint_restart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ namespace aspect
template <int dim>
void Simulator<dim>::create_snapshot()
{
computing_timer.enter_subsection("Create snapshot");
TimerScope timer (computing_timer, "Create snapshot");

// Take elapsed time from timer so that we can serialize it:
total_walltime_until_last_snapshot += wall_timer.wall_time();
Expand Down Expand Up @@ -387,8 +387,6 @@ namespace aspect
}

pcout << "*** Snapshot " << checkpoint_path << " created!" << std::endl << std::endl;

computing_timer.leave_subsection("Create snapshot");
}


Expand Down
Loading
Loading