16#ifndef CABANA_COMMUNICATIONPLAN_HPP
17#define CABANA_COMMUNICATIONPLAN_HPP
21#include <Kokkos_Core.hpp>
22#include <Kokkos_ScatterView.hpp>
40struct CountSendsAndCreateSteeringDuplicated
43struct CountSendsAndCreateSteeringAtomic
49template <
class ExecutionSpace>
50struct CountSendsAndCreateSteeringAlgorithm;
53#ifdef KOKKOS_ENABLE_CUDA
55struct CountSendsAndCreateSteeringAlgorithm<Kokkos::Cuda>
57 using type = CountSendsAndCreateSteeringAtomic;
60#ifdef KOKKOS_ENABLE_HIP
62struct CountSendsAndCreateSteeringAlgorithm<Kokkos::Experimental::HIP>
64 using type = CountSendsAndCreateSteeringAtomic;
67#ifdef KOKKOS_ENABLE_SYCL
69struct CountSendsAndCreateSteeringAlgorithm<Kokkos::Experimental::SYCL>
71 using type = CountSendsAndCreateSteeringAtomic;
74#ifdef KOKKOS_ENABLE_OPENMPTARGET
76struct CountSendsAndCreateSteeringAlgorithm<Kokkos::Experimental::OpenMPTarget>
78 using type = CountSendsAndCreateSteeringAtomic;
83template <
class ExecutionSpace>
84struct CountSendsAndCreateSteeringAlgorithm
86 using type = CountSendsAndCreateSteeringDuplicated;
91template <
class ExecutionSpace,
class ExportRankView>
92auto countSendsAndCreateSteering( ExecutionSpace,
93 const ExportRankView element_export_ranks,
95 CountSendsAndCreateSteeringAtomic )
96 -> std::pair<Kokkos::View<int*, typename ExportRankView::memory_space>,
97 Kokkos::View<
typename ExportRankView::size_type*,
98 typename ExportRankView::memory_space>>
100 using memory_space =
typename ExportRankView::memory_space;
101 using size_type =
typename ExportRankView::size_type;
104 Kokkos::View<int*, memory_space> neighbor_counts(
"neighbor_counts",
106 Kokkos::View<size_type*, memory_space> neighbor_ids(
107 Kokkos::ViewAllocateWithoutInitializing(
"neighbor_ids" ),
108 element_export_ranks.size() );
114 if ( comm_size <= 64 )
116 constexpr int team_size = 256;
117 Kokkos::TeamPolicy<ExecutionSpace> team_policy(
118 ( element_export_ranks.size() + team_size - 1 ) / team_size,
120 team_policy = team_policy.set_scratch_size(
122 Kokkos::PerTeam(
sizeof(
int ) * ( team_size + 2 * comm_size ) ) );
123 Kokkos::parallel_for(
124 "Cabana::CommunicationPlan::countSendsAndCreateSteeringShared",
127 const typename Kokkos::TeamPolicy<ExecutionSpace>::member_type&
135 int* scratch = (
int*)team.team_shmem().get_shmem(
136 ( team.team_size() + 2 * comm_size ) *
sizeof(
int ), 0 );
140 int* local_neighbor_ids = scratch;
142 int* histo = local_neighbor_ids + team.team_size();
144 int* global_offset = histo + comm_size;
147 team.team_rank() + team.league_rank() * team.team_size();
149 const int local_id = team.team_rank();
151 const int num_elements = element_export_ranks.size();
153 const int my_element_export_rank =
154 ( tid < num_elements ? element_export_ranks( tid ) : -1 );
158 const bool in_bounds =
159 tid < num_elements && my_element_export_rank >= 0;
161 Kokkos::parallel_for(
162 Kokkos::TeamThreadRange( team, comm_size ),
163 [&](
const int i ) { histo[i] = 0; } );
172 local_neighbor_ids[local_id] = Kokkos::atomic_fetch_add(
173 &histo[my_element_export_rank], 1 );
180 Kokkos::parallel_for(
181 Kokkos::TeamThreadRange( team, comm_size ),
185 global_offset[i] = Kokkos::atomic_fetch_add(
186 &neighbor_counts( i ), histo[i] );
195 neighbor_ids( tid ) =
196 global_offset[my_element_export_rank] +
197 local_neighbor_ids[local_id];
206 Kokkos::parallel_for(
207 "Cabana::CommunicationPlan::countSendsAndCreateSteering",
208 Kokkos::RangePolicy<ExecutionSpace>( 0,
209 element_export_ranks.size() ),
210 KOKKOS_LAMBDA(
const size_type i ) {
211 if ( element_export_ranks( i ) >= 0 )
212 neighbor_ids( i ) = Kokkos::atomic_fetch_add(
213 &neighbor_counts( element_export_ranks( i ) ), 1 );
219 return std::make_pair( neighbor_counts, neighbor_ids );
224template <
class ExecutionSpace,
class ExportRankView>
225auto countSendsAndCreateSteering( ExecutionSpace,
226 const ExportRankView element_export_ranks,
228 CountSendsAndCreateSteeringDuplicated )
229 -> std::pair<Kokkos::View<int*, typename ExportRankView::memory_space>,
230 Kokkos::View<
typename ExportRankView::size_type*,
231 typename ExportRankView::memory_space>>
233 using memory_space =
typename ExportRankView::memory_space;
234 using size_type =
typename ExportRankView::size_type;
237 Kokkos::Experimental::UniqueToken<
238 ExecutionSpace, Kokkos::Experimental::UniqueTokenScope::Global>
242 Kokkos::View<int*, memory_space> neighbor_counts(
243 Kokkos::ViewAllocateWithoutInitializing(
"neighbor_counts" ),
245 Kokkos::View<size_type*, memory_space> neighbor_ids(
246 Kokkos::ViewAllocateWithoutInitializing(
"neighbor_ids" ),
247 element_export_ranks.size() );
248 Kokkos::View<int**, memory_space> neighbor_counts_dup(
249 "neighbor_counts", unique_token.size(), comm_size );
250 Kokkos::View<size_type**, memory_space> neighbor_ids_dup(
251 "neighbor_ids", unique_token.size(), element_export_ranks.size() );
254 Kokkos::parallel_for(
255 "Cabana::CommunicationPlan::intialCount",
256 Kokkos::RangePolicy<ExecutionSpace>( 0, element_export_ranks.size() ),
257 KOKKOS_LAMBDA(
const size_type i ) {
258 if ( element_export_ranks( i ) >= 0 )
261 auto thread_id = unique_token.acquire();
271 neighbor_ids_dup( thread_id, i ) = ++neighbor_counts_dup(
272 thread_id, element_export_ranks( i ) );
275 unique_token.release( thread_id );
282 Kokkos::TeamPolicy<ExecutionSpace, Kokkos::Schedule<Kokkos::Dynamic>>;
283 using index_type =
typename team_policy::index_type;
287 Kokkos::parallel_for(
288 "Cabana::CommunicationPlan::finalCount",
289 team_policy( neighbor_counts.extent( 0 ), Kokkos::AUTO ),
290 KOKKOS_LAMBDA(
const typename team_policy::member_type& team ) {
292 auto i = team.league_rank();
295 int thread_counts = 0;
296 Kokkos::parallel_reduce(
297 Kokkos::TeamThreadRange( team,
298 neighbor_counts_dup.extent( 0 ) ),
299 [&](
const index_type thread_id,
int& result )
300 { result += neighbor_counts_dup( thread_id, i ); },
302 neighbor_counts( i ) = thread_counts;
308 Kokkos::parallel_for(
309 "Cabana::CommunicationPlan::createSteering",
310 team_policy( element_export_ranks.size(), Kokkos::AUTO ),
311 KOKKOS_LAMBDA(
const typename team_policy::member_type& team ) {
313 auto i = team.league_rank();
316 if ( element_export_ranks( i ) >= 0 )
321 index_type dup_thread = 0;
322 Kokkos::parallel_reduce(
323 Kokkos::TeamThreadRange( team,
324 neighbor_ids_dup.extent( 0 ) ),
325 [&](
const index_type thread_id, index_type& result )
327 if ( neighbor_ids_dup( thread_id, i ) > 0 )
337 size_type thread_offset = 0;
338 Kokkos::parallel_reduce(
339 Kokkos::TeamThreadRange( team, dup_thread ),
340 [&](
const index_type thread_id, size_type& result ) {
341 result += neighbor_counts_dup(
342 thread_id, element_export_ranks( i ) );
350 thread_offset + neighbor_ids_dup( dup_thread, i ) - 1;
356 return std::make_pair( neighbor_counts, neighbor_ids );
371 std::vector<int> topology )
373 auto remove_end = std::remove( topology.begin(), topology.end(), -1 );
374 std::sort( topology.begin(), remove_end );
375 auto unique_end = std::unique( topology.begin(), remove_end );
376 topology.resize( std::distance( topology.begin(), unique_end ) );
380 MPI_Comm_rank( comm, &my_rank );
381 for (
auto& n : topology )
385 std::swap( n, topology[0] );
418template <
class MemorySpace>
427 static_assert( Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
430 using device_type [[deprecated]] =
typename memory_space::device_type;
439 using size_type =
typename memory_space::memory_space::size_type;
453 auto p = std::make_unique<MPI_Comm>();
454 MPI_Comm_dup(
comm, p.get() );
468 MPI_Comm
comm()
const {
return *_comm_ptr; }
484 return _neighbors[neighbor];
497 return _num_export[neighbor];
517 return _num_import[neighbor];
537 std::size_t
exportSize()
const {
return _num_export_element; }
550 return _export_steering;
594 template <
class ExecutionSpace,
class ViewType>
595 Kokkos::View<size_type*, memory_space>
597 const ViewType& element_export_ranks,
598 const std::vector<int>& neighbor_ranks )
603 _num_export_element = element_export_ranks.size();
607 int num_n = _neighbors.size();
611 MPI_Comm_size(
comm(), &comm_size );
615 MPI_Comm_rank(
comm(), &my_rank );
619 const int mpi_tag = 1221;
622 _num_export.assign( num_n, 0 );
623 _num_import.assign( num_n, 0 );
627 auto counts_and_ids = Impl::countSendsAndCreateSteering(
628 exec_space, element_export_ranks, comm_size,
629 typename Impl::CountSendsAndCreateSteeringAlgorithm<
630 ExecutionSpace>::type() );
633 auto neighbor_counts_host = Kokkos::create_mirror_view_and_copy(
634 Kokkos::HostSpace(), counts_and_ids.first );
637 for (
int n = 0; n < num_n; ++n )
638 _num_export[n] = neighbor_counts_host( _neighbors[n] );
641 std::vector<MPI_Request> requests;
642 requests.reserve( num_n );
643 for (
int n = 0; n < num_n; ++n )
644 if ( my_rank != _neighbors[n] )
646 requests.push_back( MPI_Request() );
647 MPI_Irecv( &_num_import[n], 1, MPI_UNSIGNED_LONG, _neighbors[n],
648 mpi_tag,
comm(), &( requests.back() ) );
651 _num_import[n] = _num_export[n];
654 for (
int n = 0; n < num_n; ++n )
655 if ( my_rank != _neighbors[n] )
656 MPI_Send( &_num_export[n], 1, MPI_UNSIGNED_LONG, _neighbors[n],
660 std::vector<MPI_Status> status( requests.size() );
662 MPI_Waitall( requests.size(), requests.data(), status.data() );
663 if ( MPI_SUCCESS != ec )
664 throw std::logic_error(
665 "Cabana::CommunicationPlan::createFromExportsAndTopology: "
666 "Failed MPI Communication" );
669 _total_num_export = std::accumulate(
670 _num_export.begin(), _num_export.end(), std::size_t{ 0u } );
671 _total_num_import = std::accumulate(
672 _num_import.begin(), _num_import.end(), std::size_t{ 0u } );
675 MPI_Barrier(
comm() );
678 return counts_and_ids.second;
716 template <
class ViewType>
717 Kokkos::View<size_type*, memory_space>
719 const std::vector<int>& neighbor_ranks )
756 template <
class ExecutionSpace,
class ViewType>
757 Kokkos::View<size_type*, memory_space>
759 const ViewType& element_export_ranks )
764 _num_export_element = element_export_ranks.size();
768 MPI_Comm_size(
comm(), &comm_size );
772 MPI_Comm_rank(
comm(), &my_rank );
776 const int mpi_tag = 1221;
780 auto counts_and_ids = Impl::countSendsAndCreateSteering(
781 exec_space, element_export_ranks, comm_size,
782 typename Impl::CountSendsAndCreateSteeringAlgorithm<
783 ExecutionSpace>::type() );
786 auto neighbor_counts_host = Kokkos::create_mirror_view_and_copy(
787 Kokkos::HostSpace(), counts_and_ids.first );
793 _total_num_export = 0;
794 for (
int r = 0; r < comm_size; ++r )
795 if ( neighbor_counts_host( r ) > 0 )
797 _neighbors.push_back( r );
798 _num_export.push_back( neighbor_counts_host( r ) );
799 _total_num_export += neighbor_counts_host( r );
800 neighbor_counts_host( r ) = 1;
805 int num_export_rank = _neighbors.size();
806 _num_import.assign( num_export_rank, 0 );
810 bool self_send =
false;
811 for (
int n = 0; n < num_export_rank; ++n )
812 if ( _neighbors[n] == my_rank )
814 std::swap( _neighbors[n], _neighbors[0] );
815 std::swap( _num_export[n], _num_export[0] );
816 _num_import[0] = _num_export[0];
822 int num_import_rank = -1;
823 std::vector<int> recv_counts( comm_size, 1 );
824 MPI_Reduce_scatter( neighbor_counts_host.data(), &num_import_rank,
825 recv_counts.data(), MPI_INT, MPI_SUM,
comm() );
831 std::vector<std::size_t> import_sizes( num_import_rank );
832 std::vector<MPI_Request> requests( num_import_rank );
833 for (
int n = 0; n < num_import_rank; ++n )
834 MPI_Irecv( &import_sizes[n], 1, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE,
835 mpi_tag,
comm(), &requests[n] );
838 int self_offset = ( self_send ) ? 1 : 0;
839 for (
int n = self_offset; n < num_export_rank; ++n )
840 MPI_Send( &_num_export[n], 1, MPI_UNSIGNED_LONG, _neighbors[n],
844 std::vector<MPI_Status> status( requests.size() );
846 MPI_Waitall( requests.size(), requests.data(), status.data() );
847 if ( MPI_SUCCESS != ec )
848 throw std::logic_error(
849 "Cabana::CommunicationPlan::createFromExportsOnly: Failed MPI "
854 std::accumulate( import_sizes.begin(), import_sizes.end(),
855 ( self_send ) ? _num_import[0] : 0 );
859 for (
int i = 0; i < num_import_rank; ++i )
862 const auto source = status[i].MPI_SOURCE;
866 auto found_neighbor =
867 std::find( _neighbors.begin(), _neighbors.end(), source );
871 if ( found_neighbor == std::end( _neighbors ) )
873 _neighbors.push_back( source );
874 _num_import.push_back( import_sizes[i] );
875 _num_export.push_back( 0 );
883 auto n = std::distance( _neighbors.begin(), found_neighbor );
884 _num_import[n] = import_sizes[i];
889 MPI_Barrier(
comm() );
892 return counts_and_ids.second;
923 template <
class ViewType>
924 Kokkos::View<size_type*, memory_space>
945 template <
class PackViewType,
class RankViewType>
947 const RankViewType& element_export_ranks )
950 createSteering(
true, neighbor_ids, element_export_ranks,
951 element_export_ranks );
973 template <
class PackViewType,
class RankViewType,
class IdViewType>
975 const RankViewType& element_export_ranks,
976 const IdViewType& element_export_ids )
978 createSteering(
false, neighbor_ids, element_export_ranks,
979 element_export_ids );
984 template <
class ExecutionSpace,
class PackViewType,
class RankViewType,
986 void createSteering( ExecutionSpace,
const bool use_iota,
987 const PackViewType& neighbor_ids,
988 const RankViewType& element_export_ranks,
989 const IdViewType& element_export_ids )
994 ( element_export_ids.size() != element_export_ranks.size() ) )
995 throw std::runtime_error(
996 "Cabana::CommunicationPlan::createSteering: Export ids and "
997 "ranks different sizes!" );
1001 MPI_Comm_size( *_comm_ptr, &comm_size );
1005 int num_n = _neighbors.size();
1006 std::vector<std::size_t> offsets( num_n, 0.0 );
1007 for (
int n = 1; n < num_n; ++n )
1008 offsets[n] = offsets[n - 1] + _num_export[n - 1];
1011 Kokkos::View<std::size_t*, Kokkos::HostSpace> rank_offsets_host(
1012 Kokkos::ViewAllocateWithoutInitializing(
"rank_map" ), comm_size );
1013 for (
int n = 0; n < num_n; ++n )
1014 rank_offsets_host( _neighbors[n] ) = offsets[n];
1015 auto rank_offsets = Kokkos::create_mirror_view_and_copy(
1021 _export_steering = Kokkos::View<std::size_t*, memory_space>(
1022 Kokkos::ViewAllocateWithoutInitializing(
"export_steering" ),
1023 _total_num_export );
1024 auto steer_vec = _export_steering;
1025 Kokkos::parallel_for(
1026 "Cabana::CommunicationPlan::createSteering",
1027 Kokkos::RangePolicy<ExecutionSpace>( 0, _num_export_element ),
1028 KOKKOS_LAMBDA(
const int i ) {
1029 if ( element_export_ranks( i ) >= 0 )
1030 steer_vec( rank_offsets( element_export_ranks( i ) ) +
1031 neighbor_ids( i ) ) =
1032 ( use_iota ) ? i : element_export_ids( i );
1037 template <
class PackViewType,
class RankViewType,
class IdViewType>
1038 void createSteering(
const bool use_iota,
const PackViewType& neighbor_ids,
1039 const RankViewType& element_export_ranks,
1040 const IdViewType& element_export_ids )
1044 element_export_ranks, element_export_ids );
1049 std::shared_ptr<MPI_Comm> _comm_ptr;
1050 std::vector<int> _neighbors;
1051 std::size_t _total_num_export;
1052 std::size_t _total_num_import;
1053 std::vector<std::size_t> _num_export;
1054 std::vector<std::size_t> _num_import;
1055 std::size_t _num_export_element;
1056 Kokkos::View<std::size_t*, memory_space> _export_steering;
1063template <
class AoSoAType>
1085 Kokkos::ViewAllocateWithoutInitializing(
"send_buffer" ), 0 );
1087 Kokkos::ViewAllocateWithoutInitializing(
"recv_buffer" ), 0 );
1114template <
class SliceType>
1127 typename Kokkos::View<data_type**, Kokkos::LayoutRight, memory_space>;
1139 Kokkos::ViewAllocateWithoutInitializing(
"send_buffer" ), 0, 0 );
1141 Kokkos::ViewAllocateWithoutInitializing(
"recv_buffer" ), 0, 0 );
1159 for ( std::size_t d = 2; d <
_particles.viewRank(); ++d )
1177template <
class CommPlanType,
class CommDataType>
1206 const double overallocation = 1.0 )
1251 if ( use_overallocation )
1256 _comm_data.reallocateSend( shrunk_send_size );
1257 _comm_data.reallocateReceive( shrunk_recv_size );
1264 template <
class ExecutionSpace>
1268 void reserveImpl(
const CommPlanType& comm_plan,
1270 const std::size_t total_send,
1271 const std::size_t total_recv,
1272 const double overallocation )
1274 if ( overallocation < 1.0 )
1275 throw std::runtime_error(
"Cabana::CommunicationPlan: "
1276 "Cannot allocate buffers with less space "
1277 "than data to communicate!" );
1280 reserveImpl( comm_plan, particles, total_send, total_recv );
1282 void reserveImpl(
const CommPlanType& comm_plan,
1284 const std::size_t total_send,
1285 const std::size_t total_recv )
1291 auto new_send_size =
static_cast<std::size_t
>(
1293 if ( new_send_size > send_capacity )
1297 auto new_recv_size =
static_cast<std::size_t
>(
1299 if ( new_recv_size > recv_capacity )
1300 _comm_data.reallocateReceive( new_recv_size );
void setData(const particle_data_type &particles)
Update particles to communicate.
Definition Cabana_CommunicationPlan.hpp:1221
auto sendCapacity()
Current allocated send buffer space.
Definition Cabana_CommunicationPlan.hpp:1239
typename plan_type::execution_space execution_space
Kokkos execution space.
Definition Cabana_CommunicationPlan.hpp:1184
void shrinkToFit(const bool use_overallocation=false)
Reduce communication buffers to current send/receive sizes.
Definition Cabana_CommunicationPlan.hpp:1247
auto receiveSize()
Current receive buffer size.
Definition Cabana_CommunicationPlan.hpp:1237
buffer_type getSendBuffer() const
Get the communication send buffer.
Definition Cabana_CommunicationPlan.hpp:1214
particle_data_type getData() const
Get the particles to communicate.
Definition Cabana_CommunicationPlan.hpp:1219
plan_type _comm_plan
Definition Cabana_CommunicationPlan.hpp:1312
std::size_t _recv_size
Definition Cabana_CommunicationPlan.hpp:1320
void apply(ExecutionSpace)
Perform the communication (migrate, gather, scatter).
typename comm_data_type::data_type data_type
Communication data type.
Definition Cabana_CommunicationPlan.hpp:1194
comm_data_type _comm_data
Definition Cabana_CommunicationPlan.hpp:1314
double _overallocation
Definition Cabana_CommunicationPlan.hpp:1316
typename comm_data_type::particle_data_type particle_data_type
Particle data type.
Definition Cabana_CommunicationPlan.hpp:1190
CommDataType comm_data_type
Communication data type.
Definition Cabana_CommunicationPlan.hpp:1188
Kokkos::RangePolicy< execution_space > policy_type
Kokkos execution policy.
Definition Cabana_CommunicationPlan.hpp:1186
typename comm_data_type::buffer_type buffer_type
Communication buffer type.
Definition Cabana_CommunicationPlan.hpp:1196
auto getSliceComponents()
Get the total number of components in the slice.
Definition Cabana_CommunicationPlan.hpp:1309
CommPlanType plan_type
Communication plan type (Halo, Distributor)
Definition Cabana_CommunicationPlan.hpp:1182
CommunicationData(const CommPlanType &comm_plan, const particle_data_type &particles, const double overallocation=1.0)
Definition Cabana_CommunicationPlan.hpp:1204
auto receiveCapacity()
Current allocated receive buffer space.
Definition Cabana_CommunicationPlan.hpp:1241
virtual void apply()=0
Perform the communication (migrate, gather, scatter).
auto sendSize()
Current send buffer size.
Definition Cabana_CommunicationPlan.hpp:1231
typename comm_data_type::memory_space memory_space
Kokkos memory space.
Definition Cabana_CommunicationPlan.hpp:1192
buffer_type getReceiveBuffer() const
Get the communication receive buffer.
Definition Cabana_CommunicationPlan.hpp:1216
std::size_t _send_size
Definition Cabana_CommunicationPlan.hpp:1318
Kokkos::View< size_type *, memory_space > createFromExportsOnly(ExecutionSpace exec_space, const ViewType &element_export_ranks)
Export rank creator. Use this when you don't know who you will receiving from - only who you are send...
Definition Cabana_CommunicationPlan.hpp:758
Kokkos::View< std::size_t *, memory_space > getExportSteering() const
Get the steering vector for the exports.
Definition Cabana_CommunicationPlan.hpp:548
std::size_t exportSize() const
Get the number of export elements.
Definition Cabana_CommunicationPlan.hpp:537
typename memory_space::memory_space::size_type size_type
Size type.
Definition Cabana_CommunicationPlan.hpp:439
typename MemorySpace::memory_space memory_space
Memory space.
Definition Cabana_CommunicationPlan.hpp:425
Kokkos::View< size_type *, memory_space > createFromExportsOnly(const ViewType &element_export_ranks)
Export rank creator. Use this when you don't know who you will receiving from - only who you are send...
Definition Cabana_CommunicationPlan.hpp:925
Kokkos::View< size_type *, memory_space > createFromExportsAndTopology(const ViewType &element_export_ranks, const std::vector< int > &neighbor_ranks)
Neighbor and export rank creator. Use this when you already know which ranks neighbor each other (i....
Definition Cabana_CommunicationPlan.hpp:718
int numNeighbor() const
Get the number of neighbor ranks that this rank will communicate with.
Definition Cabana_CommunicationPlan.hpp:475
void createExportSteering(const PackViewType &neighbor_ids, const RankViewType &element_export_ranks)
Create the export steering vector.
Definition Cabana_CommunicationPlan.hpp:946
std::size_t totalNumExport() const
Get the total number of exports this rank will do.
Definition Cabana_CommunicationPlan.hpp:505
MPI_Comm comm() const
Get the MPI communicator.
Definition Cabana_CommunicationPlan.hpp:468
std::size_t numExport(const int neighbor) const
Get the number of elements this rank will export to a given neighbor.
Definition Cabana_CommunicationPlan.hpp:495
std::size_t numImport(const int neighbor) const
Get the number of elements this rank will import from a given neighbor.
Definition Cabana_CommunicationPlan.hpp:515
std::size_t totalNumImport() const
Get the total number of imports this rank will do.
Definition Cabana_CommunicationPlan.hpp:525
int neighborRank(const int neighbor) const
Given a local neighbor id get its rank in the MPI communicator.
Definition Cabana_CommunicationPlan.hpp:482
Kokkos::View< size_type *, memory_space > createFromExportsAndTopology(ExecutionSpace exec_space, const ViewType &element_export_ranks, const std::vector< int > &neighbor_ranks)
Neighbor and export rank creator. Use this when you already know which ranks neighbor each other (i....
Definition Cabana_CommunicationPlan.hpp:596
void createExportSteering(const PackViewType &neighbor_ids, const RankViewType &element_export_ranks, const IdViewType &element_export_ids)
Create the export steering vector.
Definition Cabana_CommunicationPlan.hpp:974
CommunicationPlan(MPI_Comm comm)
Constructor.
Definition Cabana_CommunicationPlan.hpp:446
typename memory_space::execution_space execution_space
Default execution space.
Definition Cabana_CommunicationPlan.hpp:433
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
std::vector< int > getUniqueTopology(MPI_Comm comm, std::vector< int > topology)
Return unique neighbor ranks, with the current rank first.
Definition Cabana_CommunicationPlan.hpp:370
buffer_type _send_buffer
Send buffer.
Definition Cabana_CommunicationPlan.hpp:1102
void reallocateSend(const std::size_t num_send)
Resize the send buffer.
Definition Cabana_CommunicationPlan.hpp:1091
typename particle_data_type::tuple_type data_type
Communication data type.
Definition Cabana_CommunicationPlan.hpp:1073
AoSoAType particle_data_type
Particle data type.
Definition Cabana_CommunicationPlan.hpp:1069
buffer_type _recv_buffer
Receive buffer.
Definition Cabana_CommunicationPlan.hpp:1104
typename particle_data_type::memory_space memory_space
Kokkos memory space.
Definition Cabana_CommunicationPlan.hpp:1071
particle_data_type _particles
Particle AoSoA.
Definition Cabana_CommunicationPlan.hpp:1106
CommunicationDataAoSoA(particle_data_type particles)
Definition Cabana_CommunicationPlan.hpp:1081
typename Kokkos::View< data_type *, memory_space > buffer_type
Communication buffer type.
Definition Cabana_CommunicationPlan.hpp:1075
std::size_t _num_comp
Slice components.
Definition Cabana_CommunicationPlan.hpp:1108
void reallocateReceive(const std::size_t num_recv)
Resize the receive buffer.
Definition Cabana_CommunicationPlan.hpp:1096
void setSliceComponents()
Get the total number of components in the slice.
Definition Cabana_CommunicationPlan.hpp:1156
void reallocateSend(const std::size_t num_send)
Resize the send buffer.
Definition Cabana_CommunicationPlan.hpp:1145
buffer_type _send_buffer
Send buffer.
Definition Cabana_CommunicationPlan.hpp:1164
buffer_type _recv_buffer
Receive buffer.
Definition Cabana_CommunicationPlan.hpp:1166
void reallocateReceive(const std::size_t num_recv)
Resize the receive buffer.
Definition Cabana_CommunicationPlan.hpp:1150
typename Kokkos::View< data_type **, Kokkos::LayoutRight, memory_space > buffer_type
Communication buffer type.
Definition Cabana_CommunicationPlan.hpp:1126
typename particle_data_type::value_type data_type
Communication data type.
Definition Cabana_CommunicationPlan.hpp:1124
typename particle_data_type::memory_space memory_space
Kokkos memory space.
Definition Cabana_CommunicationPlan.hpp:1122
SliceType particle_data_type
Particle data type.
Definition Cabana_CommunicationPlan.hpp:1120
std::size_t _num_comp
Slice components.
Definition Cabana_CommunicationPlan.hpp:1170
particle_data_type _particles
Particle slice.
Definition Cabana_CommunicationPlan.hpp:1168
CommunicationDataSlice(particle_data_type particles)
Definition Cabana_CommunicationPlan.hpp:1133
Definition Cabana_Types.hpp:88
AoSoA static type checker.
Definition Cabana_AoSoA.hpp:61
Slice static type checker.
Definition Cabana_Slice.hpp:861