1#ifndef included_AMP_CSRMatrixCommunicator_h
2#define included_AMP_CSRMatrixCommunicator_h
4#include "AMP/AMP_TPLs.h"
5#include "AMP/matrices/CSRConfig.h"
6#include "AMP/matrices/data/CSRLocalMatrixData.h"
7#include "AMP/utils/AMP_MPI.h"
8#include "AMP/utils/Memory.h"
9#include "AMP/vectors/CommunicationList.h"
18template<
typename Config>
22 using gidx_t =
typename Config::gidx_t;
23 using lidx_t =
typename Config::lidx_t;
27 static_assert( std::is_same_v<typename allocator_type::value_type, void> );
29 typename std::allocator_traits<allocator_type>::template rebind_alloc<gidx_t>;
31 typename std::allocator_traits<allocator_type>::template rebind_alloc<lidx_t>;
33 typename std::allocator_traits<allocator_type>::template rebind_alloc<scalar_t>;
36 using ConfigHost =
typename Config::template set_alloc<alloc::host>::type;
50 const bool flip_sendrecv =
false )
60 auto send_sizes = !flip_sendrecv ? comm_list->getSendSizes() : comm_list->getReceiveSizes();
62 if ( send_sizes[n] > 0 ) {
66 auto recv_sizes = !flip_sendrecv ? comm_list->getReceiveSizes() : comm_list->getSendSizes();
68 if ( recv_sizes[n] > 0 ) {
77 std::make_shared<CSRMatrixCommunicator<ConfigHost>>( comm_list, flip_sendrecv );
81 void sendMatrices(
const std::map<
int, std::shared_ptr<localmatrixdata_t>> &matrices );
82 std::map<int, std::shared_ptr<localmatrixdata_t>>
86 void migrateToHost(
const std::map<
int, std::shared_ptr<localmatrixdata_t>> &matrices );
90 void countSources(
const std::map<
int, std::shared_ptr<localmatrixdata_t>> &matrices );
111#if defined( AMP_GPU_AWARE_MPI )
114#elif defined( AMP_USE_DEVICE )
117 static constexpr bool MIGRATE_DEV = std::is_same_v<allocator_type, AMP::DeviceAllocator<void>>;
Provides C++ wrapper around MPI routines.
typename std::allocator_traits< allocator_type >::template rebind_alloc< scalar_t > scalarAllocator_t
typename Config::scalar_t scalar_t
typename std::allocator_traits< allocator_type >::template rebind_alloc< lidx_t > lidxAllocator_t
typename std::allocator_traits< allocator_type >::template rebind_alloc< gidx_t > gidxAllocator_t
std::vector< int > d_allowed_dest
std::shared_ptr< CSRMatrixCommunicator< ConfigHost > > d_migrate_comm
std::map< int, std::shared_ptr< CSRLocalMatrixData< ConfigHost > > > d_send_mat_migrate
std::vector< AMP_MPI::Request > d_send_requests
typename Config::allocator_type allocator_type
std::map< int, std::shared_ptr< localmatrixdata_t > > migrateFromHost(const std::map< int, std::shared_ptr< CSRLocalMatrixData< ConfigHost > > > &matrices)
void countSources(const std::map< int, std::shared_ptr< localmatrixdata_t > > &matrices)
typename Config::template set_alloc< alloc::host >::type ConfigHost
typename Config::gidx_t gidx_t
typename Config::lidx_t lidx_t
static constexpr bool MIGRATE_DEV
CSRMatrixCommunicator(std::shared_ptr< CommunicationList > comm_list, const bool flip_sendrecv=false)
std::map< int, std::shared_ptr< localmatrixdata_t > > recvMatrices(gidx_t first_row, gidx_t last_row, gidx_t first_col, gidx_t last_col)
void sendMatrices(const std::map< int, std::shared_ptr< localmatrixdata_t > > &matrices)
void migrateToHost(const std::map< int, std::shared_ptr< localmatrixdata_t > > &matrices)
int d_num_allowed_sources
AMP_MPI getComm(const TYPE &obj)
Return the underlying MPI class for the object.