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

Distributed grid fixed

parent 5f01bfc3
No related branches found
No related tags found
No related merge requests found
......@@ -113,6 +113,12 @@ AM_CONDITIONAL(BUILDCUDA, test ! x$NVCC = x"no")
###########################
# Define that there is MPI
AC_DEFINE([HAVE_MPI],[],[MPI Enabled])
#####
no_avx=no
no_sse42=no
no_sse41=no
......
#ifndef CARTESIAN_GRAPH_UNIT_TEST_HPP
#define CARTESIAN_GRAPH_UNIT_TEST_HPP
#include "Graph/CartesianGraphFactory.hpp"
#include "map_graph.hpp"
#define GS_SIZE 8
/*!
*
* Test node
*
*/
struct node_cp
{
//! The node contain 3 unsigned long integer for comunication computation and memory
typedef boost::fusion::vector<size_t,size_t,size_t> type;
//! Attributes name
struct attributes
{
static const std::string name[];
};
//! The data
type data;
//! communication property id in boost::fusion::vector
static const unsigned int communication = 0;
//! computation property id in boost::fusion::vector
static const unsigned int computation = 1;
//! memory property id in boost::fusion::vector
static const unsigned int memory = 2;
//! total number of properties boost::fusion::vector
static const unsigned int max_prop = 3;
};
const std::string node_cp::attributes::name[] = {"communication","computation","memory"};
BOOST_AUTO_TEST_SUITE( CartesianGraphFactory_test )
BOOST_AUTO_TEST_CASE( CartesianGraphFactory_use)
{
typedef node_cp node;
CartesianGraphFactory<3,Graph_CSR<Point_test<float>,Point_test<float>>> g_factory;
// Cartesian grid
size_t sz[3] = {GS_SIZE,GS_SIZE,GS_SIZE};
// Box
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
Graph_CSR<Point_test<float>,Point_test<float>> g = g_factory.construct<node::communication,float,2>(sz,box);
}
BOOST_AUTO_TEST_SUITE_END()
#endif
......@@ -10,11 +10,10 @@
#include "config.h"
#include "Decomposition.hpp"
#include "map_vector.hpp"
#include "Vector/map_vector.hpp"
#include <vector>
#include "global_const.hpp"
#include <initializer_list>
#include "map_vector.hpp"
#include "SubdomainGraphNodes.hpp"
#include "metis_util.hpp"
#include "dec_optimizer.hpp"
......@@ -106,11 +105,11 @@ private:
// Here we use METIS
// Create a cartesian grid graph
CartesianGraphFactory<dim,Graph_CSR<nm_v,nm_e>> g_factory_part;
CartesianGraphFactory<dim,Graph_CSR<nm_part_v,nm_part_e>> g_factory_part;
// Processor graph
Graph_CSR<nm_v,nm_e> gp = g_factory_part.template construct<NO_EDGE,T,dim-1,0,1>(div,domain);
Graph_CSR<nm_part_v,nm_part_e> gp = g_factory_part.template construct<NO_EDGE,T,dim-1>(div,domain);
// Get the number of processing units
size_t Np = v_cl.getProcessingUnits();
......@@ -119,33 +118,22 @@ private:
long int p_id = v_cl.getProcessUnitID();
// Convert the graph to metis
Metis<Graph_CSR<nm_v,nm_e>> met(gp,Np);
Metis<Graph_CSR<nm_part_v,nm_part_e>> met(gp,Np);
// decompose
met.decompose<nm_v::id>();
met.decompose<nm_part_v::id>();
// Optimize the decomposition creating bigger spaces
// And reducing Ghost over-stress
dec_optimizer<dim,Graph_CSR<nm_v,nm_e>> d_o(gp,div);
dec_optimizer<dim,Graph_CSR<nm_part_v,nm_part_e>> d_o(gp,div);
// set of Boxes produced by the decomposition optimizer
openfpm::vector<::Box<dim,size_t>> loc_box;
// a grig key poiting to the origin
grid_key_dx<dim> keyZero;
keyZero.zero();
// optimize the decomposition
d_o.template optimize<nm_v::sub_id,nm_v::id>(keyZero,gp,p_id,loc_box);
//-------------------DEBUG---------
VTKWriter<decltype(gp)> vtk(gp);
vtk.write("out_graph.vtk");
//---------------------------------
exit(1);
d_o.template optimize<nm_part_v::sub_id,nm_part_v::id>(gp,p_id,loc_box);
// convert into sub-domain
for (size_t s = 0 ; s < loc_box.size() ; s++)
......
......@@ -8,8 +8,8 @@
#ifndef CARTESIANGRAPHFACTORY_HPP_
#define CARTESIANGRAPHFACTORY_HPP_
#include "map_vector.hpp"
#include "map_graph.hpp"
#include "Vector/map_vector.hpp"
#include "Graph/map_graph.hpp"
#include "Grid/grid.hpp"
#include "Space/Shape/Box.hpp"
#include "Space/Shape/HyperCube.hpp"
......
......@@ -223,6 +223,17 @@ public:
~grid_dist_id()
{
}
/*! \brief Get the Virtual Cluster machine
*
* \return the Virtual cluster machine
*
*/
Vcluster & getVC()
{
return v_cl;
}
};
#endif
......@@ -55,6 +55,14 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
++dom;
}
// Get the virtual cluster machine
Vcluster & vcl = g_dist.getVC();
// reduce
vcl.reduce(count);
vcl.execute();
// Check
BOOST_REQUIRE_EQUAL(count,1024*1024);
/* auto g_it = g_dist.getIteratorBulk();
......
......@@ -181,7 +181,8 @@ private:
for (size_t j = 0 ; j < domains.size() ; j++)
{
if (graph.vertex(domains.get(j)).template get<p_sub>() < 0)
long int gs = graph.vertex(domains.get(j)).template get<p_sub>();
if (gs < 0)
{
// not assigned push it
......@@ -217,13 +218,17 @@ private:
// get the vertex and if does not have a sub-id and is assigned ...
if (graph.vertex(gh.LinId(gk)).template get<p_sub>() < 0)
long int pid = graph.vertex(gh.LinId(gk)).template get<p_sub>();
if (pid < 0)
{
// ... and the p_id different from -1
if (pr_id != -1)
{
// ... and the processor id of the sub-domain match p_id, add to the queue
if ( pr_id == graph.vertex(gh.LinId(gk)).template get<p_id>() )
long int pp_id = graph.vertex(gh.LinId(gk)).template get<p_id>();
if ( pr_id == pp_id)
domains_new.add(gh.LinId(gk));
}
else
......@@ -296,8 +301,11 @@ private:
// we get the processor id of the neighborhood sub-domain on direction d
size_t exp_p = graph.vertex(sub_w_e).template get<p_id>();
// we check if it is the same processor id
w_can_expand &= exp_p == domain_id;
// Check if already assigned
long int ass = graph.vertex(sub_w_e).template get<p_sub>();
// we check if it is the same processor id ans is not assigned
w_can_expand &= ((exp_p == domain_id) & (ass < 0));
// next domain
++it;
......@@ -376,8 +384,9 @@ private:
}
}
/*! \brief Initialize the wavefront
/*! \brief Initialize the wavefronts
*
* \param starting point of the wavefront set
* \param v_w Wavefront to initialize
*
*/
......@@ -395,6 +404,55 @@ private:
}
}
/*! \brief Get the first seed
*
* search in the graph for one sub-domain labelled with processor id
* to use as seed
*
* \tparam p_id property in the graph storing the sub-domain id
*
* \param Graph graph
* \param id processor id
*
*/
template<unsigned int p_id> grid_key_dx<dim> search_first_seed(Graph & graph, long int id)
{
// if no processor is selected return the first point
if (id < -1)
{
grid_key_dx<dim> key;
key.zero();
return key;
}
// Create a grid iterator
grid_key_dx_iterator<dim> g_sub(gh);
// iterate through all grid points
while (g_sub.isNext())
{
// get the actual key
const grid_key_dx<dim> & gk = g_sub.get();
// if the subdomain has the id we are searching stop
if (graph.vertex(gh.LinId(gk)).template get<p_id>() == id)
{
return gk;
}
++g_sub;
}
// If not found return an invalid key
grid_key_dx<dim> key;
key.invalid();
return key;
}
public:
/*! \brief Constructor
......@@ -421,7 +479,7 @@ public:
* \tparam j property containing the decomposition
* \tparam i property to fill with the sub-decomposition
*
* \param Seed point
* \param start_p seed point
* \param graph we are processing
*
*/
......@@ -445,7 +503,32 @@ public:
* \tparam j property containing the decomposition
* \tparam i property to fill with the sub-decomposition
*
* \param Seed point
* \param graph we are processing
* \param p_id Processor id (if p_id == -1 the optimization is done for all the processors)
* \param list of sub-domain boxes
*
*/
template <unsigned int p_sub, unsigned int p_id> void optimize(Graph & graph, long int pr_id, openfpm::vector<Box<dim,size_t>> & lb)
{
// search for the first seed
grid_key_dx<dim> key_seed = search_first_seed<p_id>(graph,pr_id);
// optimize
optimize<p_sub,p_id>(key_seed,graph,pr_id,lb);
}
/*! \brief optimize the graph
*
* Starting from a domain (hyper-cubic), it create wavefront at the boundary and expand
* the boundary until the wavefronts cannot expand any more.
* To the domains inside the hyper-cube one sub-id is assigned. This procedure continue until
* all the domain of one p_id has a sub-id
*
* \tparam j property containing the decomposition
* \tparam i property to fill with the sub-decomposition
*
* \param start_p seed point
* \param graph we are processing
* \param p_id Processor id (if p_id == -1 the optimization is done for all the processors)
* \param list of sub-domain boxes
......
......@@ -10,7 +10,7 @@
#include "Graph/CartesianGraphFactory.hpp"
#include "map_graph.hpp"
#include "Graph/map_graph.hpp"
#include "metis_util.hpp"
#include "dec_optimizer.hpp"
......
#include <iostream>
#include "config.h"
#include "Graph/CartesianGraphFactory.hpp"
#define BOOST_DISABLE_ASSERTS
......@@ -14,7 +15,7 @@
#include "Space/Shape/Box.hpp"
#include "util.hpp"
#include "CartesianGraphFactory_unit_test.hpp"
#include "Graph/CartesianGraphFactory_unit_test.hpp"
#include "metis_util_unit_test.hpp"
#include "dec_optimizer_unit_test.hpp"
#include "Grid/grid_dist_id_unit_test.hpp"
......
......@@ -9,7 +9,7 @@
#define METIS_UTIL_UNIT_TEST_HPP_
#include "Graph/CartesianGraphFactory.hpp"
#include "map_graph.hpp"
#include "Graph/map_graph.hpp"
#include "metis_util.hpp"
#undef GS_SIZE
......
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