Skip to content

Commit

Permalink
fixup: get LinkedCellList memory space from positions
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed May 20, 2024
1 parent ec1acc4 commit a669113
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion benchmark/core/Cabana_LinkedCellPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
double sort_delta[3] = { cutoff, cutoff, cutoff };
double grid_min[3] = { x_min[p], x_min[p], x_min[p] };
double grid_max[3] = { x_max[p], x_max[p], x_max[p] };
auto linked_cell_list = Cabana::createLinkedCellList<memory_space>(
auto linked_cell_list = Cabana::createLinkedCellList(
x, sort_delta, grid_min, grid_max );

// Setup for neighbor iteration.
Expand Down
2 changes: 1 addition & 1 deletion benchmark/core/Cabana_NeighborVerletPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
// in cells the size of the smallest cutoff distance.
double cutoff = cutoff_ratios.front();
double sort_delta[3] = { cutoff, cutoff, cutoff };
auto linked_cell_list = Cabana::createLinkedCellList<memory_space>(
auto linked_cell_list = Cabana::createLinkedCellList(
x, sort_delta, grid_min, grid_max );
Cabana::permute( linked_cell_list, aosoas[p] );
}
Expand Down
30 changes: 15 additions & 15 deletions core/src/Cabana_LinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,30 +730,30 @@ class LinkedCellList
\brief Creation function for linked cell list.
\return LinkedCellList.
*/
template <class MemorySpace, class SliceType, class Scalar,
std::size_t NumSpaceDim = 3>
template <class SliceType, class Scalar, std::size_t NumSpaceDim = 3>
auto createLinkedCellList( SliceType positions,
const Scalar grid_delta[NumSpaceDim],
const Scalar grid_min[NumSpaceDim],
const Scalar grid_max[NumSpaceDim] )
{
return LinkedCellList<MemorySpace, Scalar>( positions, grid_delta, grid_min,
grid_max );
using memory_space = typename SliceType::memory_space;
return LinkedCellList<memory_space, Scalar>( positions, grid_delta,
grid_min, grid_max );
}

/*!
\brief Creation function for linked cell list with partial range.
\return LinkedCellList.
*/
template <class MemorySpace, class SliceType, class Scalar,
std::size_t NumSpaceDim = 3>
template <class SliceType, class Scalar, std::size_t NumSpaceDim = 3>
auto createLinkedCellList( SliceType positions, const std::size_t begin,
const std::size_t end,
const Scalar grid_delta[NumSpaceDim],
const Scalar grid_min[NumSpaceDim],
const Scalar grid_max[NumSpaceDim] )
{
return LinkedCellList<MemorySpace, Scalar>(
using memory_space = typename SliceType::memory_space;
return LinkedCellList<memory_space, Scalar>(
positions, begin, end, grid_delta, grid_min, grid_max );
}

Expand All @@ -762,27 +762,26 @@ auto createLinkedCellList( SliceType positions, const std::size_t begin,
cell ratio.
\return LinkedCellList.
*/
template <class MemorySpace, class SliceType, class Scalar,
std::size_t NumSpaceDim = 3>
template <class SliceType, class Scalar, std::size_t NumSpaceDim = 3>
auto createLinkedCellList( SliceType positions,
const Scalar grid_delta[NumSpaceDim],
const Scalar grid_min[NumSpaceDim],
const Scalar grid_max[NumSpaceDim],
const Scalar neighborhood_radius,
const Scalar cell_size_ratio = 1.0 )
{
return LinkedCellList<MemorySpace, Scalar>( positions, grid_delta, grid_min,
grid_max, neighborhood_radius,
cell_size_ratio );
using memory_space = typename SliceType::memory_space;
return LinkedCellList<memory_space, Scalar>(
positions, grid_delta, grid_min, grid_max, neighborhood_radius,
cell_size_ratio );
}

/*!
\brief Creation function for linked cell list with partial range and custom
cutoff radius and/or cell ratio.
\return LinkedCellList.
*/
template <class MemorySpace, class SliceType, class Scalar,
std::size_t NumSpaceDim = 3>
template <class SliceType, class Scalar, std::size_t NumSpaceDim = 3>
auto createLinkedCellList( SliceType positions, const std::size_t begin,
const std::size_t end,
const Scalar grid_delta[NumSpaceDim],
Expand All @@ -791,7 +790,8 @@ auto createLinkedCellList( SliceType positions, const std::size_t begin,
const Scalar neighborhood_radius,
const Scalar cell_size_ratio = 1.0 )
{
return LinkedCellList<MemorySpace, Scalar>(
using memory_space = typename SliceType::memory_space;
return LinkedCellList<memory_space, Scalar>(
positions, begin, end, grid_delta, grid_min, grid_max,
neighborhood_radius, cell_size_ratio );
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/Cabana_VerletList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ struct VerletListBuilder
for ( std::size_t d = 0; d < num_space_dim; ++d )
grid_delta[d] = grid_size;

linked_cell_list = createLinkedCellList<memory_space>(
position, grid_delta, grid_min, grid_max, neighborhood_radius,
cell_size_ratio );
linked_cell_list =
createLinkedCellList( 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
14 changes: 7 additions & 7 deletions core/unit_test/tstLinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void testLinkedList()
{
auto begin = test_data.begin;
auto end = test_data.end;
auto cell_list = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto cell_list = Cabana::createLinkedCellList(
pos, begin, end, grid_delta, grid_min, grid_max,
test_data.grid_delta[0], 1.0 );
Cabana::permute( cell_list, test_data.aosoa );
Expand All @@ -351,7 +351,7 @@ void testLinkedList()

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

Expand All @@ -376,7 +376,7 @@ void testLinkedListSlice()
{
auto begin = test_data.begin;
auto end = test_data.end;
auto cell_list = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto cell_list = Cabana::createLinkedCellList(
pos, begin, end, grid_delta, grid_min, grid_max, grid_delta[0] );
Cabana::permute( cell_list, pos );

Expand All @@ -387,7 +387,7 @@ void testLinkedListSlice()
}
// Now bin and permute all of the particles.
{
auto cell_list = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto cell_list = Cabana::createLinkedCellList(
pos, grid_delta, grid_min, grid_max, grid_delta[0] );
Cabana::permute( cell_list, pos );

Expand Down Expand Up @@ -640,7 +640,7 @@ void testLinkedCellNeighborInterface()
// Create the linked cell list.
double grid_size = test_data.cell_size_ratio * test_data.test_radius;
double grid_delta[3] = { grid_size, grid_size, grid_size };
auto nlist = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto nlist = Cabana::createLinkedCellList(
positions, test_data.begin, test_data.end, grid_delta,
test_data.grid_min, test_data.grid_max, test_data.test_radius,
test_data.cell_size_ratio );
Expand All @@ -665,7 +665,7 @@ void testLinkedCellParallel()
// Create the linked cell list.
double grid_size = test_data.cell_size_ratio * test_data.test_radius;
double grid_delta[3] = { grid_size, grid_size, grid_size };
auto nlist = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto nlist = Cabana::createLinkedCellList(
positions, test_data.begin, test_data.end, grid_delta,
test_data.grid_min, test_data.grid_max, test_data.test_radius,
test_data.cell_size_ratio );
Expand All @@ -690,7 +690,7 @@ void testLinkedCellReduce()
// Create the linked cell list.
double grid_size = test_data.cell_size_ratio * test_data.test_radius;
double grid_delta[3] = { grid_size, grid_size, grid_size };
auto nlist = Cabana::createLinkedCellList<TEST_MEMSPACE>(
auto nlist = Cabana::createLinkedCellList(
positions, test_data.begin, test_data.end, grid_delta,
test_data.grid_min, test_data.grid_max, test_data.test_radius,
test_data.cell_size_ratio );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ void linkedCellListExample()
exercise, try adding both start and end (int) inputs to define a subset
range of particles to permute:
auto cell_list = Cabana::createLinkedCellList<MemorySpace>(
auto cell_list = Cabana::createLinkedCellList(
positions, start, end, grid_delta, grid_min, grid_max );
*/
auto cell_list = Cabana::createLinkedCellList<MemorySpace>(
positions, grid_delta, grid_min, grid_max );
auto cell_list = Cabana::createLinkedCellList( positions, grid_delta,
grid_min, grid_max );

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

0 comments on commit a669113

Please sign in to comment.