Skip to content

Commit

Permalink
Removed deprecated device type class templates
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed May 14, 2024
1 parent 6be5fb5 commit ea824dd
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 206 deletions.
2 changes: 1 addition & 1 deletion benchmark/grid/Cabana_Grid_InterpolationPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,

// Create a local grid and local mesh
auto local_grid = createLocalGrid( global_grid, halo_width );
auto local_mesh = createLocalMesh<exec_space>( *local_grid );
auto local_mesh = createLocalMesh<memory_space>( *local_grid );
auto owned_cells = local_grid->indexSpace( Own(), Cell(), Local() );
int num_cells = owned_cells.size();

Expand Down
13 changes: 4 additions & 9 deletions core/src/Cabana_AoSoA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,10 @@ class AoSoA
//! Member data types.
using member_types = DataTypes;

// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );

//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! Kokkos memory space.
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Default execution space.
using execution_space = typename memory_space::execution_space;

Expand Down
12 changes: 3 additions & 9 deletions core/src/Cabana_CommunicationPlan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,9 @@ template <class MemorySpace>
class CommunicationPlan
{
public:
// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );

//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! Kokkos memory space.
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Default execution space.
using execution_space = typename memory_space::execution_space;
Expand Down
63 changes: 0 additions & 63 deletions core/src/Cabana_Experimental_NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,37 +353,6 @@ auto makeNeighborList( Tag tag, Slice const& coordinate_slice,
buffer_size );
}

/*!
\brief Neighbor list implementation using ArborX for particles within the
interaction distance with a 1D compressed layout for particles and neighbors.
\tparam DeviceType Kokkos device type.
\tparam Slice The position slice type.
\tparam Tag Tag indicating whether to build a full or half neighbor list.
\param tag Tag indicating whether to build a full or half neighbor list.
\param coordinate_slice The slice containing the particle positions.
\param first The beginning particle index to compute neighbors for.
\param last The end particle index to compute neighbors for.
\param radius The radius of the neighborhood. Particles within this radius are
considered neighbors.
\param buffer_size Optional guess for maximum number of neighbors.
Neighbor list implementation most appropriate for highly varying particle
densities.
*/
template <typename DeviceType, typename Slice, typename Tag>
[[deprecated]] auto makeNeighborList( Tag tag, Slice const& coordinate_slice,
typename Slice::size_type first,
typename Slice::size_type last,
typename Slice::value_type radius,
int buffer_size = 0 )
{
using exec_space = typename DeviceType::execution_space;
return makeNeighborList( exec_space{}, tag, coordinate_slice, first, last,
radius, buffer_size );
}

//---------------------------------------------------------------------------//
//! 2d ArborX neighbor list storage layout.
template <typename MemorySpace, typename Tag>
Expand Down Expand Up @@ -517,38 +486,6 @@ auto make2DNeighborList( Tag tag, Slice const& coordinate_slice,
radius, buffer_size );
}

/*!
\brief Neighbor list implementation using ArborX for particles within the
interaction distance with a 2D layout for particles and neighbors.
\tparam DeviceType Kokkos device type.
\tparam Slice The position slice type.
\tparam Tag Tag indicating whether to build a full or half neighbor list.
\param tag Tag indicating whether to build a full or half neighbor list.
\param coordinate_slice The slice containing the particle positions.
\param first The beginning particle index to compute neighbors for.
\param last The end particle index to compute neighbors for.
\param radius The radius of the neighborhood. Particles within this radius are
considered neighbors.
\param buffer_size Optional guess for maximum number of neighbors per
particle.
Neighbor list implementation most appropriate for highly varying particle
densities.
*/
template <typename DeviceType, typename Slice, typename Tag>
[[deprecated]] auto make2DNeighborList( Tag tag, Slice const& coordinate_slice,
typename Slice::size_type first,
typename Slice::size_type last,
typename Slice::value_type radius,
int buffer_size = 0 )
{
using exec_space = typename DeviceType::execution_space;
return make2DNeighborList( exec_space{}, tag, coordinate_slice, first, last,
radius, buffer_size );
}

} // namespace Experimental

//! 1d ArborX NeighborList interface.
Expand Down
13 changes: 3 additions & 10 deletions core/src/Cabana_LinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,10 @@ template <class MemorySpace, class Scalar = double>
class LinkedCellList
{
public:
// FIXME: add static_assert that this is a valid MemorySpace.

// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
//! Kokkos memory space.
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! Default execution space.
using execution_space = typename memory_space::execution_space;
//! Memory space size type.
Expand Down
8 changes: 4 additions & 4 deletions core/src/Cabana_SiloParticleOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void writeFields(
{
// Reorder in a contiguous blocked format.
Kokkos::View<typename SliceType::value_type*,
typename SliceType::device_type>
typename SliceType::memory_space>
view( Kokkos::ViewAllocateWithoutInitializing( "scalar_field" ),
end - begin );
copySliceToView( view, slice, begin, end );
Expand All @@ -122,7 +122,7 @@ void writeFields(
{
// Reorder in a contiguous blocked format.
Kokkos::View<typename SliceType::value_type**, Kokkos::LayoutLeft,
typename SliceType::device_type>
typename SliceType::memory_space>
view( Kokkos::ViewAllocateWithoutInitializing( "vector_field" ),
end - begin, slice.extent( 2 ) );
copySliceToView( view, slice, begin, end );
Expand Down Expand Up @@ -153,7 +153,7 @@ void writeFields(
{
// Reorder in a contiguous blocked format.
Kokkos::View<typename SliceType::value_type***, Kokkos::LayoutLeft,
typename SliceType::device_type>
typename SliceType::memory_space>
view( Kokkos::ViewAllocateWithoutInitializing( "matrix_field" ),
end - begin, slice.extent( 2 ), slice.extent( 3 ) );
copySliceToView( view, slice, begin, end );
Expand Down Expand Up @@ -439,7 +439,7 @@ void writePartialRangeTimeStep( const std::string& prefix, MPI_Comm comm,

// Reorder the coordinates in a blocked format.
Kokkos::View<typename CoordSliceType::value_type**, Kokkos::LayoutLeft,
typename CoordSliceType::device_type>
typename CoordSliceType::memory_space>
view( Kokkos::ViewAllocateWithoutInitializing( "coords" ), end - begin,
coords.extent( 2 ) );
copySliceToView( view, coords, begin, end );
Expand Down
13 changes: 4 additions & 9 deletions core/src/Cabana_Slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,10 @@ class Slice
using slice_type =
Slice<DataType, MemorySpace, MemoryAccessType, VectorLength, Stride>;

// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );

//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! Kokkos memory space.
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Default execution space.
using execution_space = typename memory_space::execution_space;

Expand Down
13 changes: 4 additions & 9 deletions core/src/Cabana_Sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ template <class MemorySpace>
class BinningData
{
public:
// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );

//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! Kokkos memory space.
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Default execution space.
using execution_space = typename memory_space::execution_space;
//! Memory space size type.
Expand Down
6 changes: 2 additions & 4 deletions core/src/Cabana_Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ namespace Impl
{
//! \cond Impl

// Custom warning for switch from device_type to memory_space.
// Custom warning for use within static_assert.
constexpr bool deprecated( std::false_type ) { return true; }

[[deprecated(
"Template parameter should be converted from Kokkos device type to "
"Kokkos memory space." )]] constexpr bool
[[deprecated( "Cabana deprecation." )]] constexpr bool
deprecated( std::true_type )
{
return true;
Expand Down
3 changes: 1 addition & 2 deletions example/grid_tutorial/14_spline/spline_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void splineExample()
This includes the creation of a simple uniform mesh and a single particle
position.
*/
using ExecutionSpace = Kokkos::DefaultHostExecutionSpace;

// Create a 3-dimensional global uniform mesh
// Global bounding box.
Expand Down Expand Up @@ -67,7 +66,7 @@ void splineExample()

// Get the local mesh for this rank.
auto local_mesh =
Cabana::Grid::createLocalMesh<ExecutionSpace>( *local_grid );
Cabana::Grid::createLocalMesh<Kokkos::HostSpace>( *local_grid );

// Create a particle position vector.
double xp[3] = { 0.5, 2, 1.5 };
Expand Down
24 changes: 12 additions & 12 deletions example/grid_tutorial/15_interpolation/interpolation_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void interpolationExample()
This example is all in 2D.
*/
using ExecutionSpace = Kokkos::DefaultHostExecutionSpace;
using MemorySpace = Kokkos::HostSpace;

// Create the global mesh.
std::array<double, 2> low_corner = { -1.2, 0.1 };
Expand All @@ -147,14 +148,13 @@ void interpolationExample()
// Create a grid local_grid.
int halo_width = 1;
auto local_grid = Cabana::Grid::createLocalGrid( global_grid, halo_width );
auto local_mesh =
Cabana::Grid::createLocalMesh<ExecutionSpace>( *local_grid );
auto local_mesh = Cabana::Grid::createLocalMesh<MemorySpace>( *local_grid );

// Create a point in the center of every cell.
auto cell_space = local_grid->indexSpace(
Cabana::Grid::Own(), Cabana::Grid::Cell(), Cabana::Grid::Local() );
int num_particles = cell_space.size();
Kokkos::View<double* [2], ExecutionSpace> particle_positions(
Kokkos::View<double* [2], MemorySpace> particle_positions(
Kokkos::ViewAllocateWithoutInitializing( "positions" ), num_particles );
Kokkos::parallel_for(
"fill_positions", createExecutionPolicy( cell_space, ExecutionSpace() ),
Expand All @@ -176,7 +176,7 @@ void interpolationExample()
// information on these functions.
auto scalar_layout =
Cabana::Grid::createArrayLayout( local_grid, 1, Cabana::Grid::Node() );
auto scalar_grid_field = Cabana::Grid::createArray<double, ExecutionSpace>(
auto scalar_grid_field = Cabana::Grid::createArray<double, MemorySpace>(
"scalar_grid_field", scalar_layout );

// Create a halo for scatter operations. This concept is discussed in more
Expand All @@ -187,24 +187,24 @@ void interpolationExample()
// Create a vector field on the grid.
auto vector_layout =
Cabana::Grid::createArrayLayout( local_grid, 2, Cabana::Grid::Node() );
auto vector_grid_field = Cabana::Grid::createArray<double, ExecutionSpace>(
auto vector_grid_field = Cabana::Grid::createArray<double, MemorySpace>(
"vector_grid_field", vector_layout );
auto vector_halo = Cabana::Grid::createHalo(
Cabana::Grid::NodeHaloPattern<2>(), halo_width, *vector_grid_field );

// Simple Kokkos::Views may be used to represent particle data.
// Create a scalar point field.
Kokkos::View<double*, ExecutionSpace> scalar_particle_field(
Kokkos::View<double*, MemorySpace> scalar_particle_field(
Kokkos::ViewAllocateWithoutInitializing( "particle_scalar" ),
num_particles );

// Create a vector point field.
Kokkos::View<double* [2], ExecutionSpace> vector_particle_field(
Kokkos::View<double* [2], MemorySpace> vector_particle_field(
Kokkos::ViewAllocateWithoutInitializing( "particle_vector" ),
num_particles );

// Create a tensor point field.
Kokkos::View<double* [2][2], ExecutionSpace> tensor_particle_field(
Kokkos::View<double* [2][2], MemorySpace> tensor_particle_field(
Kokkos::ViewAllocateWithoutInitializing( "particle_tensor" ),
num_particles );

Expand Down Expand Up @@ -350,8 +350,8 @@ void interpolationExample()
* aggregated fields will be considered in a separate example.
* ************************************************************************/

P2GExampleFunctor<Kokkos::View<double*, ExecutionSpace>,
Kokkos::View<double* [2], ExecutionSpace>>
P2GExampleFunctor<Kokkos::View<double*, MemorySpace>,
Kokkos::View<double* [2], MemorySpace>>
example_p2g { scalar_particle_field, vector_particle_field };
Cabana::Grid::p2g( example_p2g, particle_positions, num_particles,
Cabana::Grid::Spline<1>(), *scalar_halo,
Expand Down Expand Up @@ -455,8 +455,8 @@ void interpolationExample()
* interpolation function, but is also useful when combined in fused kernel
* operations.
* *************************************************************************/
G2PExampleFunctor<Kokkos::View<double*, ExecutionSpace>,
Kokkos::View<double* [2][2], ExecutionSpace>>
G2PExampleFunctor<Kokkos::View<double*, MemorySpace>,
Kokkos::View<double* [2][2], MemorySpace>>
example_g2p { scalar_particle_field, tensor_particle_field };
Cabana::Grid::g2p( *vector_grid_field, *vector_halo, particle_positions,
num_particles, Cabana::Grid::Spline<1>(), example_g2p );
Expand Down
6 changes: 3 additions & 3 deletions grid/src/Cabana_Grid_Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ class Array
std::conditional_t<2 == num_space_dim,
Kokkos::View<value_type***, Params...>, void>>;

//! Memory space.
//! Kokkos memory space.
using memory_space = typename view_type::memory_space;
//! Default device type.
using device_type [[deprecated]] = typename memory_space::device_type;
static_assert( Kokkos::is_memory_space<memory_space>() );

//! Default execution space.
using execution_space = typename memory_space::execution_space;

Expand Down
24 changes: 4 additions & 20 deletions grid/src/Cabana_Grid_FastFourierTransform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,12 @@ class FastFourierTransform
//! Scalar value type.
using value_type = Scalar;

// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Kokkos memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert(
Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Kokkos execution space.
using execution_space = typename memory_space::execution_space;
//! Kokkos execution space.
using exec_space [[deprecated]] = execution_space;
//! Default Kokkos device type.
using device_type [[deprecated]] = typename memory_space::device_type;

//! Spatial dimension.
static constexpr std::size_t num_space_dim = mesh_type::num_space_dim;
Expand Down Expand Up @@ -486,20 +478,12 @@ class HeffteFastFourierTransform
//! Scalar value type.
using value_type = Scalar;

// FIXME: extracting the self type for backwards compatibility with previous
// template on DeviceType. Should simply be MemorySpace after next release.
//! Kokkos memory space.
using memory_space = typename MemorySpace::memory_space;
// FIXME: replace warning with memory space assert after next release.
static_assert(
Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
using memory_space = MemorySpace;
static_assert( Kokkos::is_memory_space<MemorySpace>() );

//! Kokkos execution space.
using execution_space = ExecSpace;
//! Kokkos execution space.
using exec_space [[deprecated]] = execution_space;
//! Default Kokkos device type.
using device_type [[deprecated]] = typename memory_space::device_type;
//! FFT backend type.
using backend_type = BackendType;
//! Mesh type.
Expand Down
Loading

0 comments on commit ea824dd

Please sign in to comment.