Chi-Tech
AAH_AsynComm_receivedelayeddata.cc
Go to the documentation of this file.
1#include "AAH_AsynComm.h"
2
5
7
8#include "chi_runtime.h"
9#include "chi_log.h"
10#include "chi_mpi.h"
11
12// ###################################################################
13/** Receives delayed data from successor locations. */
15 int angle_set_num)
16{
17 const auto& spds = fluds_.GetSPDS();
18
19 const auto& delayed_location_dependencies =
21 const size_t num_delayed_loc_deps = delayed_location_dependencies.size();
22
23 //======================================== Receive delayed data
24 bool all_messages_received = true;
25 for (size_t prelocI = 0; prelocI < num_delayed_loc_deps; prelocI++)
26 {
27 int locJ = delayed_location_dependencies[prelocI];
28
29 int num_mess = delayed_prelocI_message_count[prelocI];
30 for (int m = 0; m < num_mess; m++)
31 {
32 if (not delayed_prelocI_message_received[prelocI][m])
33 {
34 int message_available = 0;
35 MPI_Iprobe(comm_set_.MapIonJ(locJ, Chi::mpi.location_id),
36 max_num_mess * angle_set_num + m, // tag
38 &message_available,
39 MPI_STATUS_IGNORE);
40
41 if (not message_available)
42 {
43 all_messages_received = false;
44 continue;
45 }
46
47 //============================ Receive upstream data
48 auto& upstream_psi =
50
51 u_ll_int block_addr = delayed_prelocI_message_blockpos[prelocI][m];
52 u_ll_int message_size = delayed_prelocI_message_size[prelocI][m];
53
54 int error_code =
55 MPI_Recv(&upstream_psi[block_addr],
56 static_cast<int>(message_size),
57 MPI_DOUBLE,
59 max_num_mess * angle_set_num + m, // tag
61 MPI_STATUS_IGNORE);
62
63 delayed_prelocI_message_received[prelocI][m] = true;
64
65 if (error_code != MPI_SUCCESS)
66 {
67 std::stringstream err_stream;
68 err_stream << "################# Delayed receive error."
69 << " message size=" << message_size
70 << " as_num=" << angle_set_num << " num_mess=" << num_mess
71 << " m=" << m << " error="
72 << " size="
73 << "\n";
74 char error_string[BUFSIZ];
75 int length_of_error_string, error_class;
76 MPI_Error_class(error_code, &error_class);
77 MPI_Error_string(error_class, error_string, &length_of_error_string);
78 err_stream << error_string << "\n";
79 MPI_Error_string(error_code, error_string, &length_of_error_string);
80 err_stream << error_string << "\n";
81 Chi::log.LogAllWarning() << err_stream.str();
82 }
83 } // if not message already received
84 } // for message
85 } // for delayed predecessor
86
87 if (not all_messages_received) return false;
88
89 return true;
90}
unsigned long long int u_ll_int
Definition: AAH_AsynComm.h:9
static chi::ChiLog & log
Definition: chi_runtime.h:81
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
LogStream LogAllWarning()
Definition: chi_log.h:238
MPI_Comm LocICommunicator(int locI) const
int MapIonJ(int locI, int locJ) const
const int & location_id
Current process rank.
Definition: mpi_info.h:26
std::vector< std::vector< u_ll_int > > delayed_prelocI_message_blockpos
Definition: AAH_AsynComm.h:46
std::vector< std::vector< u_ll_int > > delayed_prelocI_message_size
Definition: AAH_AsynComm.h:42
std::vector< std::vector< bool > > delayed_prelocI_message_received
Definition: AAH_AsynComm.h:49
const chi::ChiMPICommunicatorSet & comm_set_
Definition: AsyncComm.h:36
virtual std::vector< std::vector< double > > & DelayedPrelocIOutgoingPsi()=0
const SPDS & GetSPDS() const
Definition: FLUDS.h:31
const VecInt & GetDelayedLocationDependencies() const
Definition: SPDS.h:34