Skip to content
Snippets Groups Projects
Commit f7ab82da authored by Pietro Incardona's avatar Pietro Incardona
Browse files

Adding box distribution test

parent b5ce7a9e
No related branches found
No related tags found
No related merge requests found
Pipeline #2753 passed
......@@ -228,7 +228,8 @@ public:
getPrimeFactors(v_cl.size(),facts);
size_t div[dim];
size_t ln[dim];
size_t ln[dim];
double ln_d[dim];
for (int i = 0 ; i < dim ; i++)
{div[i] = 1;}
......@@ -237,7 +238,10 @@ public:
{div[i % dim] *= facts.get(i);}
for (int i = 0 ; i < dim ; i++)
{ln[i] = gr.size(i) / div[i];}
{
ln[i] = gr.size(i) / div[i];
ln_d[i] = (double)gr.size(i) / div[i];
}
grid_sm<dim,void> gr_proc(div);
......@@ -249,10 +253,10 @@ public:
for (int i = 0 ; i < dim ; i++)
{
key_prc.set_d(i,key.get(i)/ln[i]);
if (key_prc.get(i) >= div[i])
{key_prc.set_d(i,div[i]-1);}
}
key_prc.set_d(i,key.get(i)/ln_d[i]);
if (key_prc.get(i) >= div[i])
{key_prc.set_d(i,div[i]-1);}
}
size_t i = gr.LinId(key);
......
......@@ -11,6 +11,7 @@
#include "config.h"
#include "SpaceDistribution.hpp"
#include <unistd.h>
#include "BoxDistribution.hpp"
/*! \brief Set a sphere as high computation cost
*
......@@ -423,6 +424,53 @@ BOOST_AUTO_TEST_CASE( Space_distribution_test)
}
BOOST_AUTO_TEST_CASE( Box_distribution_test)
{
Vcluster<> & v_cl = create_vcluster();
if (v_cl.size() > 16)
{return;}
//! [Initialize a ParMetis Cartesian graph and decompose]
BoxDistribution<3, float> box_dist(v_cl);
// Physical domain
Box<3, float> box( { 0.0, 0.0, 0.0 }, { 10.0, 10.0, 10.0 });
// Grid info
grid_sm<3, void> info( { GS_SIZE, GS_SIZE, GS_SIZE });
// Initialize Cart graph and decompose
box_dist.createCartGraph(info,box);
// First create the center of the weights distribution, check it is coherent to the size of the domain
Point<3, float> center( { 2.0, 2.0, 2.0 });
// first decomposition
box_dist.decompose();
BOOST_REQUIRE_EQUAL(box_dist.get_ndec(),0ul);
auto & graph = box_dist.getGraph();
for (int i = 0 ; i < graph.getNVertex() ; i++)
{
BOOST_REQUIRE(graph.vertex(i).template get<nm_v_proc_id>() < v_cl.size());
}
size_t n_sub = box_dist.getNOwnerSubSubDomains();
size_t n_sub_tot = info.size();
size_t n_sub_bal = n_sub_tot / v_cl.size();
BOOST_REQUIRE( (((int)n_sub_bal - 64) <= (long int)n_sub) && (n_sub_bal + 64 >= n_sub) );
//! [refine with parmetis the decomposition]
// BOOST_REQUIRE_EQUAL(sizeof(ParMetisDistribution<3,float>),872ul);
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_DECOMPOSITION_DISTRIBUTION_DISTRIBUTION_UNIT_TESTS_HPP_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment