Commit 14f1c4aa authored by incardon's avatar incardon

Adding Ghost with grid units

parent 43252977
openfpm_data @ 7c9737c9
Subproject commit 49040a1f74848f700ffda26002d98191b25ea813 Subproject commit 7c9737c9de9051c7af21edceee29c0aa11cc8afa
openfpm_devices @ 18cad2e7
Subproject commit 55db81226f047b3dfea1e3b276b67ee8374651b0 Subproject commit 18cad2e78602aa5f55f04926c327a7864d67b756
openfpm_io @ b7238aac
Subproject commit 935c25aaa275530ef1dafb86b7a9074e649a1d1f Subproject commit b7238aac71a82a304a7d455a8a62fc1149168fb5
openfpm_numerics @ 6ad65177
Subproject commit b4d8373acf148fcfb868fc3edff3eb2aed78c881 Subproject commit 6ad651779c654df68af427d6294bc4ba368a372e
openfpm_vcluster @ b57540c8
Subproject commit 54fcd2aeb78744c3b4f085d8f58b86cb8e325e52 Subproject commit b57540c803a8b7c269013f4a3c59b3f148d71edc
...@@ -405,26 +405,39 @@ class grid_dist_id ...@@ -405,26 +405,39 @@ class grid_dist_id
} }
} }
public: /*! \brief Default Copy constructor on this class make no sense and is unsafe, this definition disable it
*
// Which kind of grid the structure store */
typedef device_grid d_grid; grid_dist_id(const grid_dist_id<dim,St,T,Decomposition,Memory,device_grid> & g)
{
}
//! constructor /*! \brief Initialize the Cell decomposer of the grid
grid_dist_id(Vcluster v_cl, Decomposition & dec, const size_t (& g_sz)[dim], const Box<dim,St> & domain, const Ghost<dim,T> & ghost) *
:domain(domain),ghost(ghost),loc_grid(NULL),v_cl(v_cl),dec(dec),ginfo(g_sz),ginfo_v(g_sz) *
*/
inline void InitializeCellDecomposer(const size_t (& g_sz)[dim])
{ {
// check that the grid has valid size
check_size(g_sz); check_size(g_sz);
// For a 5x5 grid you have 4x4 Cell // For a 5x5 grid you have 4x4 Cell
size_t c_g[dim]; size_t c_g[dim];
for (size_t i = 0 ; i < dim ; i++) {c_g[i] = g_sz[i]-1;} for (size_t i = 0 ; i < dim ; i++) {c_g[i] = (g_sz[i]-1 > 0)?(g_sz[i]-1):1;}
// Initialize the cell decomposer // Initialize the cell decomposer
cd_sm.setDimensions(domain,c_g,0); cd_sm.setDimensions(domain,c_g,0);
}
/*! \brief Initialize the grid
*
* \param g_sz Global size of the grid
*
*/
inline void InitializeStructures(const size_t (& g_sz)[dim])
{
// fill the global size of the grid // fill the global size of the grid
for (int i = 0 ; i < dim ; i++) {this->g_sz[i] = g_sz[i];} for (size_t i = 0 ; i < dim ; i++) {this->g_sz[i] = g_sz[i];}
// Get the number of processor and calculate the number of sub-domain // Get the number of processor and calculate the number of sub-domain
// for decomposition // for decomposition
...@@ -434,17 +447,33 @@ public: ...@@ -434,17 +447,33 @@ public:
// Calculate the maximum number (before merging) of sub-domain on // Calculate the maximum number (before merging) of sub-domain on
// each dimension // each dimension
size_t div[dim]; size_t div[dim];
for (int i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
{div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));} {div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));}
// Create the sub-domains // Create the sub-domains
dec.setParameters(div); dec.setParameters(div,domain,ghost);
// Create local grid // Create local grid
Create(); Create();
// Calculate ghost boxes // Calculate ghost boxes
dec.calculateGhostBoxes(ghost); dec.calculateGhostBoxes();
}
public:
// Which kind of grid the structure store
typedef device_grid d_grid;
// Decomposition used
typedef Decomposition decomposition;
//! constructor
grid_dist_id(Vcluster v_cl, Decomposition & dec, const size_t (& g_sz)[dim] , const Box<dim,St> & domain, const Ghost<dim,T> & ghost)
:domain(domain),ghost(ghost),loc_grid(NULL),v_cl(v_cl),dec(dec),ginfo(g_sz),ginfo_v(g_sz)
{
InitializeCellDecomposer(g_sz);
InitializeStructures(g_sz);
} }
/*! \brief Constrcuctor /*! \brief Constrcuctor
...@@ -457,38 +486,37 @@ public: ...@@ -457,38 +486,37 @@ public:
grid_dist_id(const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,St> & g) grid_dist_id(const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,St> & g)
:domain(domain),ghost(g),dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster),ginfo(g_sz),ginfo_v(g_sz) :domain(domain),ghost(g),dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster),ginfo(g_sz),ginfo_v(g_sz)
{ {
// check that the grid has valid size InitializeCellDecomposer(g_sz);
check_size(g_sz); InitializeStructures(g_sz);
}
// For a 5x5 grid you have 4x4 Cell
size_t c_g[dim];
for (size_t i = 0 ; i < dim ; i++) {c_g[i] = (g_sz[i]-1 > 0)?(g_sz[i]-1):1;}
// Initialize the cell decomposer /*! \brief Constrcuctor
cd_sm.setDimensions(domain,c_g,0); *
* \param g_sz array with the grid size on each dimension
* \param domain domain where this grid live
* \param g Ghost given in grid units
*
*/
grid_dist_id(const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,size_t> & g)
:domain(domain),dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster),ginfo(g_sz),ginfo_v(g_sz)
{
InitializeCellDecomposer(g_sz);
// fill the global size of the grid // get the grid spacing
for (size_t i = 0 ; i < dim ; i++) {this->g_sz[i] = g_sz[i];} Box<dim,St> sp = cd_sm.getCellBox();
// Get the number of processor and calculate the number of sub-domain // enlarge 0.001 of the spacing
// for decomposition sp.magnify_fix_P1(0.001);
size_t n_proc = v_cl.getProcessingUnits();
size_t n_sub = n_proc * SUB_UNIT_FACTOR;
// Calculate the maximum number (before merging) of sub-domain on // set the ghost
// each dimension
size_t div[dim];
for (size_t i = 0 ; i < dim ; i++) for (size_t i = 0 ; i < dim ; i++)
{div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));} {
ghost.setLow(i,sp.getHigh(i));
// Create the sub-domains ghost.setHigh(i,sp.getHigh(i));
dec.setParameters(div,domain,ghost); }
// Create local grid
Create();
// Calculate ghost boxes // Initialize structures
dec.calculateGhostBoxes(); InitializeStructures(g_sz);
} }
/*! \brief Get an object containing the grid informations /*! \brief Get an object containing the grid informations
...@@ -547,6 +575,31 @@ public: ...@@ -547,6 +575,31 @@ public:
return true; return true;
} }
/*! \brief Get the size of local domain grids
*
* \return The size of the local domain
*
*/
size_t getLocalDomainSize()
{
size_t total = 0;
for (size_t i = 0 ; i < gdb_ext.size() ; i++)
{
total += gdb_ext.Dbox.getVolumeKey();
}
}
/*! \brief It return the informations about the local grids
*
* \return The information about the local grids
*
*/
const openfpm::vector<GBoxes<device_grid::dims>> & getLocalGridsInfo()
{
return gdb_ext;
}
/*! \brief It return an iterator that span the full grid domain (each processor span its local domain) /*! \brief It return an iterator that span the full grid domain (each processor span its local domain)
* *
* \return the iterator * \return the iterator
......
...@@ -181,7 +181,7 @@ void Test2D_sub(const Box<2,float> & domain, long int k) ...@@ -181,7 +181,7 @@ void Test2D_sub(const Box<2,float> & domain, long int k)
BOOST_REQUIRE_EQUAL(key_g.get(0),k/2); BOOST_REQUIRE_EQUAL(key_g.get(0),k/2);
BOOST_REQUIRE_EQUAL(key_g.get(1),k/2); BOOST_REQUIRE_EQUAL(key_g.get(1),k/2);
key_s_it = dom.getGKey(key); auto key_s_it = dom.getGKey(key);
BOOST_REQUIRE_EQUAL(key_g.get(0),key_s_it.get(0)); BOOST_REQUIRE_EQUAL(key_g.get(0),key_s_it.get(0));
BOOST_REQUIRE_EQUAL(key_g.get(1),key_s_it.get(1)); BOOST_REQUIRE_EQUAL(key_g.get(1),key_s_it.get(1));
...@@ -528,6 +528,53 @@ void Test3D(const Box<3,float> & domain, long int k) ...@@ -528,6 +528,53 @@ void Test3D(const Box<3,float> & domain, long int k)
} }
} }
void Test3D_gg(const Box<3,float> & domain, long int k, long int gk)
{
long int big_step = k / 30;
big_step = (big_step == 0)?1:big_step;
long int small_step = 1;
print_test( "Testing 3D grid k<=",k);
// 3D test
for ( ; k >= 2 ; k /= 2 )
{
BOOST_TEST_CHECKPOINT( "Testing 3D grid ghost integer k=" << k );
// grid size
size_t sz[3];
sz[0] = k;
sz[1] = k;
sz[2] = k;
// factor
float factor = pow(global_v_cluster->getProcessingUnits()/2.0f,1.0f/3.0f);
// Ghost
Ghost<3,size_t> g(gk);
// Distributed grid with id decomposition
grid_dist_id<3, float, scalar<float>, CartDecomposition<3,float>> g_dist(sz,domain,g);
// check the consistency of the decomposition
bool val = g_dist.getDecomposition().check_consistency();
BOOST_REQUIRE_EQUAL(val,true);
auto lg = g_dist.getLocalGridsInfo();
// for each local grid check that the border is 1 point
// (Warning this property can only be ensured with k is a multiple of 2)
// in the other case it will be mostly like that but cannot be ensured
for (size_t i = 0 ; i < lg.size() ; i++)
{
BOOST_REQUIRE_EQUAL(lg.get(i).Dbox.getLow(i),gk);
BOOST_REQUIRE_EQUAL(lg.get(i).GDbox.getHigh(i)- lg.get(i).Dbox.getHigh(i),gk);
}
}
}
void Test2D_complex(const Box<2,float> & domain, long int k) void Test2D_complex(const Box<2,float> & domain, long int k)
{ {
typedef Point_test<float> p; typedef Point_test<float> p;
...@@ -894,6 +941,26 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_sub_iterator_test_use) ...@@ -894,6 +941,26 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_sub_iterator_test_use)
Test3D_sub(domain3,k); Test3D_sub(domain3,k);
} }
BOOST_AUTO_TEST_CASE( grid_dist_id_with_grid_unit_ghost )
{
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
long int k = 1024*1024*global_v_cluster->getProcessingUnits();
k = std::pow(k, 1/2.);
// Test2D_gg(domain,k);
// Domain
Box<3,float> domain3({0.0,0.0,0.0},{1.0,1.0,1.0});
k = 128*128*128*global_v_cluster->getProcessingUnits();
k = std::pow(k, 1/3.);
Test3D_gg(domain3,k,1);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
#endif #endif
LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS)
noinst_PROGRAMS = pdata noinst_PROGRAMS = pdata
pdata_SOURCES = main.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp pdata_SOURCES = main.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_devices/src/Memleak_check.cpp
pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -Wno-unused-function pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -Wno-unused-function
pdata_CFLAGS = $(CUDA_CFLAGS) pdata_CFLAGS = $(CUDA_CFLAGS)
pdata_LDADD = $(LINKLIBS) -lmetis pdata_LDADD = $(LINKLIBS) -lmetis
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS)
noinst_PROGRAMS = cart_dec metis_dec dom_box noinst_PROGRAMS = cart_dec metis_dec dom_box
cart_dec_SOURCES = CartDecomposition_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp cart_dec_SOURCES = CartDecomposition_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_devices/src/Memleak_check.cpp
cart_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function cart_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
cart_dec_CFLAGS = $(CUDA_CFLAGS) cart_dec_CFLAGS = $(CUDA_CFLAGS)
cart_dec_LDADD = $(LINKLIBS) -lmetis cart_dec_LDADD = $(LINKLIBS) -lmetis
metis_dec_SOURCES = Metis_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp metis_dec_SOURCES = Metis_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_devices/src/Memleak_check.cpp
metis_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function metis_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
metis_dec_CFLAGS = $(CUDA_CFLAGS) metis_dec_CFLAGS = $(CUDA_CFLAGS)
metis_dec_LDADD = $(LINKLIBS) -lmetis metis_dec_LDADD = $(LINKLIBS) -lmetis
dom_box_SOURCES = domain_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp dom_box_SOURCES = domain_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_devices/src/Memleak_check.cpp
dom_box_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function dom_box_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
dom_box_CFLAGS = $(CUDA_CFLAGS) dom_box_CFLAGS = $(CUDA_CFLAGS)
dom_box_LDADD = $(LINKLIBS) dom_box_LDADD = $(LINKLIBS)
......
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