Skip to content

Commit

Permalink
replace pushRegion/popRegion with ScopedRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
kwitaechong committed Feb 19, 2024
1 parent 99001ee commit b5ed3ea
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 110 deletions.
4 changes: 2 additions & 2 deletions core/src/Cabana_Distributor.hpp
Expand Up @@ -21,6 +21,7 @@
#include <Cabana_Slice.hpp>

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>

#include <mpi.h>

Expand Down Expand Up @@ -176,7 +177,7 @@ void distributeData(
is_aosoa<AoSoA_t>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::migrate" );
Kokkos::Profiling::ScopedRegion region( "Cabana::migrate" );

static_assert( is_accessible_from<typename Distributor_t::memory_space,
ExecutionSpace>{},
Expand Down Expand Up @@ -304,7 +305,6 @@ void distributeData(

// Barrier before completing to ensure synchronization.
MPI_Barrier( distributor.comm() );
Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down
9 changes: 3 additions & 6 deletions core/src/Cabana_HDF5ParticleOutput.hpp
Expand Up @@ -29,6 +29,7 @@
#define CABANA_HDF5PARTICLEOUTPUT_HPP

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>

#include <hdf5.h>
#ifdef H5_HAVE_SUBFILING_VFD
Expand Down Expand Up @@ -542,7 +543,7 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,
const CoordSliceType& coords_slice,
FieldSliceTypes&&... fields )
{
Kokkos::Profiling::pushRegion( "Cabana::HDF5ParticleOutput" );
Kokkos::Profiling::ScopedRegion region( "Cabana::HDF5ParticleOutput" );

hid_t plist_id;
hid_t dset_id;
Expand Down Expand Up @@ -758,8 +759,6 @@ void writeTimeStep( HDF5Config h5_config, const std::string& prefix,

if ( 0 == comm_rank )
Impl::writeXdmfFooter( filename_xdmf.str().c_str() );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -847,7 +846,7 @@ void readTimeStep( HDF5Config h5_config, const std::string& prefix,
const std::size_t n_local, const std::string& dataset_name,
double& time, FieldSliceType& field )
{
Kokkos::Profiling::pushRegion( "Cabana::HDF5ParticleInput" );
Kokkos::Profiling::ScopedRegion region( "Cabana::HDF5ParticleInput" );

hid_t plist_id;
hid_t dset_id;
Expand Down Expand Up @@ -943,8 +942,6 @@ void readTimeStep( HDF5Config h5_config, const std::string& prefix,
H5Sclose( filespace_id );
H5Dclose( dset_id );
H5Fclose( file_id );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down
12 changes: 4 additions & 8 deletions core/src/Cabana_Halo.hpp
Expand Up @@ -21,6 +21,7 @@
#include <Cabana_Slice.hpp>

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>

#include <mpi.h>

Expand Down Expand Up @@ -286,7 +287,7 @@ class Gather<HaloType, AoSoAType,
template <class ExecutionSpace>
void apply( ExecutionSpace )
{
Kokkos::Profiling::pushRegion( "Cabana::gather" );
Kokkos::Profiling::ScopedRegion region( "Cabana::gather" );

// Get the buffers and particle data (local copies for lambdas below).
auto send_buffer = this->getSendBuffer();
Expand Down Expand Up @@ -362,8 +363,6 @@ class Gather<HaloType, AoSoAType,

// Barrier before completing to ensure synchronization.
MPI_Barrier( _halo.comm() );

Kokkos::Profiling::popRegion();
}

void apply() override { apply( execution_space{} ); }
Expand Down Expand Up @@ -467,7 +466,7 @@ class Gather<HaloType, SliceType,
template <class ExecutionSpace>
void apply( ExecutionSpace )
{
Kokkos::Profiling::pushRegion( "Cabana::gather" );
Kokkos::Profiling::ScopedRegion region( "Cabana::gather" );

// Get the buffers (local copies for lambdas below).
auto send_buffer = this->getSendBuffer();
Expand Down Expand Up @@ -562,8 +561,6 @@ class Gather<HaloType, SliceType,

// Barrier before completing to ensure synchronization.
MPI_Barrier( _halo.comm() );

Kokkos::Profiling::popRegion();
}

void apply() override { apply( execution_space{} ); }
Expand Down Expand Up @@ -717,7 +714,7 @@ class Scatter
template <class ExecutionSpace>
void apply( ExecutionSpace )
{
Kokkos::Profiling::pushRegion( "Cabana::scatter" );
Kokkos::Profiling::ScopedRegion region( "Cabana::scatter" );

// Get the buffers (local copies for lambdas below).
auto send_buffer = this->getSendBuffer();
Expand Down Expand Up @@ -816,7 +813,6 @@ class Scatter

// Barrier before completing to ensure synchronization.
MPI_Barrier( _halo.comm() );
Kokkos::Profiling::popRegion();
}

void apply() override { apply( execution_space{} ); }
Expand Down
6 changes: 3 additions & 3 deletions core/src/Cabana_LinkedCellList.hpp
Expand Up @@ -22,6 +22,7 @@
#include <impl/Cabana_CartesianGrid.hpp>

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>
#include <Kokkos_ScatterView.hpp>

#include <cassert>
Expand Down Expand Up @@ -242,7 +243,8 @@ class LinkedCellList
void build( ExecutionSpace, SliceType positions, const std::size_t begin,
const std::size_t end )
{
Kokkos::Profiling::pushRegion( "Cabana::LinkedCellList::build" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::LinkedCellList::build" );

static_assert( is_accessible_from<memory_space, ExecutionSpace>{}, "" );
assert( end >= begin );
Expand Down Expand Up @@ -318,8 +320,6 @@ class LinkedCellList
// Create the binning data.
_bin_data = BinningData<MemorySpace>( begin, end, _counts, _offsets,
_permutes );

Kokkos::Profiling::popRegion();
}

/*!
Expand Down
50 changes: 17 additions & 33 deletions core/src/Cabana_Parallel.hpp
Expand Up @@ -21,6 +21,7 @@
#include <Cabana_Types.hpp> // is_accessible_from

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>

#include <cstdlib>
#include <type_traits>
Expand Down Expand Up @@ -172,12 +173,10 @@ inline void simd_parallel_for(
const SimdPolicy<VectorLength, ExecParameters...>& exec_policy,
const FunctorType& functor, const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::simd_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::simd_parallel_for" );

Impl::ParallelFor<SimdPolicy<VectorLength, ExecParameters...>, FunctorType>(
str, exec_policy, functor );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -253,7 +252,7 @@ inline void neighbor_parallel_for(
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const SerialOpTag, const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::neighbor_parallel_for" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -287,8 +286,6 @@ inline void neighbor_parallel_for(
Kokkos::parallel_for( linear_exec_policy, neigh_func );
else
Kokkos::parallel_for( str, linear_exec_policy, neigh_func );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -317,7 +314,7 @@ inline void neighbor_parallel_for(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const SerialOpTag, const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::neighbor_parallel_for" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -359,8 +356,6 @@ inline void neighbor_parallel_for(
Kokkos::parallel_for( linear_exec_policy, neigh_func );
else
Kokkos::parallel_for( str, linear_exec_policy, neigh_func );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -388,7 +383,7 @@ inline void neighbor_parallel_for(
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const TeamOpTag, const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::neighbor_parallel_for" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -429,8 +424,6 @@ inline void neighbor_parallel_for(
Kokkos::parallel_for( team_policy, neigh_func );
else
Kokkos::parallel_for( str, team_policy, neigh_func );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -460,7 +453,7 @@ inline void neighbor_parallel_for(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const TeamOpTag, const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::neighbor_parallel_for" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -507,8 +500,6 @@ inline void neighbor_parallel_for(
Kokkos::parallel_for( team_policy, neigh_func );
else
Kokkos::parallel_for( str, team_policy, neigh_func );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -539,7 +530,7 @@ inline void neighbor_parallel_for(
const SecondNeighborsTag, const TeamVectorOpTag,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );
Kokkos::Profiling::ScopedRegion region( "Cabana::neighbor_parallel_for" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -588,8 +579,6 @@ inline void neighbor_parallel_for(
Kokkos::parallel_for( team_policy, neigh_func );
else
Kokkos::parallel_for( str, team_policy, neigh_func );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -642,7 +631,8 @@ inline void neighbor_parallel_reduce(
const FirstNeighborsTag, const SerialOpTag, ReduceType& reduce_val,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::neighbor_parallel_reduce" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -678,8 +668,6 @@ inline void neighbor_parallel_reduce(
else
Kokkos::parallel_reduce( str, linear_exec_policy, neigh_reduce,
reduce_val );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -712,7 +700,8 @@ inline void neighbor_parallel_reduce(
const SecondNeighborsTag, const SerialOpTag, ReduceType& reduce_val,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::neighbor_parallel_reduce" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -755,8 +744,6 @@ inline void neighbor_parallel_reduce(
else
Kokkos::parallel_reduce( str, linear_exec_policy, neigh_reduce,
reduce_val );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -789,7 +776,8 @@ inline void neighbor_parallel_reduce(
const FirstNeighborsTag, const TeamOpTag, ReduceType& reduce_val,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::neighbor_parallel_reduce" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -835,8 +823,6 @@ inline void neighbor_parallel_reduce(
Kokkos::parallel_reduce( team_policy, neigh_reduce, reduce_val );
else
Kokkos::parallel_reduce( str, team_policy, neigh_reduce, reduce_val );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -870,7 +856,8 @@ inline void neighbor_parallel_reduce(
const SecondNeighborsTag, const TeamOpTag, ReduceType& reduce_val,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::neighbor_parallel_reduce" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -921,8 +908,6 @@ inline void neighbor_parallel_reduce(
Kokkos::parallel_reduce( team_policy, neigh_reduce, reduce_val );
else
Kokkos::parallel_reduce( str, team_policy, neigh_reduce, reduce_val );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -956,7 +941,8 @@ inline void neighbor_parallel_reduce(
const SecondNeighborsTag, const TeamVectorOpTag, ReduceType& reduce_val,
const std::string& str = "" )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );
Kokkos::Profiling::ScopedRegion region(
"Cabana::neighbor_parallel_reduce" );

using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;

Expand Down Expand Up @@ -1012,8 +998,6 @@ inline void neighbor_parallel_reduce(
Kokkos::parallel_reduce( team_policy, neigh_reduce, reduce_val );
else
Kokkos::parallel_reduce( str, team_policy, neigh_reduce, reduce_val );

Kokkos::Profiling::popRegion();
}

//---------------------------------------------------------------------------//
Expand Down
5 changes: 2 additions & 3 deletions core/src/Cabana_SiloParticleOutput.hpp
Expand Up @@ -29,6 +29,7 @@
#define CABANA_SILOPARTICLEOUTPUT_HPP

#include <Kokkos_Core.hpp>
#include <Kokkos_Profiling_ScopedRegion.hpp>

#include <Cabana_Slice.hpp>

Expand Down Expand Up @@ -403,7 +404,7 @@ void writePartialRangeTimeStep( const std::string& prefix, MPI_Comm comm,
const CoordSliceType& coords,
FieldSliceTypes&&... fields )
{
Kokkos::Profiling::pushRegion( "Cabana::SiloParticleOutput" );
Kokkos::Profiling::ScopedRegion region( "Cabana::SiloParticleOutput" );

// Create the parallel baton.
int mpi_tag = 1948;
Expand Down Expand Up @@ -478,8 +479,6 @@ void writePartialRangeTimeStep( const std::string& prefix, MPI_Comm comm,

// Finish.
PMPIO_Finish( baton );

Kokkos::Profiling::popRegion();
}

/*!
Expand Down

0 comments on commit b5ed3ea

Please sign in to comment.