Commit 2c8bc5b6 authored by DUFOYER Benjamin's avatar DUFOYER Benjamin

Add split of MPI message

Add build LET all level
Fix Memory bug
parent 0ec7b837
......@@ -195,8 +195,8 @@ public:
std::cout << " nb_leaf : " << this->linear_tree->size() << std::endl;
std::cout << " nb_block : " << nb_block << std::endl;
std::cout << " block_size : " << block_size << std::endl;
for(int i = 0 ; i < this->linear_tree->size() ; i++){
std::cout << linear_tree->at(i) << std::endl;
for(unsigned i = 0 ; i < this->linear_tree->size() ; i++){
std::cout << linear_tree->data()[i] << std::endl;
}
}
......@@ -225,6 +225,13 @@ public:
index_particle_distribution);
}
void update_index_particle_distribution(std::pair<MortonIndex,MortonIndex> new_distrib){
dstr_grp_tree_builder::share_particle_division(
this->mpi_conf,
new_distrib,
index_particle_distribution);
}
std::vector<std::pair<MortonIndex,MortonIndex>>*
get_index_particle_distribution(){
// TO get the particle repartition, you will compute it before
......@@ -267,31 +274,45 @@ public:
* @param dim Dimension of coordinate of particle
*/
template<class GroupTreeClass>
void create_let_group_tree_leaf(
GroupTreeClass& tree,
int dim = 3
void create_let_group_tree_at_level(
GroupTreeClass& tree,
int level,
int dim = 3
){
FAssert(index_particle_distribution.size() != 0 );
FAssert(dim > 0);
// Compute min and max global morton index
const MortonIndex global_min_m_idx = this->index_particle_distribution.front().first;
const MortonIndex global_max_m_idx = this->index_particle_distribution.back().second;
bool leaf_level = (tree.getHeight()-1 == level);
// Compute min and max global morton index at the level needed
// This variable is used to put value in const
MortonIndex gmin = this->index_particle_distribution.front().first;
MortonIndex gmax = this->index_particle_distribution.back().second;
// update the morton index
if(!leaf_level){
gmin = gmin >> 3;
gmax = gmax >> 3;
}
const MortonIndex global_min_m_idx = gmin;
const MortonIndex global_max_m_idx = gmax;
// Compute min and max local morton index
const MortonIndex local_min_m_idx = tree.getParticleGroup(0)->getStartingIndex();
const MortonIndex local_max_m_idx = tree.getParticleGroup( (tree.getNbParticleGroup()-1) )->getEndingIndex();
// IDEA : can be a task
// This function compute the leaf needed by the P2P operation
// This function return a vector with all leaf needed
// get leaf P2P
std::vector<MortonIndex> leaf_P2P = dstr_grp_tree_builder::get_leaf_P2P_interaction(
tree,
global_min_m_idx,
global_max_m_idx,
local_min_m_idx,
local_max_m_idx);
const MortonIndex local_min_m_idx =
tree.getParticleGroup(0)->getStartingIndex() >>( (tree.getHeight()-1-level)*dim);
const MortonIndex local_max_m_idx = tree.getParticleGroup(
(tree.getNbParticleGroup()-1) )->getEndingIndex() >>( (tree.getHeight()-1-level)*dim);
std::vector<MortonIndex> leaf_P2P;
if(leaf_level){
// IDEA : can be a task
// This function compute the leaf needed by the P2P operation
// This function return a vector with all leaf needed
// get leaf P2P
leaf_P2P = dstr_grp_tree_builder::get_leaf_P2P_interaction(
tree,
global_min_m_idx,
global_max_m_idx,
local_min_m_idx,
local_max_m_idx);
}
// IDEA can be a task
// This function compute the leaf needed by the M2L operation
......@@ -303,38 +324,48 @@ public:
global_max_m_idx,
local_min_m_idx,
local_max_m_idx,
tree.getHeight()-1,
level,
tree,
dim);
// this function return the concatenation of the leaf for the P2P and
// the leaf for the M2L
std::vector<MortonIndex> needed_leaf = dstr_grp_tree_builder::concat_M2L_P2P(leaf_P2P,leaf_M2L);
// Creation of interaction matrice
// TODO Expliquer pourquoi on est obliger de faire ça
// TODO réfléchir comment faire
std::vector<MortonIndex> needed_leaf;
if(leaf_level){
// this function return the concatenation of the leaf for the P2P and
// the leaf for the M2L
needed_leaf = dstr_grp_tree_builder::concat_M2L_P2P(leaf_P2P,leaf_M2L);
} else {
needed_leaf = leaf_M2L;
this->update_index_particle_distribution(
std::pair<MortonIndex,MortonIndex>(local_min_m_idx
,local_max_m_idx)
);
}
std::vector<size_t> global_matrix_interaction = dstr_grp_tree_builder::get_matrix_interaction(
needed_leaf,
index_particle_distribution,
this->mpi_conf);
// Send and get leaf
// Auto is used to get the block more easly
// it's a vector<vector<block_t>>
// block_t is a struct define on FDistributedGroupTreeBuilder.hpp
auto let_block = dstr_grp_tree_builder::send_get_symbolic_block(
auto let_block =
dstr_grp_tree_builder::send_get_symbolic_block_at_level(
needed_leaf,
global_matrix_interaction,
tree,
level,
this->mpi_conf);
// Add the block recev to the local group tree
dstr_grp_tree_builder::add_let_leaf_block_to_tree(
tree,
let_block,
local_min_m_idx);
local_min_m_idx,
level);
}
}
/**
* This function is used to show the FGroupLinearTee more easly
......
......@@ -1075,6 +1075,10 @@ public:
return _cellBlocksPerLevel[inLevel][inIdx];
}
const int getNbElementsPerBlock() const{
return this->_nbElementsPerBlock;
}
const CellGroupClass* getCellGroup(const int inLevel, const int inIdx) const {
FAssertLF(inLevel < _treeHeight);
FAssertLF(inIdx < int(_cellBlocksPerLevel[inLevel].size()));
......@@ -1391,7 +1395,7 @@ void create_block_nodes_level(MortonIndex* currentBlockIndexes,
_cellBlocksPerLevel[level].begin(),
vect_block.begin(),
vect_block.begin()+block_at_begin);
// Add block a the end of the level
// Add block a the end of the level
_cellBlocksPerLevel[level].insert(
_cellBlocksPerLevel[level].end(),
vect_block.begin()+block_at_begin,
......
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