Commit bdb7efa9 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

Now compile without MPI

parent 1135fdf1
......@@ -807,8 +807,8 @@ namespace scalfmm::tree
std::cout << std::endl;
MortonDistribution parent_distrib(cells_distrib);
auto rank = para.get_process_id();
out::print("rank(" + std::to_string(rank) + ") cells_distrib: ", cells_distrib);
out::print("rank(" + std::to_string(rank) + ") mortonCellIndex: ", mortonCellIndex);
// out::print("rank(" + std::to_string(rank) + ") cells_distrib: ", cells_distrib);
// out::print("rank(" + std::to_string(rank) + ") mortonCellIndex: ", mortonCellIndex);
// get the parent distribution
for(auto& p: parent_distrib)
......@@ -854,9 +854,13 @@ namespace scalfmm::tree
}
}
}
#ifdef SCALFMM_USE_MPI
auto nb_elt = sizeof(local_dist);
para.get_communicator().allgather(local_dist.data(), nb_elt, MPI_CHAR, parent_distrib[0].data(), nb_elt,
MPI_CHAR);
#else
parent_distrib[0] = local_dist;
#endif
}
out::print("rank(" + std::to_string(rank) + ") parent_distrib: ", parent_distrib);
......@@ -1158,11 +1162,14 @@ namespace scalfmm::tree
const MortonDistribution& distrib, const VectorMortonIdx& local_morton_idx)
{
auto rank = para.get_process_id();
auto nb_proc = para.get_num_processes();
std::cout << scalfmm::colors::green << " (" << rank << ")--> Begin distrib::check_if_morton_index_exist "
<< scalfmm::colors::reset << std::endl;
using mortonIdx_type = typename VectorMortonIdx::value_type;
auto nb_proc = para.get_num_processes();
// bad_index the largest morton index in the whole indexes + 1
auto bad_index = distrib[nb_proc - 1][1] + 1;
#ifdef SCALFMM_USE_MPI
std::vector<int> nb_messages_to_send(nb_proc, 0);
std::vector<int> nb_messages_to_receive(nb_proc, 0);
// beging index to send to process k
......@@ -1256,7 +1263,7 @@ namespace scalfmm::tree
//‡ std::cout << ki << " " << elt[ki] << " " << start << "
//";
// check if morton index exists in my local morton vector
// if not we hust insert a teh bad_index in order not to change the size of the buddfer to
// if not we hust insert a the bad_index in order not to change the size of the buddfer to
// send.
auto pos = find_index(elt[ki], local_morton_idx, start);
if(pos < 0)
......@@ -1277,7 +1284,6 @@ namespace scalfmm::tree
}
}
}
#ifndef _LET_CHECK
/////////////////////////////////////////////////////////////////////////////
/// re-send the existing index
......@@ -1310,7 +1316,6 @@ namespace scalfmm::tree
{
inria::mpi::request::waitall(tab_mpi_status.size(), tab_mpi_status.data());
}
#endif
// out::print("rank(" + std::to_string(rank) + ") needed_idx : ", needed_idx);
for(std::size_t i = 0; i < nb_messages_to_receive.size(); ++i)
......@@ -1320,6 +1325,13 @@ namespace scalfmm::tree
delete[] buffer[i];
}
}
#else
std::cout << scalfmm::colors::red;
std::cerr << " distrib::check_if_morton_index_exist doesnt works in sequential (without MPI)" << std::endl;
std::cout << scalfmm::colors::reset << std::endl;
#endif
// We remove the bad_index in order to have only the existing components (leaf/cell)
std::sort(needed_idx.begin(), needed_idx.end());
auto last = std::unique(needed_idx.begin(), needed_idx.end());
......@@ -1477,7 +1489,7 @@ namespace scalfmm::tree
return m1 < m2;
});
#endif
out::print("rank(" + std::to_string(rank) + ") partArray final: ", particle_container);
// out::print("rank(" + std::to_string(rank) + ") partArray final: ", particle_container);
///
//
// std::cout << "sort at level " << level << " box " << box << std::endl;
......@@ -1533,10 +1545,10 @@ namespace scalfmm::tree
particles_distrib = leaves_distrib;
}
std::cout << scalfmm::colors::red;
out::print("rank(" + std::to_string(rank) + ") --> particles_distrib: ", particles_distrib);
out::print("rank(" + std::to_string(rank) + ") --> leaves_distrib: ", leaves_distrib);
std::cout << scalfmm::colors::reset << std::endl;
// std::cout << scalfmm::colors::red;
// out::print("rank(" + std::to_string(rank) + ") --> particles_distrib: ", particles_distrib);
// out::print("rank(" + std::to_string(rank) + ") --> leaves_distrib: ", leaves_distrib);
// std::cout << scalfmm::colors::reset << std::endl;
//// End
////////////////////////////////////////////////////////////////////////////////////////////
///
......@@ -1592,7 +1604,6 @@ namespace scalfmm::tree
localGroupTree->set_leaf_distribution(particles_distrib);
// std::cout << std::flush;
manager.get_communicator().barrier();
// std::cout << scalfmm::colors::red;
// std::cout << "END LEAF LEVEL " << std::endl;
// std::cout << scalfmm::colors::reset;
......@@ -1602,6 +1613,7 @@ namespace scalfmm::tree
//////////////////////////////////////////////////////////////////
/// Construct a uniform distribution of the morton index
///
#ifdef SCALFMM_USE_MPI
if(use_leaf_distribution && use_particle_distribution)
{
try
......@@ -1614,21 +1626,19 @@ namespace scalfmm::tree
std::cerr << e.what() << '\n';
}
}
#endif
///
/// Find and add the cells to add at the leaves level
std::vector<morton_distrib_type> level_dist(localGroupTree->height());
level_dist[leaf_level] = leaves_distrib;
manager.get_communicator().barrier();
build_let_at_level(manager, *localGroupTree, leafMortonIdx, level_dist[leaf_level], leaf_level);
localGroupTree->set_cell_distribution(leaf_level, level_dist[leaf_level]);
for(int l = leaf_level - 1; l >= localGroupTree->top_level(); --l)
{
std::cout << std::flush;
manager.get_communicator().barrier();
level_dist[l] = std::move(
distrib::build_upper_distribution(manager, dimension, l, leafMortonIdx, level_dist[l + 1]));
out::print("rank(" + std::to_string(rank) + ") leafMortonIdx: ", leafMortonIdx);
// out::print("rank(" + std::to_string(rank) + ") leafMortonIdx: ", leafMortonIdx);
build_let_at_level(manager, *localGroupTree, leafMortonIdx, level_dist[l], l);
localGroupTree->set_cell_distribution(l, level_dist[l]);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment