Commit 0ec7b837 authored by DUFOYER Benjamin's avatar DUFOYER Benjamin

Fix LET at leaf level + Adding split MPI message for message too big

parent a2154f09
......@@ -20,8 +20,8 @@ protected:
const inria::mpi_config& mpi_conf;
std::vector<node_t>* linear_tree;
std::vector<std::pair<unsigned long long int,unsigned long long int>> particle_repartition;
bool unknow_particle_repartition = true;
std::vector<std::pair<MortonIndex,MortonIndex>> index_particle_distribution;
bool unknow_index_particle_distribution = true;
public:
......@@ -39,7 +39,7 @@ public:
*/
FGroupLinearTree(const inria::mpi_config& conf):
mpi_conf(conf),
particle_repartition(conf.comm.size())
index_particle_distribution(conf.comm.size())
{
linear_tree = new std::vector<node_t>[1];
}
......@@ -52,7 +52,7 @@ public:
* @param in_linear_tree linear tree
* @param in_block_size block size
*/
void create_local_blocked_linear_tree(
void create_local_group_linear_tree(
std::vector<node_t>* in_linear_tree,
int in_block_size
){
......@@ -67,7 +67,7 @@ public:
* @param in_linear_tree linear tree
* @param in_block_size blocksize needed
*/
void create_global_blocked_linear_tree(
void create_global_group_linear_tree(
std::vector<node_t>* in_linear_tree,
int in_block_size
){
......@@ -209,34 +209,34 @@ public:
}
/**
* This function fill the particle_repartition with a call of the function
* This function fill the index_particle_distribution with a call of the function
* from FDistributedGroupTreeBuilder
* @author benjamin.dufoyer@inria.fr
* @param particle_container [description]
*/
template<class particle_t>
void set_particle_repartition(
void set_index_particle_distribution(
std::vector<particle_t> particle_container)
{
unknow_particle_repartition = false;
dstr_grp_tree_builder::know_particle_division(
unknow_index_particle_distribution = false;
dstr_grp_tree_builder::share_particle_division(
this->mpi_conf,
particle_container,
particle_repartition);
index_particle_distribution);
}
std::vector<std::pair<unsigned long long int,unsigned long long int>>*
get_particle_repartition(){
std::vector<std::pair<MortonIndex,MortonIndex>>*
get_index_particle_distribution(){
// TO get the particle repartition, you will compute it before
FAssert(!unknow_particle_repartition);
return &this->particle_repartition;
FAssert(!unknow_index_particle_distribution);
return &this->index_particle_distribution;
}
std::pair<unsigned long long int,unsigned long long int> get_particle_repartition_at(unsigned i){
std::pair<MortonIndex,MortonIndex> get_index_particle_distribution_at(unsigned i){
// TO get the particle repartition, you will compute it before
FAssert(!unknow_particle_repartition);
FAssert(i < this->particle_repartition.size());
return this->particle_repartition.data()[i];
FAssert(!unknow_index_particle_distribution);
FAssert(i < this->index_particle_distribution.size());
return this->index_particle_distribution.data()[i];
}
/**
......@@ -246,13 +246,13 @@ public:
* @author benjamin.dufoyer@inria.fr
* @return max left morton index, -1 if he doesn't exist
*/
long long int get_left_limit(){
MortonIndex get_left_limit(){
// Check if the repartition have been compute
FAssert(!unknow_particle_repartition);
FAssert(!unknow_index_particle_distribution);
int my_rank = this->mpi_conf.comm.rank();
long long int left_limit = -1;
MortonIndex left_limit = -1;
if(my_rank != 0){
left_limit = (long long int )this->particle_repartition[my_rank-1].second;
left_limit = (MortonIndex )this->index_particle_distribution[my_rank-1].second;
}
return left_limit;
}
......@@ -267,64 +267,73 @@ public:
* @param dim Dimension of coordinate of particle
*/
template<class GroupTreeClass>
void create_let_group_tree(
void create_let_group_tree_leaf(
GroupTreeClass& tree,
int dim = 3
){
FAssert(particle_repartition.size() != 0 );
FAssert(index_particle_distribution.size() != 0 );
FAssert(dim > 0);
// Compute min and max global morton index
const MortonIndex global_min_m_idx = this->particle_repartition.front().first;
const MortonIndex global_max_m_idx = this->particle_repartition.back().second;
const MortonIndex global_min_m_idx = this->index_particle_distribution.front().first;
const MortonIndex global_max_m_idx = this->index_particle_distribution.back().second;
// 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<size_t> leaf_P2P = dstr_grp_tree_builder::get_leaf_P2P_interaction(
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);
// IDEA can be a task
// This function compute the leaf needed by the M2L operation
// This function return a vector with all leaf needed
// get leaf M2L
std::vector<size_t> leaf_M2L =
dstr_grp_tree_builder::get_leaf_M2L_interaction(
std::vector<MortonIndex> leaf_M2L =
dstr_grp_tree_builder::get_leaf_M2L_interaction_at_level(
global_min_m_idx,
global_max_m_idx,
local_min_m_idx,
local_max_m_idx,
tree.getHeight()-1,
tree,
dim);
// concat result
std::vector<size_t> needed_leaf = dstr_grp_tree_builder::concat_M2L_P2P(leaf_P2P,leaf_M2L);
// 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<size_t> global_matrix_interaction = dstr_grp_tree_builder::get_matrix_interaction(
needed_leaf,
particle_repartition,
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_leaf(
auto let_block = dstr_grp_tree_builder::send_get_symbolic_block(
needed_leaf,
global_matrix_interaction,
tree,
this->mpi_conf);
// Add the block recev to the local group tree
dstr_grp_tree_builder::add_let_block_to_tree(
dstr_grp_tree_builder::add_let_leaf_block_to_tree(
tree,
let_block,
local_min_m_idx);
}
/**
......
......@@ -1067,6 +1067,10 @@ public:
CellGroupClass* getCellGroup(const int inLevel, const int inIdx){
FAssertLF(inLevel < _treeHeight);
if(inIdx >= int(_cellBlocksPerLevel[inLevel].size())){
std::cout << "level : "<< inLevel << std::endl;
std::cout << " idx :"<< inIdx << std::endl;
}
FAssertLF(inIdx < int(_cellBlocksPerLevel[inLevel].size()));
return _cellBlocksPerLevel[inLevel][inIdx];
}
......@@ -1214,7 +1218,7 @@ MortonIndex* create_leaf_level(Blocked_Linear_tree* in_lin_tree,
// Initialise each cell of the block
size_t nb_particles_offset_before_leaf = 0;
size_t idx_particules = 0;
for(unsigned cell_id_in_block = 0; cell_id_in_block < size_of_block; ++cell_id_in_block){
// Adding cell into leaf block
new_block->newCell(
......@@ -1241,19 +1245,18 @@ MortonIndex* create_leaf_level(Blocked_Linear_tree* in_lin_tree,
);
BasicAttachedClass attached_leaf =
new_particle_block->template getLeaf<BasicAttachedClass>(cell_id_in_block);
// Adding particle
for(size_t idxPart = 0 ; idxPart < nb_particle_per_leaf[leaf_number_min+cell_id_in_block] ; ++idxPart ){
attached_leaf.setParticle(
idxPart,
nb_particles_offset_before_leaf+idxPart,
&particle_container);
idxPart,
idx_particules,
//nb_particles_offset_before_leaf+idxPart,
&particle_container);
++idx_particules;
}
// Setting the offset to don't use particle twice
//offset_particles += nb_particle_per_leaf[idx_nb_particle_in_block];
//idx_nb_particle_in_block += 1;
......@@ -1355,7 +1358,7 @@ void create_block_nodes_level(MortonIndex* currentBlockIndexes,
/**
* Add block putted in parameter into the local group tree
* Add LET block at leaf level of the local GroupTree
* @author benjamin.dufoyer@inria.fr
* @param block_to_insert list symbolic information of block
* to add
......@@ -1364,34 +1367,38 @@ void create_block_nodes_level(MortonIndex* currentBlockIndexes,
* @param level level to add
*/
template<class block_t>
void create_LET_block(
std::vector<block_t> block_to_insert,
bool start,
int level){
// declaration of buffer to insertion
void add_LET_block(std::vector<block_t>& block_to_insert,
int level,
const MortonIndex& local_min_m_idx
){
if(block_to_insert.size() == 0)
return;
// Allocate vector of new block
std::vector<CellGroupClass*> vect_block(block_to_insert.size());
// prepare block for insertion
// Fill the vector of new block
unsigned block_at_begin = 0;
for(unsigned i = 0; i < vect_block.size(); ++i){
vect_block[i] = new CellGroupClass(
block_to_insert[i].start_index ,
block_to_insert[i].end_index ,
(int)block_to_insert[i].nb_leaf_in_block );
if(block_to_insert[i].end_index < local_min_m_idx){
++block_at_begin;
}
}
// add at the end or at the beginning of current block
if(start){
// inserting blocks
_cellBlocksPerLevel[level].insert(
_cellBlocksPerLevel[level].begin(),
vect_block.begin(),
vect_block.end() );
} else {
// inserting blocks
_cellBlocksPerLevel[level].insert(
_cellBlocksPerLevel[level].end(),
vect_block.begin(),
vect_block.end());
}
// Add block at beginning of the level
_cellBlocksPerLevel[level].insert(
_cellBlocksPerLevel[level].begin(),
vect_block.begin(),
vect_block.begin()+block_at_begin);
// Add block a the end of the level
_cellBlocksPerLevel[level].insert(
_cellBlocksPerLevel[level].end(),
vect_block.begin()+block_at_begin,
vect_block.end());
}
};
#endif // FGROUPTREE_HPP
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