13#define uint unsigned int
22 :
chi_mesh::sweep_management::AsynchronousCommunicator(fluds, comm_set),
23 angle_set_id_(angle_set_id),
24 cbc_fluds_(dynamic_cast<
CBC_FLUDS&>(fluds))
30 uint64_t cell_global_id,
35 MessageKey key{location_id, cell_global_id, face_id};
39 data.assign(data_size, 0.0);
53 std::map<MPIRank, BufferItem> locI_buffer_map;
57 const MPIRank locI = std::get<0>(msg_key);
58 const uint64_t cell_global_id = std::get<1>(msg_key);
59 const uint face_id = std::get<2>(msg_key);
60 const size_t data_size = data.size();
62 BufferItem& buffer_item = locI_buffer_map[locI];
67 buffer_array.
Write(cell_global_id);
68 buffer_array.Write(face_id);
69 buffer_array.Write(data_size);
71 for (
const double value : data)
72 buffer_array.Write(value);
75 for (
auto& [locI, buffer] : locI_buffer_map)
82 bool all_messages_sent =
true;
85 if (not buffer_item.send_initiated_)
87 const int locJ = buffer_item.destination_;
89 MPI_Isend(buffer_item.data_array_.Data().data(),
90 static_cast<int>(buffer_item.data_array_.Size()),
95 &buffer_item.mpi_request_));
96 buffer_item.send_initiated_ =
true;
99 if (not buffer_item.completed_)
103 MPI_Test(&buffer_item.mpi_request_, &sent, MPI_STATUS_IGNORE));
104 if (sent) buffer_item.completed_ =
true;
106 all_messages_sent =
false;
110 return all_messages_sent;
115 typedef std::pair<uint64_t, uint> CellFaceKey;
117 std::map<CellFaceKey, std::vector<double>> received_messages;
118 std::vector<uint64_t> cells_who_received_data;
120 for (
int locJ : location_dependencies)
122 int message_available = 0;
131 if (message_available)
134 MPI_Get_count(&status, MPI_BYTE, &num_items);
135 std::vector<std::byte> recv_buffer(num_items);
137 MPI_Recv(recv_buffer.data(),
149 const uint64_t cell_global_id = data_array.
Read<uint64_t>();
151 const size_t data_size = data_array.
Read<
size_t>();
153 std::vector<double> psi_data;
154 psi_data.reserve(data_size);
155 for (
size_t k = 0; k < data_size; ++k)
156 psi_data.push_back(data_array.
Read<
double>());
158 received_messages[{cell_global_id, face_id}] = std::move(psi_data);
159 cells_who_received_data.push_back(
167 return cells_who_received_data;
static chi::MPI_Info & mpi
MPI_Comm LocICommunicator(int locI) const
int MapIonJ(int locI, int locJ) const
static void Call(int mpi_error_code)
const int & location_id
Current process rank.
void Write(const T &value)
size_t MapCellGlobalID2LocalID(uint64_t global_id) const
const chi::ChiMPICommunicatorSet & comm_set_
const SPDS & GetSPDS() const
const chi_mesh::MeshContinuum & Grid() const
const VecInt & GetLocationDependencies() const
CBC_ASynchronousCommunicator(size_t angle_set_id, chi_mesh::sweep_management::FLUDS &fluds, const chi::ChiMPICommunicatorSet &comm_set)
const size_t angle_set_id_
std::vector< BufferItem > send_buffer_
std::vector< uint64_t > ReceiveData()
std::vector< double > & InitGetDownwindMessageData(int location_id, uint64_t cell_global_id, unsigned int face_id, size_t angle_set_id, size_t data_size) override
std::tuple< int, uint64_t, unsigned int > MessageKey
std::map< MessageKey, std::vector< double > > outgoing_message_queue_
std::map< CellFaceKey, std::vector< double > > & DeplocsOutgoingMessages()
chi_data_types::ByteArray data_array_