Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
lebuller committed Nov 8, 2023
1 parent c643d5c commit f071fd1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 52 deletions.
20 changes: 9 additions & 11 deletions core/src/Cabana_LinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class LinkedCellList
*/
KOKKOS_INLINE_FUNCTION
Scalar minDistanceToPoint( const Scalar x, const Scalar y, const Scalar z,
const int i, const int j, const int k ) const
const int i, const int j, const int k ) const
{
return _grid.minDistanceToPoint( x, y, z, i, j, k );
}
Expand Down Expand Up @@ -264,20 +264,18 @@ class LinkedCellList
_grid.ijkBinIndex( cell, i, j, k );

kmin = ( k - _cell_range > 0 ) ? k - _cell_range : 0;
kmax =
( k + _cell_range + 1 < _grid._nz ) ? k + _cell_range + 1 : _grid._nz;
kmax = ( k + _cell_range + 1 < _grid._nz ) ? k + _cell_range + 1
: _grid._nz;

jmin = ( j - _cell_range > 0 ) ? j - _cell_range : 0;
jmax =
( j + _cell_range + 1 < _grid._ny ) ? j + _cell_range + 1 : _grid._ny;
jmax = ( j + _cell_range + 1 < _grid._ny ) ? j + _cell_range + 1
: _grid._ny;

imin = ( i - _cell_range > 0 ) ? i - _cell_range : 0;
imax =
( i + _cell_range + 1 < _grid._nx ) ? i + _cell_range + 1 : _grid._nx;
imax = ( i + _cell_range + 1 < _grid._nx ) ? i + _cell_range + 1
: _grid._nx;
}



/*!
\brief Get the 1d bin data.
\return The 1d bin data.
Expand Down Expand Up @@ -456,7 +454,7 @@ class LinkedCellList
//! Cutoff squared.
Scalar _rsqr;
//! Background grid.
// Impl::CartesianGrid<double> grid;
// Impl::CartesianGrid<double> grid;
//! Maximum cells per dimension.
int _max_cells_dir;
//! Maximum total cells.
Expand Down Expand Up @@ -641,7 +639,7 @@ class NeighborList<LinkedCellList<DeviceType, ScalarType>>
int total_count = 0;
int imin, imax, jmin, jmax, kmin, kmax;
list.getCells( cell( particle_index ), imin, imax, jmin, jmax, kmin,
kmax );
kmax );

// Loop over the cell stencil.
for ( int i = imin; i < imax; ++i )
Expand Down
45 changes: 27 additions & 18 deletions core/src/Cabana_Parallel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const SerialOpTag, const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );

Expand Down Expand Up @@ -319,7 +320,8 @@ inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const SerialOpTag, const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );

Expand Down Expand Up @@ -391,7 +393,8 @@ inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const TeamOpTag, const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );

Expand Down Expand Up @@ -464,7 +467,8 @@ inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const TeamOpTag, const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );

Expand Down Expand Up @@ -544,7 +548,8 @@ inline void neighbor_parallel_for(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const TeamVectorOpTag,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_for" );

Expand Down Expand Up @@ -648,7 +653,8 @@ inline void neighbor_parallel_reduce(
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const SerialOpTag, ReduceType& reduce_val,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );

Expand Down Expand Up @@ -719,7 +725,8 @@ inline void neighbor_parallel_reduce(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const SerialOpTag, ReduceType& reduce_val,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );

Expand Down Expand Up @@ -797,7 +804,8 @@ inline void neighbor_parallel_reduce(
const FunctorType& functor, const NeighborListType& list,
const FirstNeighborsTag, const TeamOpTag, ReduceType& reduce_val,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );

Expand Down Expand Up @@ -879,7 +887,8 @@ inline void neighbor_parallel_reduce(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const TeamOpTag, ReduceType& reduce_val,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );

Expand Down Expand Up @@ -966,7 +975,8 @@ inline void neighbor_parallel_reduce(
const FunctorType& functor, const NeighborListType& list,
const SecondNeighborsTag, const TeamVectorOpTag, ReduceType& reduce_val,
const std::string& str = "",
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ), int>::type* = 0 )
typename std::enable_if<( !is_linked_cell_list<NeighborListType>::value ),
int>::type* = 0 )
{
Kokkos::Profiling::pushRegion( "Cabana::neighbor_parallel_reduce" );

Expand Down Expand Up @@ -1136,8 +1146,7 @@ struct LinkedCellParallelFor

LinkedCellParallelFor( std::string label, Policy exec_policy,
Functor functor, const LinkedCellType& list,
ViewType cells,
const index_type begin = 0 )
ViewType cells, const index_type begin = 0 )
: _exec_policy( exec_policy )
, _functor( functor )
, _list( list )
Expand Down Expand Up @@ -1264,9 +1273,9 @@ template <class FunctorType, class LinkedCellType, class... ExecParameters>
inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const LinkedCellType& list,
const FirstNeighborsTag, const SerialOpTag,
const std::string& str = "",
typename std::enable_if<( is_linked_cell_list<LinkedCellType>::value ), int>::type* = 0 )
const FirstNeighborsTag, const SerialOpTag, const std::string& str = "",
typename std::enable_if<( is_linked_cell_list<LinkedCellType>::value ),
int>::type* = 0 )
{
using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;
using execution_space =
Expand Down Expand Up @@ -1332,9 +1341,9 @@ template <class FunctorType, class LinkedCellType, class... ExecParameters>
inline void neighbor_parallel_for(
const Kokkos::RangePolicy<ExecParameters...>& exec_policy,
const FunctorType& functor, const LinkedCellType& list,
const FirstNeighborsTag, const TeamOpTag,
const std::string& str = "" ,
typename std::enable_if<( is_linked_cell_list<LinkedCellType>::value ), int>::type* = 0 )
const FirstNeighborsTag, const TeamOpTag, const std::string& str = "",
typename std::enable_if<( is_linked_cell_list<LinkedCellType>::value ),
int>::type* = 0 )
{
using work_tag = typename Kokkos::RangePolicy<ExecParameters...>::work_tag;
using execution_space =
Expand Down
7 changes: 3 additions & 4 deletions core/src/Cabana_VerletList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ struct VerletListBuilder
// treated as candidates for neighbors.
double grid_size = cell_size_ratio * neighborhood_radius;
PositionValueType grid_delta[3] = { grid_size, grid_size, grid_size };
linked_cell_list = LinkedCellList<memory_space, PositionValueType>( position, grid_delta,
grid_min, grid_max,
neighborhood_radius,
cell_size_ratio );
linked_cell_list = LinkedCellList<memory_space, PositionValueType>(
position, grid_delta, grid_min, grid_max, neighborhood_radius,
cell_size_ratio );
bin_data_1d = linked_cell_list.binningData();

// We will use the square of the distance for neighbor determination.
Expand Down
33 changes: 17 additions & 16 deletions core/unit_test/tstLinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ struct LCLTestData
}
};

void copyListToHost( LCLTestData& test_data,
const Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list )
void copyListToHost(
LCLTestData& test_data,
const Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list )
{
// Copy data to the host for testing.
auto np = test_data.num_p;
Expand Down Expand Up @@ -260,7 +261,8 @@ void testLinkedList()
auto begin = test_data.begin;
auto end = test_data.end;
Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list(
pos, begin, end, grid_delta, grid_min, grid_max, test_data.grid_delta[0] );
pos, begin, end, grid_delta, grid_min, grid_max,
test_data.grid_delta[0] );
Cabana::permute( cell_list, test_data.aosoa );

copyListToHost( test_data, cell_list );
Expand All @@ -271,8 +273,8 @@ void testLinkedList()

// Now bin and permute all of the particles.
{
Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list( pos, grid_delta,
grid_min, grid_max, test_data.grid_delta[0] );
Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list(
pos, grid_delta, grid_min, grid_max, test_data.grid_delta[0] );
Cabana::permute( cell_list, test_data.aosoa );

copyListToHost( test_data, cell_list );
Expand Down Expand Up @@ -307,8 +309,8 @@ void testLinkedListSlice()
}
// Now bin and permute all of the particles.
{
Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list( pos, grid_delta,
grid_min, grid_max, grid_delta[0] );
Cabana::LinkedCellList<TEST_MEMSPACE, double> cell_list(
pos, grid_delta, grid_min, grid_max, grid_delta[0] );
Cabana::permute( cell_list, pos );

copyListToHost( test_data, cell_list );
Expand All @@ -330,8 +332,7 @@ void testLinkedListSlice()
//---------------------------------------------------------------------------//
// linked_list_parallel
//---------------------------------------------------------------------------//
template <class ListType, class TestListType,
class PositionType>
template <class ListType, class TestListType, class PositionType>
void checkLinkedCellParallel( const ListType& nlist,
const TestListType& N2_list_copy,
const int num_particle,
Expand Down Expand Up @@ -389,11 +390,11 @@ void checkLinkedCellParallel( const ListType& nlist,
};
Kokkos::RangePolicy<TEST_EXECSPACE> policy( 0, num_particle );
Cabana::neighbor_parallel_for( policy, serial_count_op, nlist,
Cabana::FirstNeighborsTag(),
Cabana::SerialOpTag(), "test_1st_serial" );
Cabana::FirstNeighborsTag(),
Cabana::SerialOpTag(), "test_1st_serial" );
Cabana::neighbor_parallel_for( policy, team_count_op, nlist,
Cabana::FirstNeighborsTag(),
Cabana::TeamOpTag(), "test_1st_team" );
Cabana::FirstNeighborsTag(),
Cabana::TeamOpTag(), "test_1st_team" );
Kokkos::fence();

checkFirstNeighborParallelFor( N2_list_copy, serial_result, team_result,
Expand All @@ -420,9 +421,9 @@ void testLinkedCellParallel()
positions, grid_delta, test_data.grid_min, test_data.grid_max,
test_data.test_radius, test_data.cell_size_ratio );

// Cabana::LinkedCellStencil<double> stencil(
// test_data.test_radius, test_data.cell_size_ratio, test_data.grid_min,
// test_data.grid_max );
// Cabana::LinkedCellStencil<double> stencil(
// test_data.test_radius, test_data.cell_size_ratio,
// test_data.grid_min, test_data.grid_max );

checkLinkedCellParallel( nlist, test_data.N2_list_copy,
test_data.num_particle, positions,
Expand Down
2 changes: 1 addition & 1 deletion core/unit_test/tstNeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void testModifyNeighbors()
//---------------------------------------------------------------------------//
// TESTS
//---------------------------------------------------------------------------//
//TEST( TEST_CATEGORY, linked_cell_stencil_test ) { testLinkedCellStencil(); }
// TEST( TEST_CATEGORY, linked_cell_stencil_test ) { testLinkedCellStencil(); }

//---------------------------------------------------------------------------//
TEST( TEST_CATEGORY, verlet_list_full_test )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void linkedCellListExample()
grid_delta,
grid_min, grid_max );
*/
Cabana::LinkedCellList<MemorySpace, double> cell_list( positions, grid_delta,
grid_min, grid_max, grid_delta[0] );
Cabana::LinkedCellList<MemorySpace, double> cell_list(
positions, grid_delta, grid_min, grid_max, grid_delta[0] );

/*
Now permute the AoSoA (i.e. reorder the data) using the linked cell list.
Expand Down

0 comments on commit f071fd1

Please sign in to comment.