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

Now test-build-let works ine 2d and 3d

parent f4d90be4
......@@ -24,14 +24,22 @@
/// \param argv
/// \return
///
///
/// \code
/// ./examples/RelWithDebInfo/test-build-let --input-file ../data/prolate.fma
/// --order 3 --tree-height 4 --group-size 3
/// mpirun --oversubscribe -np 3 ./examples/RelWithDebInfo/test-build-let
/// --input-file ../buildMPI/prolate.fma --order 3 --tree-height 3
/// --group-size 3
/// --group-size 3 --d 3
/// \endcode
namespace local_args
{
struct Dimension
{
inria::tcli::str_vec flags = {"--dimension", "--d"};
const char* description = "Dimension : \n 2 for dimension 2, 3 for dimension 3";
using type = int;
type def = 1;
};
struct PartDistrib
{
/// Unused type, mandatory per interface specification
......@@ -57,12 +65,10 @@ namespace local_args
std::string description = "Use two distribution one for the particle and one for the tree";
};
} // namespace local_args
auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
template<int dimension>
auto run(parallel_manager& para, const std::string& input_file, const int tree_height, const int& part_group_size,
const int& leaf_group_size, const int order, bool use_leaf_distribution, bool use_particle_distribution) -> int
{
parallel_manager para;
para.init();
constexpr int dimension = 2;
constexpr int nb_inputs_near = 1;
constexpr int nb_outputs_near = 1;
constexpr int nb_inputs_far = 1;
......@@ -88,46 +94,6 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
using box_type = scalfmm::component::box<position_type>;
using group_tree_type = scalfmm::component::dist_group_tree<cell_type, leaf_type, box_type>;
//
// Parameter handling
auto parser = inria::tcli::make_parser(inria::tcli::help{}, args::input_file(), args::output_file(),
args::tree_height{}, args::order{}, // args::thread_count{},
args::block_size{}, args::log_file{}, args::log_level{},
local_args::PartDistrib{}, local_args::PartLeafDistrib{});
parser.parse(argc, argv);
// Getting command line parameters
const int tree_height{parser.get<args::tree_height>()};
const int group_size{parser.get<args::block_size>()};
const std::string input_file{parser.get<args::input_file>()};
const auto output_file{parser.get<args::output_file>()};
const auto order{parser.get<args::order>()};
bool use_particle_distribution{parser.exists<local_args::PartDistrib>()};
bool use_leaf_distribution{!use_particle_distribution};
if(parser.exists<local_args::PartLeafDistrib>())
{
use_leaf_distribution = true;
use_particle_distribution = true;
}
if(para.io_master())
{
std::cout << scalfmm::colors::blue << "<params> Tree height: " << tree_height << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Group Size: " << group_size << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> order: " << order << scalfmm::colors::reset << '\n';
if(!input_file.empty())
{
std::cout << scalfmm::colors::blue << "<params> Input file: " << input_file << scalfmm::colors::reset
<< '\n';
}
std::cout << scalfmm::colors::blue << "<params> Output file: " << output_file << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Particle Distribution: " << std::boolalpha
<< use_particle_distribution << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Leaf Distribution: " << std::boolalpha
<< use_leaf_distribution << scalfmm::colors::reset << '\n';
}
///
///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Read the data in parallel
......@@ -177,8 +143,9 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
int leaf_level = tree_height - 1;
scalfmm::tree::let::buildLetTree(para, number_of_particles, particles_set, box, leaf_level, group_size, group_size,
letGroupTree, order, use_leaf_distribution, use_particle_distribution);
scalfmm::tree::let::buildLetTree(para, number_of_particles, particles_set, box, leaf_level, part_group_size,
leaf_group_size, letGroupTree, order, use_leaf_distribution,
use_particle_distribution);
#ifdef SCALFMM_USE_MPI
para.get_communicator().barrier();
......@@ -205,8 +172,80 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
///
///////////////////////////////////////////////////////////////////////////////////////////////////////
// delete letGroupTree;
delete letGroupTree;
para.end();
return 0;
}
auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
{
parallel_manager para;
para.init();
//
// Parameter handling
auto parser =
inria::tcli::make_parser(inria::tcli::help{}, args::input_file(), args::output_file(), args::tree_height{},
args::order{}, // args::thread_count{},
args::block_size{}, args::log_file{}, args::log_level{}, local_args::Dimension{},
local_args::PartDistrib{}, local_args::PartLeafDistrib{});
parser.parse(argc, argv);
// Getting command line parameters
const int tree_height{parser.get<args::tree_height>()};
const int group_size{parser.get<args::block_size>()};
const std::string input_file{parser.get<args::input_file>()};
const auto output_file{parser.get<args::output_file>()};
const auto order{parser.get<args::order>()};
const auto dimension{parser.get<local_args::Dimension>()};
bool use_particle_distribution{parser.exists<local_args::PartDistrib>()};
bool use_leaf_distribution{!use_particle_distribution};
if(parser.exists<local_args::PartLeafDistrib>())
{
use_leaf_distribution = true;
use_particle_distribution = true;
}
if(para.io_master())
{
std::cout << scalfmm::colors::blue << "<params> Tree height: " << tree_height << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Group Size: " << group_size << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> order: " << order << scalfmm::colors::reset << '\n';
if(!input_file.empty())
{
std::cout << scalfmm::colors::blue << "<params> Input file: " << input_file << scalfmm::colors::reset
<< '\n';
}
std::cout << scalfmm::colors::blue << "<params> Output file: " << output_file << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Particle Distribution: " << std::boolalpha
<< use_particle_distribution << scalfmm::colors::reset << '\n';
std::cout << scalfmm::colors::blue << "<params> Leaf Distribution: " << std::boolalpha
<< use_leaf_distribution << scalfmm::colors::reset << '\n';
}
switch(dimension)
{
case 2:
{
constexpr int dim = 2;
run<dim>(para, input_file, tree_height, group_size, group_size, order, use_leaf_distribution,
use_particle_distribution);
break;
}
case 3:
{
constexpr int dim = 3;
run<dim>(para, input_file, tree_height, group_size, group_size, order, use_leaf_distribution,
use_particle_distribution);
break;
}
default:
{
std::cerr << "Dimension should b 2 or 4 !!\n";
}
}
para.end();
}
......@@ -13,6 +13,7 @@
#include "scalfmm/tree/interaction_list.hpp"
#include <scalfmm/tree/utils.hpp>
#include <scalfmm/utils/io_helpers.hpp> // for out::print
#include <scalfmm/utils/math.hpp>
#include <scalfmm/utils/parallel_manager.hpp>
#ifdef SCALFMM_USE_MPI
......@@ -27,11 +28,18 @@ namespace scalfmm::tree
{
namespace distrib
{
template<typename Index1_type, typename Index_type>
bool between(const Index1_type& m, const Index_type& mmin, const Index_type& mmax)
{
return (mmin <= m) && (m <= mmax);
};
// ///
// /// \brief between return true if min <= m <= max
// /// \param m index to check
// /// \param mmin mininum of the interval
// /// \param mmax maimum of the interval
// /// \return true if m is in [min,max]
// ///
// template<typename Index1_type, typename Index_type>
// bool between(const Index1_type& m, const Index_type& mmin, const Index_type& mmax)
// {
// return (mmin <= m) && (m <= mmax);
// };
///
/// \brief send_get_min_morton_idx send the morton index to the left and get value from the right
///
......@@ -530,7 +538,7 @@ namespace scalfmm::tree
{
break;
}
while(!between(morton_array[i], morton_dist[pos][0], morton_dist[pos][1]))
while(!math::between(morton_array[i], morton_dist[pos][0], morton_dist[pos][1]))
{
pos++;
new_start = true;
......@@ -574,7 +582,7 @@ namespace scalfmm::tree
{
break;
}
while(!between(morton_array[i], morton_dist[pos][0], morton_dist[pos][1]))
while(!math::between(morton_array[i], morton_dist[pos][0], morton_dist[pos][1]))
{
pos--;
new_start = true;
......@@ -836,7 +844,7 @@ namespace scalfmm::tree
for(std::size_t i = 0; i < mortonCellIndex.size(); ++i)
{
if(morton_to_remove == (mortonCellIndex[i] >> 2))
if(morton_to_remove == (mortonCellIndex[i] >> dimension))
{
continue;
}
......@@ -857,7 +865,7 @@ namespace scalfmm::tree
///
for(std::size_t i = 0; i < mortonCellIndex.size(); ++i)
{
mortonCellIndex[i] = mortonCellIndex[i] >> 2;
mortonCellIndex[i] = mortonCellIndex[i] >> dimension;
}
out::print("rank(" + std::to_string(rank) + ") mortonCellIndex: ", mortonCellIndex);
......@@ -935,7 +943,7 @@ namespace scalfmm::tree
{
//
const auto& interval = leaves_distrib[r];
if(between(p, interval[0], interval[1]))
if(math::between(p, interval[0], interval[1]))
{
outsideIndex_to_add.push_back(p);
break;
......@@ -948,7 +956,7 @@ namespace scalfmm::tree
{
//
const auto& interval = leaves_distrib[r];
if(between(p, interval[0], interval[1]))
if(math::between(p, interval[0], interval[1]))
{
outsideIndex_to_add.push_back(p);
break;
......@@ -1028,7 +1036,7 @@ namespace scalfmm::tree
{
//
const auto& interval = cell_distrib[r];
if(between(p, interval[0], interval[1]))
if(math::between(p, interval[0], interval[1]))
{
outsideIndex_to_add.push_back(p);
break;
......@@ -1040,7 +1048,7 @@ namespace scalfmm::tree
for(int r = my_rank + 1; r < cell_distrib.size(); ++r)
{
const auto& interval = cell_distrib[r];
if(between(p, interval[0], interval[1]))
if(math::between(p, interval[0], interval[1]))
{
outsideIndex_to_add.push_back(p);
break;
......@@ -1100,7 +1108,7 @@ namespace scalfmm::tree
{
for(std::size_t i = start; i < distrib.size(); ++i)
{
if(between(index, distrib[i][0], distrib[i][1]))
if(math::between(index, distrib[i][0], distrib[i][1]))
{
return i;
}
......@@ -1588,9 +1596,9 @@ namespace scalfmm::tree
// std::cout << scalfmm::colors::red;
// std::cout << "END LEAF LEVEL " << std::endl;
// std::cout << scalfmm::colors::reset;
/// If the distribution is not the same for the leaf and the cell we have to redistribute the
/// morton index according to the good distribution
/// Todo inria::dist::distribute()
/// If the distribution is not the same for the leaf and the cell we redistribute the
/// morton index according to ta unifom distribution of morton index
///
//////////////////////////////////////////////////////////////////
/// Construct a uniform distribution of the morton index
///
......@@ -1599,10 +1607,7 @@ namespace scalfmm::tree
try
{
inria::mpi_config conf(manager.get_communicator());
/// wrong tupe for leaves_distrib
// inria::distribute(conf, begin(leafMortonIdx), end(leafMortonIdx),
// leaves_distrib,
// inria::uniform_distribution{conf, leafMortonIdx});
inria::distribute(conf, leafMortonIdx, inria::uniform_distribution{conf, leafMortonIdx});
}
catch(std::out_of_range& e)
{
......@@ -1621,10 +1626,6 @@ namespace scalfmm::tree
{
std::cout << std::flush;
manager.get_communicator().barrier();
std::cout << scalfmm::colors::red;
std::cout << "level: " << l << " leaf_level " << leaf_level << " top "
<< localGroupTree->top_level() << std::endl;
std::cout << scalfmm::colors::reset;
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);
......
......@@ -51,8 +51,8 @@ namespace scalfmm::math
return a - b < epsilon && b - a < epsilon;
}
template<typename ValueType>
inline constexpr auto between(ValueType value, ValueType range_begin, ValueType range_end) -> bool
template<typename ValueType1, typename ValueType>
inline constexpr auto between(ValueType1 value, ValueType range_begin, ValueType range_end) -> bool
{
return (value >= range_begin && value < range_end);
}
......
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