Skip to content

Commit

Permalink
fixup: remove class lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Oct 20, 2023
1 parent 73245cb commit 8aca216
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions grid/src/Cabana_Grid_GlobalParticleComm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ class GlobalParticleComm
template <class LocalMeshType>
void storeRanks( LocalMeshType local_mesh )
{
auto store_corners = KOKKOS_CLASS_LAMBDA( const std::size_t d )
auto local_corners = _local_corners;
auto store_corners = KOKKOS_LAMBDA( const std::size_t d )
{
_local_corners( _rank[d], d, 0 ) =
local_corners( _rank[d], d, 0 ) =
local_mesh.lowCorner( Cabana::Grid::Own(), d );
_local_corners( _rank[d], d, 1 ) =
local_corners( _rank[d], d, 1 ) =
local_mesh.highCorner( Cabana::Grid::Own(), d );
};
using exec_space = typename memory_space::execution_space;
Expand All @@ -118,12 +119,13 @@ class GlobalParticleComm
{
auto scale = getScaling();

auto scale_corners = KOKKOS_CLASS_LAMBDA( const std::size_t d )
auto local_corners = _local_corners;
auto scale_corners = KOKKOS_LAMBDA( const std::size_t d )
{
for ( int r = 0; r < _ranks_per_dim[d]; ++r )
{
_local_corners( r, d, 0 ) /= scale[d];
_local_corners( r, d, 1 ) /= scale[d];
local_corners( r, d, 0 ) /= scale[d];
local_corners( r, d, 1 ) /= scale[d];
}
};
using exec_space = typename memory_space::execution_space;
Expand Down Expand Up @@ -187,22 +189,6 @@ class GlobalParticleComm
memory_space(), global_ranks_host );
}

//! Get the MPI rank.
template <std::size_t NSD = num_space_dim>
KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, int>
getRank( int ijk[num_space_dim] ) const
{
return _global_ranks( ijk[0], ijk[1], ijk[2] );
}

//! Get the MPI rank.
template <std::size_t NSD = num_space_dim>
KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, int>
getRank( int ijk[num_space_dim] ) const
{
return _global_ranks( ijk[0], ijk[1], 0 );
}

/*!
\brief Bin particles across the global grid.
Expand Down Expand Up @@ -231,9 +217,12 @@ class GlobalParticleComm
auto local_corners = _local_corners;
auto ranks_per_dim = _ranks_per_dim;
auto destinations = _destinations;
auto build_migrate = KOKKOS_CLASS_LAMBDA( const std::size_t p )
auto global_ranks = _global_ranks;
auto build_migrate = KOKKOS_LAMBDA( const std::size_t p )
{
int ijk[num_space_dim];
// This is not num_space_dim because global_ranks is always rank-3
// out of convenience.
int ijk[3] = { 0, 0, 0 };

// Find the rank this particle should be moved to.
for ( std::size_t d = 0; d < num_space_dim; ++d )
Expand All @@ -258,7 +247,7 @@ class GlobalParticleComm
ijk[d] = min;
}
// Keep the destination rank for eventual migration.
destinations( p ) = getRank( ijk );
destinations( p ) = global_ranks( ijk[0], ijk[1], ijk[2] );
};

Kokkos::RangePolicy<ExecutionSpace> policy( exec_space, begin, end );
Expand Down

0 comments on commit 8aca216

Please sign in to comment.