Skip to content
Snippets Groups Projects

Ensure to find all neighbors processes (especially with width interpolator)

Merged Berenger Bramas requested to merge bugfix/neighbors-processes-find into develop
1 file
+ 30
20
Compare changes
  • Side-by-side
  • Inline
@@ -166,7 +166,7 @@ public:
@@ -166,7 +166,7 @@ public:
int nbProcToRecvLower;
int nbProcToRecvLower;
{
{
int nextDestProc = my_rank;
int nextDestProc = my_rank;
for(int idxLower = 1 ; idxLower <= interpolation_size ; idxLower += partition_interval_size_per_proc[nextDestProc]){
for(int idxLower = 1 ; idxLower <= interpolation_size+1 ; idxLower += partition_interval_size_per_proc[nextDestProc]){
nextDestProc = (nextDestProc-1+nb_processes_involved)%nb_processes_involved;
nextDestProc = (nextDestProc-1+nb_processes_involved)%nb_processes_involved;
if(nextDestProc == my_rank){
if(nextDestProc == my_rank){
// We are back on our process
// We are back on our process
@@ -177,9 +177,11 @@ public:
@@ -177,9 +177,11 @@ public:
const int lowerRankDiff = (nextDestProc < my_rank ? my_rank - nextDestProc : nb_processes_involved-nextDestProc+my_rank);
const int lowerRankDiff = (nextDestProc < my_rank ? my_rank - nextDestProc : nb_processes_involved-nextDestProc+my_rank);
const int nbPartitionsToSend = std::min(current_partition_size, interpolation_size-(idxLower-1));
const int nbPartitionsToSend = std::min(current_partition_size, interpolation_size-(idxLower-1));
 
assert(nbPartitionsToSend >= 0);
const int nbParticlesToSend = current_offset_particles_for_partition[nbPartitionsToSend] - current_offset_particles_for_partition[0];
const int nbParticlesToSend = current_offset_particles_for_partition[nbPartitionsToSend] - current_offset_particles_for_partition[0];
const int nbPartitionsToRecv = std::min(partition_interval_size_per_proc[destProc], (interpolation_size+1)-(idxLower-1));
const int nbPartitionsToRecv = std::min(partition_interval_size_per_proc[destProc], (interpolation_size+1)-(idxLower-1));
 
assert(nbPartitionsToRecv > 0);
const int nbParticlesToRecv = -1;
const int nbParticlesToRecv = -1;
NeighborDescriptor descriptor;
NeighborDescriptor descriptor;
@@ -197,7 +199,7 @@ public:
@@ -197,7 +199,7 @@ public:
nbProcToRecvLower = neigDescriptors.size();
nbProcToRecvLower = neigDescriptors.size();
nextDestProc = my_rank;
nextDestProc = my_rank;
for(int idxUpper = 1 ; idxUpper <= interpolation_size ; idxUpper += partition_interval_size_per_proc[nextDestProc]){
for(int idxUpper = 1 ; idxUpper <= interpolation_size+1 ; idxUpper += partition_interval_size_per_proc[nextDestProc]){
nextDestProc = (nextDestProc+1+nb_processes_involved)%nb_processes_involved;
nextDestProc = (nextDestProc+1+nb_processes_involved)%nb_processes_involved;
if(nextDestProc == my_rank){
if(nextDestProc == my_rank){
// We are back on our process
// We are back on our process
@@ -208,9 +210,11 @@ public:
@@ -208,9 +210,11 @@ public:
const int upperRankDiff = (nextDestProc > my_rank ? nextDestProc - my_rank: nb_processes_involved-my_rank+nextDestProc);
const int upperRankDiff = (nextDestProc > my_rank ? nextDestProc - my_rank: nb_processes_involved-my_rank+nextDestProc);
const int nbPartitionsToSend = std::min(current_partition_size, (interpolation_size+1)-(idxUpper-1));
const int nbPartitionsToSend = std::min(current_partition_size, (interpolation_size+1)-(idxUpper-1));
 
assert(nbPartitionsToSend > 0);
const int nbParticlesToSend = current_offset_particles_for_partition[current_partition_size] - current_offset_particles_for_partition[current_partition_size-nbPartitionsToSend];
const int nbParticlesToSend = current_offset_particles_for_partition[current_partition_size] - current_offset_particles_for_partition[current_partition_size-nbPartitionsToSend];
const int nbPartitionsToRecv = std::min(partition_interval_size_per_proc[destProc], interpolation_size-(idxUpper-1));
const int nbPartitionsToRecv = std::min(partition_interval_size_per_proc[destProc], interpolation_size-(idxUpper-1));
 
assert(nbPartitionsToSend >= 0);
const int nbParticlesToRecv = -1;
const int nbParticlesToRecv = -1;
NeighborDescriptor descriptor;
NeighborDescriptor descriptor;
@@ -234,25 +238,28 @@ public:
@@ -234,25 +238,28 @@ public:
NeighborDescriptor& descriptor = neigDescriptors[idxDescr];
NeighborDescriptor& descriptor = neigDescriptors[idxDescr];
if(descriptor.isLower){
if(descriptor.isLower){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
if(descriptor.nbPartitionsToSend > 0){
mpiRequests.emplace_back();
AssertMpi(MPI_Isend(const_cast<int*>(&descriptor.nbParticlesToSend), 1, MPI_INT, descriptor.destProc, TAG_LOW_UP_NB_PARTICLES,
current_com, &mpiRequests.back()));
if(descriptor.nbParticlesToSend){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
mpiRequests.emplace_back();
AssertMpi(MPI_Isend(const_cast<real_number*>(&particles_positions[0]), descriptor.nbParticlesToSend*size_particle_positions, particles_utils::GetMpiType(real_number()), descriptor.destProc, TAG_LOW_UP_PARTICLES,
AssertMpi(MPI_Isend(const_cast<int*>(&descriptor.nbParticlesToSend), 1, MPI_INT, descriptor.destProc, TAG_LOW_UP_NB_PARTICLES,
current_com, &mpiRequests.back()));
current_com, &mpiRequests.back()));
assert(descriptor.toRecvAndMerge == nullptr);
if(descriptor.nbParticlesToSend){
descriptor.toRecvAndMerge.reset(new real_number[descriptor.nbParticlesToSend*size_particle_rhs]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
whatNext.emplace_back(std::pair<Action,int>{MERGE_PARTICLES, idxDescr});
mpiRequests.emplace_back();
mpiRequests.emplace_back();
AssertMpi(MPI_Isend(const_cast<real_number*>(&particles_positions[0]), descriptor.nbParticlesToSend*size_particle_positions, particles_utils::GetMpiType(real_number()), descriptor.destProc, TAG_LOW_UP_PARTICLES,
AssertMpi(MPI_Irecv(descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend*size_particle_rhs, particles_utils::GetMpiType(real_number()), descriptor.destProc, TAG_UP_LOW_RESULTS,
current_com, &mpiRequests.back()));
current_com, &mpiRequests.back()));
 
assert(descriptor.toRecvAndMerge == nullptr);
 
descriptor.toRecvAndMerge.reset(new real_number[descriptor.nbParticlesToSend*size_particle_rhs]);
 
whatNext.emplace_back(std::pair<Action,int>{MERGE_PARTICLES, idxDescr});
 
mpiRequests.emplace_back();
 
AssertMpi(MPI_Irecv(descriptor.toRecvAndMerge.get(), descriptor.nbParticlesToSend*size_particle_rhs, particles_utils::GetMpiType(real_number()), descriptor.destProc, TAG_UP_LOW_RESULTS,
 
current_com, &mpiRequests.back()));
 
}
}
}
 
assert(descriptor.nbPartitionsToRecv);
whatNext.emplace_back(std::pair<Action,int>{RECV_PARTICLES, idxDescr});
whatNext.emplace_back(std::pair<Action,int>{RECV_PARTICLES, idxDescr});
mpiRequests.emplace_back();
mpiRequests.emplace_back();
AssertMpi(MPI_Irecv(&descriptor.nbParticlesToRecv,
AssertMpi(MPI_Irecv(&descriptor.nbParticlesToRecv,
@@ -260,6 +267,7 @@ public:
@@ -260,6 +267,7 @@ public:
current_com, &mpiRequests.back()));
current_com, &mpiRequests.back()));
}
}
else{
else{
 
assert(descriptor.nbPartitionsToSend);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
mpiRequests.emplace_back();
AssertMpi(MPI_Isend(const_cast<int*>(&descriptor.nbParticlesToSend), 1, MPI_INT, descriptor.destProc, TAG_UP_LOW_NB_PARTICLES,
AssertMpi(MPI_Isend(const_cast<int*>(&descriptor.nbParticlesToSend), 1, MPI_INT, descriptor.destProc, TAG_UP_LOW_NB_PARTICLES,
@@ -279,11 +287,13 @@ public:
@@ -279,11 +287,13 @@ public:
current_com, &mpiRequests.back()));
current_com, &mpiRequests.back()));
}
}
whatNext.emplace_back(std::pair<Action,int>{RECV_PARTICLES, idxDescr});
if(descriptor.nbPartitionsToRecv){
mpiRequests.emplace_back();
whatNext.emplace_back(std::pair<Action,int>{RECV_PARTICLES, idxDescr});
AssertMpi(MPI_Irecv(&descriptor.nbParticlesToRecv,
mpiRequests.emplace_back();
1, MPI_INT, descriptor.destProc, TAG_LOW_UP_NB_PARTICLES,
AssertMpi(MPI_Irecv(&descriptor.nbParticlesToRecv,
current_com, &mpiRequests.back()));
1, MPI_INT, descriptor.destProc, TAG_LOW_UP_NB_PARTICLES,
 
current_com, &mpiRequests.back()));
 
}
}
}
}
}
Loading