Click here to Skip to main content
15,895,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: me vs. VS2022.. detecting NULL pointers Pin
Mircea Neacsu29-Feb-24 12:24
Mircea Neacsu29-Feb-24 12:24 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
charlieg29-Feb-24 15:41
charlieg29-Feb-24 15:41 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
Mircea Neacsu29-Feb-24 16:39
Mircea Neacsu29-Feb-24 16:39 
QuestionDATASET Pin
Aryan Gupta 202429-Feb-24 6:51
Aryan Gupta 202429-Feb-24 6:51 
AnswerRe: DATASET Pin
Dave Kreskowiak29-Feb-24 9:34
mveDave Kreskowiak29-Feb-24 9:34 
AnswerRe: DATASET Pin
Richard Deeming29-Feb-24 21:34
mveRichard Deeming29-Feb-24 21:34 
GeneralRe: DATASET Pin
CPallini1-Mar-24 1:52
mveCPallini1-Mar-24 1:52 
QuestionHow to recover missing file ? Pin
Salvatore Terress28-Feb-24 6:08
Salvatore Terress28-Feb-24 6:08 
AnswerRe: How to recover missing file ? Pin
Maximilien28-Feb-24 7:37
Maximilien28-Feb-24 7:37 
GeneralRe: How to recover missing file ? Pin
Salvatore Terress28-Feb-24 10:51
Salvatore Terress28-Feb-24 10:51 
QuestionRe: How to recover missing file ? Pin
Richard MacCutchan28-Feb-24 8:00
mveRichard MacCutchan28-Feb-24 8:00 
AnswerRe: How to recover missing file ? Pin
jschell28-Feb-24 12:26
jschell28-Feb-24 12:26 
AnswerRe: How to recover missing file ? Pin
k505428-Feb-24 12:34
mvek505428-Feb-24 12:34 
GeneralRe: How to recover missing file ? Pin
Salvatore Terress29-Feb-24 1:11
Salvatore Terress29-Feb-24 1:11 
GeneralRe: How to recover missing file ? Pin
k505429-Feb-24 5:19
mvek505429-Feb-24 5:19 
GeneralRe: How to recover missing file ? Pin
jschell29-Feb-24 12:24
jschell29-Feb-24 12:24 
GeneralRe: How to recover missing file ? Pin
k505429-Feb-24 12:50
mvek505429-Feb-24 12:50 
QuestionMpi blocking communication Pin
Member 1518121126-Feb-24 11:19
Member 1518121126-Feb-24 11:19 
I'm currently working on a lattice Boltzmann code (D3Q27) employing MPI for parallelization. I've implemented MPI 3D topology for communication, and my code snippet handles communication as follows, I also have the same structure for the communication between front-back and up-down.

void Simulation::Communicate(int iter) {

int tag_xp = 0;
int tag_xm = 1;
int tag_yp = 2;
int tag_ym = 3;
int tag_zp = 4;
int tag_zm = 5;

MPI_Status status;

if (SubDomain_.my_right_ != MPI_PROC_NULL) {
std::vector<double> send_data;
for (int k = 0; k < SubDomain_.my_Nz_; k++) {
for (int j = 0; j < SubDomain_.my_Ny_; j++) {

if (SubDomain_.lattice_[SubDomain_.my_Nx_ - 2][j][k] == nullptr) {
for (int dir = 0; dir < _nLatNodes; dir++) {

send_data.push_back(0.0);

}
}
else {

for (int dir = 0; dir < _nLatNodes; dir++) {
send_data.push_back(SubDomain_.lattice_[SubDomain_.my_Nx_ - 2][j][k]->m_distributions[dir]);

}
}

}
}

std::vector<double> recv_data(send_data.size());

MPI_Sendrecv(send_data.data(), send_data.size(), MPI_DOUBLE, SubDomain_.my_right_, tag_xp,
recv_data.data(), recv_data.size(), MPI_DOUBLE, SubDomain_.my_right_, tag_xm,
MPI_COMM_WORLD, &status);


int index = 0;
for (int k = 0; k < SubDomain_.my_Nz_; k++) {
for (int j = 0; j < SubDomain_.my_Ny_; j++) {
for (int dir = 0; dir < _nLatNodes; dir++) {
SubDomain_.lattice_[SubDomain_.my_Nx_ - 1][j][k]->m_distributions[dir] = recv_data[index];
index++;
}
}
}

}


if (SubDomain_.my_left_ != MPI_PROC_NULL) {
std::vector<double> send_data;
for (int k = 0; k < SubDomain_.my_Nz_; k++) {
for (int j = 0; j < SubDomain_.my_Ny_; j++) {

if (SubDomain_.lattice_[1][j][k] == nullptr) {
for (int dir = 0; dir < _nLatNodes; dir++) {
send_data.push_back(0.0);
}
}
else {

for (int dir = 0; dir < _nLatNodes; dir++) {
send_data.push_back(SubDomain_.lattice_[1][j][k]->m_distributions[dir]);
}

}
}
}

std::vector<double> recv_data(send_data.size());
MPI_Sendrecv(send_data.data(), send_data.size(), MPI_DOUBLE, SubDomain_.my_left_, tag_xm,
recv_data.data(), recv_data.size(), MPI_DOUBLE, SubDomain_.my_left_, tag_xp,
MPI_COMM_WORLD, &status);
int index = 0;
for (int k = 0; k < SubDomain_.my_Nz_; k++) {
for (int j = 0; j < SubDomain_.my_Ny_; j++) {
for (int dir = 0; dir < _nLatNodes; dir++) {
SubDomain_.lattice_[0][j][k]->m_distributions[dir] = recv_data[index];
index++;
}
}
}
}
}


While I can verify that communication occurs correctly by printing sent and received data, upon visualization, it appears that the data might not be transferring to neighboring processors as expected, despite not being zeroed out (as previously confirmed through printing). After each iteration, I visualize the velocity components obtained via the Lattice Boltzmann Method (LBM). My observation reveals that the fluid dynamics are solely resolved within the processor featuring the inlet boundary condition, while all other processors exhibit a velocity of zero. This suggests that data transfer to neighboring processors might not be occurring as expected.

I have a couple of concerns:

Could data corruption arise from blocking communication? Is diagonal communication necessary? My understanding is that if communication in the normal directions (x, y, and z) is established, diagonal communication implicitly occurs. Additionally, I'm uncertain about the order of communication. Do all communications happen simultaneously, or is it sequential (e.g., right and left, then front and back, then up and down)? If they're not simultaneous, would diagonal communication be required?

I also have a confusion in receiver processor id. for example

MPI_Sendrecv(send_data.data(), send_data.size(), MPI_DOUBLE, SubDomain_.my_right_, tag_xp, recv_data.data(), recv_data.size(), MPI_DOUBLE, SubDomain_.my_right_, tag_xm, MPI_COMM_WORLD, &status); should it be SubDomain_.myrank_, instead of SubDomain_.my_right_ in receive part?

I'd appreciate any insights to clarify these points of confusion. Thank you!
AnswerRe: Mpi blocking communication Pin
jschell26-Feb-24 12:22
jschell26-Feb-24 12:22 
Questionhow to "include" this... Pin
Salvatore Terress26-Feb-24 8:37
Salvatore Terress26-Feb-24 8:37 
AnswerRe: how to "include" this... Pin
Richard MacCutchan26-Feb-24 9:09
mveRichard MacCutchan26-Feb-24 9:09 
AnswerRe: how to "include" this... Pin
jschell26-Feb-24 12:25
jschell26-Feb-24 12:25 
GeneralRe: how to "include" this... Pin
Salvatore Terress26-Feb-24 16:48
Salvatore Terress26-Feb-24 16:48 
GeneralRe: how to "include" this... Pin
RedDk27-Feb-24 7:51
RedDk27-Feb-24 7:51 
AnswerRe: how to "include" this... Pin
Maximilien27-Feb-24 1:32
Maximilien27-Feb-24 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.