Commit 3a20e85c authored by incardon's avatar incardon

Add last changes

parent 76d0407d
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,7 +18,7 @@
#include "metis_util.hpp"
#include "dec_optimizer.hpp"
#include "Space/Shape/Box.hpp"
#include "Space/space.hpp"
#include "Space/Shape/Point.hpp"
/**
* \brief This class decompose a space into subspaces
......@@ -51,7 +51,7 @@ public:
private:
//! This is the access_key to data_s, for example in the case of vector
//! This is the key type toaccess data_s, for example in the case of vector
//! acc_key is size_t
typedef typename data_s<SpaceBox<dim,T>,device_l<SpaceBox<dim,T>>,Memory,openfpm::vector_grow_policy_default,openfpm::vect_isel<SpaceBox<dim,T>>::value >::access_key acc_key;
......@@ -262,13 +262,31 @@ public:
*
*/
template<typename Mem> size_t inline processorID(encapc<1, space<dim,T>, Mem> p)
template<typename Mem> size_t inline processorID(encapc<1, Point<dim,T>, Mem> p)
{
size_t pid = 0;
for (size_t i = 0 ; i < dim ; i++)
{
pid += p.get().get(i);
pid += p.template get<Point<dim,T>::x>()[i];
}
return pid;
}
/*! \brief processorID return in which processor the particle should go
*
* \return processorID
*
*/
size_t inline processorID(T (&p)[dim])
{
size_t pid = 0;
for (size_t i = 0 ; i < dim ; i++)
{
pid += p[i];
}
return pid;
......@@ -511,27 +529,29 @@ public:
return domain;
}
/*! \brief It return a graph that represent the domain decomposed into the cartesian grid
/*! \brief Check if the particle is local
*
* \param p object position
*
* It return a graph that represent the domain decomposed into the cartesian grid
* \return true if it is local
*
*/
/* Graph<> createGraphModel()
template<typename Mem> bool isLocal(encapc<1, Point<dim,T>, Mem> p)
{
return processorID<Mem>() == v_cl.getProcessUnitID();
}
}*/
/*! \brief It return a graph that represent the domain decomposed into the cartesian grid
/*! \brief Check if the particle is local
*
* It return a graph that represent the domain decomposed into the cartesian grid
* \param p object position
*
* \return true if it is local
*
*/
/* Graph<> createLocalGraphMode()
bool isLocal(T (&pos)[dim])
{
}*/
return processorID(pos) == v_cl.getProcessUnitID();
}
};
......
......@@ -24,25 +24,18 @@ struct bisect_unroll
{
ORB & orb;
// start
size_t start = 0;
// level
size_t n = 0;
/*! \brief constructor
*
*/
bisect_unroll(ORB & orb, size_t start, size_t n)
:orb(orb),start(start),n(n)
bisect_unroll(ORB & orb)
:orb(orb)
{};
//! It call the copy function for each property
template<typename T>
void operator()(T& t)
{
start += orb.template bisect<T::value>(n,start);
n = (n+1)%dim;
orb.template bisect<T::value>();
}
};
......@@ -102,7 +95,7 @@ public:
*
*/
template<unsigned int dim, typename T, typename loc_wg=openfpm::vector<float>, typename loc_pos=openfpm::vector<space<dim,T>> , typename Box=Box<dim,T>, template<typename,typename> class Tree=Graph_CSR_s>
template<unsigned int dim, typename T, typename loc_wg=openfpm::vector<float>, typename loc_pos=openfpm::vector<Point<dim,T>> , typename Box=Box<dim,T>, template<typename,typename> class Tree=Graph_CSR_s>
class ORB
{
// Virtual cluster
......@@ -135,7 +128,7 @@ class ORB
*/
template<unsigned int dir> void local_cm(size_t start)
{
typedef space<dim,T> s;
typedef Point<dim,T> s;
// reset the counters and accumulators
cm.fill(0);
......@@ -171,10 +164,13 @@ class ORB
template<unsigned int dir> inline void local_label()
{
typedef space<dim,T> s;
typedef Point<dim,T> s;
// we just have to create the labels array with zero
if (dir == 0)
// direction of the previous split
const size_t dir_cm = (dir == 0)?(dim-1):(dir-1);
// if it is the first iteration we just have to create the labels array with zero
if (grp.getNVertex() == 1)
{lp_lbl.resize(lp.size());lp_lbl.fill(0); return;}
// we check where (the node) the particles live
......@@ -199,7 +195,7 @@ class ORB
// if the particle n-coordinate is smaller than the CM is inside the child n1
// otherwise is inside the child n2
if (lp.template get<s::x>(key)[dir] < cm)
if (lp.template get<s::x>(key)[dir_cm] < cm)
{lp_lbl.get(key) = n1;}
else
{lp_lbl.get(key) = n2;}
......@@ -208,13 +204,22 @@ class ORB
}
}
template<unsigned int dir> size_t bisect(size_t n, size_t start)
/*! \brief Bisect the domains along one direction
*
* \tparam dir direction where to split
*
*/
template<unsigned int dir> size_t bisect()
{
//
size_t start = grp.getNVertex();
// first label the local particles
local_label<dir>();
// Index from where start the first leaf
size_t n_node = (n == 0)?1: 2 << (n-1);
size_t n_node = (start + 1) / 2;
// Calculate the local cm
local_cm<dir>(start - n_node);
......@@ -279,10 +284,11 @@ public:
grp.addVertex();
// unroll bisection cycle
bisect_unroll<dim,ORB_class> bu(*this,1,0);
bisect_unroll<dim,ORB_class> bu(*this);
for (size_t i = 0 ; i < dim_cycle ; i++)
{
boost::mpl::for_each< boost::mpl::range_c<int,0,dim> >(bu);
// bu is recreated several time internaly
}
// calculate and execute the remaining cycles
......
......@@ -20,16 +20,16 @@ BOOST_AUTO_TEST_CASE( ORB_test_use)
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
// Seed with a real random value, if available
// and create the random generator engine
// set the seed
// create the random generator engine
std::srand(global_v_cluster->getProcessUnitID());
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
typedef space<3,float> p;
typedef Point<3,float> p;
// create a random local vector of particles
openfpm::vector<space<3,float>> vp(N_POINTS);
openfpm::vector<Point<3,float>> vp(N_POINTS);
// fill the particles
......
This diff is collapsed.
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
bin_PROGRAMS = pdata
pdata_SOURCES = main.cpp ../../OpenFPM_devices/src/memory/HeapMemory.cpp ../../OpenFPM_vcluster/src/VCluster.cpp ../../OpenFPM_data/src/Memleak_check.cpp
pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH)
pdata_CFLAGS = $(CUDA_CFLAGS)
pdata_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/ -L../../metis_install/lib -lmetis
.cu.o :
$(NVCC) $(NVCCFLAGS) -o $@ -c $<
This diff is collapsed.
/*
* spaces.hpp
*
* Created on: Mar 10, 2015
* Author: Pietro Incardona
*/
#ifndef SPACES_HPP_
#define SPACES_HPP_
template<unsigned int dim, typename T> class space
{
public:
typedef boost::fusion::vector<T[dim]> type;
typedef typename memory_traits_inte<type>::type memory_int;
typedef typename memory_traits_lin<type>::type memory_lin;
type data;
static const unsigned int x = 0;
static const unsigned int max_prop = 1;
};
#endif /* SPACES_HPP_ */
......@@ -9,7 +9,7 @@
#define VECTOR_HPP_
#include "VCluster.hpp"
#include "Space/space.hpp"
#include "Space/Shape/Point.hpp"
#include "Vector/vector_dist_iterator.hpp"
#include "Space/Shape/Box.hpp"
#include "Vector/vector_dist_key.hpp"
......@@ -21,7 +21,7 @@
*
*/
template<typename space, typename prop, typename Box, typename Decomposition , typename Memory=HeapMemory, bool with_id=false>
template<typename point, typename prop, typename Box, typename Decomposition , typename Memory=HeapMemory, bool with_id=false>
class vector_dist
{
private:
......@@ -30,7 +30,7 @@ private:
Decomposition dec;
// Particle position vector for each subdomain the last one is the unassigned particles vector
Vcluster_object_array<openfpm::vector<space>> v_pos;
Vcluster_object_array<openfpm::vector<point>> v_pos;
// Particle properties vector for each subdomain the last one is the unassigned particles vector
Vcluster_object_array<openfpm::vector<prop>> v_prp;
......@@ -49,7 +49,7 @@ public:
:dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster)
{
// Allocate unassigned particles vectors
v_pos = v_cl.template allocate<openfpm::vector<space>>(1);
v_pos = v_cl.template allocate<openfpm::vector<point>>(1);
v_prp = v_cl.template allocate<openfpm::vector<prop>>(1);
// resize the position vector
......@@ -66,9 +66,9 @@ public:
// Calculate the maximum number (before merging) of sub-domain on
// each dimension
size_t div[space::max_prop];
for (int i = 0 ; i < space::max_prop ; i++)
{div[i] = round_big_2(pow(n_sub,1.0/space::max_prop));}
size_t div[point::dims];
for (int i = 0 ; i < point::dims ; i++)
{div[i] = round_big_2(pow(n_sub,1.0/point::dims));}
// Create the sub-domains
dec.setParameters(div,box);
......@@ -134,9 +134,9 @@ public:
* \return an iterator
*
*/
vector_dist_iterator<openfpm::vector<space>> getIterator()
vector_dist_iterator<openfpm::vector<point>> getIterator()
{
return vector_dist_iterator<openfpm::vector<space>>(v_pos);
return vector_dist_iterator<openfpm::vector<point>>(v_pos);
}
/*! \brief Get the iterator across the properties of the particles
......@@ -144,12 +144,20 @@ public:
* \return an iterator
*
*/
vector_dist_iterator<openfpm::vector<space>> getPropIterator()
vector_dist_iterator<openfpm::vector<point>> getPropIterator()
{
return vector_dist_iterator<openfpm::vector<prop>>(v_prp);
}
/*! \brief Get the decomposition
*
* \return
*
*/
Decomposition & getDecomposition()
{
return dec;
}
};
......
......@@ -15,12 +15,16 @@ BOOST_AUTO_TEST_SUITE( vector_dist_test )
BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use)
{
Box<2,float> box({0.0,0.0},{1.0,1.0});
vector_dist<space<2,float>, Point_test<float>, Box<2,float>, CartDecomposition<2,float> > vd(4096,box);
typedef Point<2,float> s;
// set the seed
// create the random generator engine
std::srand(global_v_cluster->getProcessUnitID());
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
// randomized
size_t seed = global_v_cluster->getProcessUnitID();
srand (time(NULL)+seed);
Box<2,float> box({0.0,0.0},{1.0,1.0});
vector_dist<Point<2,float>, Point_test<float>, Box<2,float>, CartDecomposition<2,float> > vd(4096,box);
auto it = vd.getIterator();
......@@ -28,13 +32,27 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use)
{
auto key = it.get();
vd.template getPos<space<2,float>::x>(key)[0] = (rand()/(double)(RAND_MAX));
vd.template getPos<space<2,float>::x>(key)[1] = (rand()/(double)(RAND_MAX));
vd.template getPos<s::x>(key)[0] = ud(eg);
vd.template getPos<s::x>(key)[1] = ud(eg);
++it;
}
vd.map();
// Check if we have all the local particles
auto & ct = vd.getDecomposition();
it = vd.getIterator();
while (it.isNext())
{
auto key = it.get();
BOOST_REQUIRE_EQUAL(ct.isLocal(vd.template getPos<s::x>(key)),true);
++it;
}
}
BOOST_AUTO_TEST_SUITE_END()
......
This diff is collapsed.
/* src/config.h. Generated from config.h.in by configure. */
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Debug */
#define DEBUG /**/
/* Debug */
#define DEBUG_MODE /**/
/* GPU support */
/* #undef GPU */
/* MPI Enabled */
#define HAVE_MPI /**/
/* Memory check, corruption and leak */
/* #undef MEMLEAK_CHECK */
/* NVCC compiling */
#define NVCC /**/
/* Name of package */
#define PACKAGE "full-package-name"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "BUG-REPORT-ADDRESS"
/* Define to the full name of this package. */
#define PACKAGE_NAME "FULL-PACKAGE-NAME"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "FULL-PACKAGE-NAME VERSION"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "full-package-name"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "VERSION"
/* Version number of package */
#define VERSION "VERSION"
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Debug */
#undef DEBUG
/* Debug */
#undef DEBUG_MODE
/* GPU support */
#undef GPU
/* MPI Enabled */
#undef HAVE_MPI
/* Memory check, corruption and leak */
#undef MEMLEAK_CHECK
/* NVCC compiling */
#undef NVCC
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Version number of package */
#undef VERSION
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Debug */
#undef DEBUG
/* Debug */
#undef DEBUG_MODE
/* GPU support */
#undef GPU
/* Memory check, corruption and leak */
#undef MEMLEAK_CHECK
/* NVCC compiling */
#undef NVCC
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Version number of package */
#undef VERSION
File added
timestamp for src/config.h
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