Commit 6cd8785d authored by incardon's avatar incardon

Fixing compilation for Adami code + fixing debugging examples

parent 7eac8b1e
...@@ -10,7 +10,7 @@ OBJ = main.o ...@@ -10,7 +10,7 @@ OBJ = main.o
$(CC) -O3 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH) $(CC) -O3 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
se_classes: $(OBJ) se_classes: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS) $(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS_SE2)
all: se_classes all: se_classes
......
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
#define SE_CLASS1 #define SE_CLASS1
#define SE_CLASS2 #define SE_CLASS2
// SE_CLASS2 only is unsupported, without SE_CLASS2_ONLY_TRACK
#define SE_CLASS2_ONLY_TRACK
#define SE_CLASS3 #define SE_CLASS3
#define THROW_ON_ERROR #define THROW_ON_ERROR
#define PRINT_STACKTRACE
#include "Memleak_check.hpp" #include "Memleak_check.hpp"
#include "Vector/vector_dist.hpp" #include "Vector/vector_dist.hpp"
#include "Decomposition/CartDecomposition.hpp" #include "Decomposition/CartDecomposition.hpp"
...@@ -100,7 +103,7 @@ int main(int argc, char* argv[]) ...@@ -100,7 +103,7 @@ int main(int argc, char* argv[])
vect_dist_key_dx vt(5048); vect_dist_key_dx vt(5048);
auto it = vd.getPos(vt); auto it = vd.getPos(vt);
} }
catch (size_t e) catch (std::exception e)
{ {
std::cerr << "Error notification of overflow \n"; std::cerr << "Error notification of overflow \n";
} }
......
...@@ -7,10 +7,10 @@ LDIR = ...@@ -7,10 +7,10 @@ LDIR =
OBJ = main.o OBJ = main.o
%.o: %.cpp %.o: %.cpp
$(CC) -O3 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH) $(CC) -O0 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
se_classes: $(OBJ) se_classes: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS) $(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS_SE2)
all: se_classes all: se_classes
......
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
#define SE_CLASS1 #define SE_CLASS1
#define SE_CLASS2 #define SE_CLASS2
// SE_CLASS2 is unsupported if not used in combination with SE_CLASS2_TRACK_ONLY
#define SE_CLASS2_ONLY_TRACK
#define SE_CLASS3 #define SE_CLASS3
#define PRINT_STACKTRACE
#define THROW_ON_ERROR #define THROW_ON_ERROR
#include "Memleak_check.hpp" #include "Memleak_check.hpp"
#include "Grid/grid_dist_id.hpp" #include "Grid/grid_dist_id.hpp"
...@@ -80,7 +83,7 @@ int main(int argc, char* argv[]) ...@@ -80,7 +83,7 @@ int main(int argc, char* argv[])
// //
if (v_cl.getProcessUnitID() == 0) if (v_cl.getProcessUnitID() == 0)
print_alloc(); {print_alloc();}
// //
// ### WIKI 5 ### // ### WIKI 5 ###
......
...@@ -102,8 +102,8 @@ void init(grid_dist_id<2,double,aggregate<double> > & g_dist, const size_t (& sz ...@@ -102,8 +102,8 @@ void init(grid_dist_id<2,double,aggregate<double> > & g_dist, const size_t (& sz
//! \cond [init field zero] \endcond //! \cond [init field zero] \endcond
if (key_g.get(0) == 0 || key_g.get(0) == sz[0] || if (key_g.get(0) < 0 || key_g.get(0) == sz[0] ||
key_g.get(1) == 0 || key_g.get(1) == sz[1]) key_g.get(1) < 0 || key_g.get(1) == sz[1])
{ {
// Boundary part // Boundary part
g_dist.template get<0>(key) = 0.0; g_dist.template get<0>(key) = 0.0;
......
...@@ -861,8 +861,6 @@ int main(int argc, char* argv[]) ...@@ -861,8 +861,6 @@ int main(int argc, char* argv[])
timer tot_sim; timer tot_sim;
tot_sim.start(); tot_sim.start();
cudaProfilerStart();
size_t write = 0; size_t write = 0;
size_t it = 0; size_t it = 0;
size_t it_reb = 0; size_t it_reb = 0;
...@@ -988,8 +986,6 @@ int main(int argc, char* argv[]) ...@@ -988,8 +986,6 @@ int main(int argc, char* argv[])
openfpm_finalize(); openfpm_finalize();
cudaProfilerStop();
} }
#else #else
......
openfpm_data @ b695601c
Subproject commit fdbff4c0b9b762e3447da261812e777eba52dcd4 Subproject commit b695601ce2fbf723059e6872f92feb42ee078207
openfpm_devices @ 1a3dfc0a
Subproject commit 73c26af3e5ee3ad324e6c9fc62996951c0fd90a8 Subproject commit 1a3dfc0a96e4ad8ab61f7f1f7cdc9127ea99041c
openfpm_vcluster @ 9c2f9df8
Subproject commit 03b15252b4b8aae304e1011097499f7617a1d017 Subproject commit 9c2f9df89aed28a20f80a503c4430928e1e33b26
...@@ -39,7 +39,7 @@ enum debug_iterator ...@@ -39,7 +39,7 @@ enum debug_iterator
* *
*/ */
template<typename vector_dist_type, typename functor_test, typename functor_print> template<typename vector_dist_type, typename functor_test, typename functor_print>
bool debug_find(vector_dist_type vd, functor_test fun_test, functor_print fun_print, bool debug_find(vector_dist_type & vd, functor_test fun_test, functor_print fun_print,
debug_iterator it = debug_iterator::DOMAIN_IT, debug_run type_of_run = debug_run::HOST, debug_iterator it = debug_iterator::DOMAIN_IT, debug_run type_of_run = debug_run::HOST,
bool print = true) bool print = true)
{ {
......
...@@ -1210,7 +1210,7 @@ public: ...@@ -1210,7 +1210,7 @@ public:
* \param dec_gran number of sub-sub-domain for each processor * \param dec_gran number of sub-sub-domain for each processor
* *
*/ */
void setGoodParameters(::Box<dim,T> domain_, void setGoodParameters(::Box<dim,T> & domain_,
const size_t (& bc)[dim], const size_t (& bc)[dim],
const Ghost<dim,T> & ghost, const Ghost<dim,T> & ghost,
size_t dec_gran, size_t dec_gran,
...@@ -1245,7 +1245,7 @@ public: ...@@ -1245,7 +1245,7 @@ public:
{tot_size *= div[i];} {tot_size *= div[i];}
// the granularity is too coarse increase the divisions // the granularity is too coarse increase the divisions
if (tot_size / n_proc > 0.75*dec_gran ) if (tot_size / n_proc > (unsigned int long)(0.75*dec_gran) )
{break;} {break;}
nsub_to_div(div,n_sub,dim_r); nsub_to_div(div,n_sub,dim_r);
...@@ -1280,7 +1280,7 @@ public: ...@@ -1280,7 +1280,7 @@ public:
* *
*/ */
void setParameters(const size_t (& div_)[dim], void setParameters(const size_t (& div_)[dim],
::Box<dim,T> domain_, ::Box<dim,T> & domain_,
const size_t (& bc)[dim], const size_t (& bc)[dim],
const Ghost<dim,T> & ghost, const Ghost<dim,T> & ghost,
const grid_sm<dim,void> & sec_dist = grid_sm<dim,void>()) const grid_sm<dim,void> & sec_dist = grid_sm<dim,void>())
......
...@@ -316,7 +316,7 @@ public: ...@@ -316,7 +316,7 @@ public:
* \param grid info * \param grid info
* \param dom domain * \param dom domain
*/ */
void createCartGraph(grid_sm<dim, void> & grid, Box<dim, T> dom) void createCartGraph(grid_sm<dim, void> & grid, Box<dim, T> & dom)
{ {
size_t bc[dim]; size_t bc[dim];
......
...@@ -105,7 +105,10 @@ struct Box_sub ...@@ -105,7 +105,10 @@ struct Box_sub
//! Constructor reset cmb //! Constructor reset cmb
Box_sub() Box_sub()
{cmb.zero();} {
r_sub = (size_t)-1;
cmb.zero();
}
}; };
//! Particular case for local internal ghost boxes //! Particular case for local internal ghost boxes
......
...@@ -51,7 +51,7 @@ __device__ __host__ inline int processorID_impl(T2 & p, ...@@ -51,7 +51,7 @@ __device__ __host__ inline int processorID_impl(T2 & p,
#endif #endif
/* coverty[negative_returns] */
return sub_domains_global.template get<1>(e); return sub_domains_global.template get<1>(e);
} }
......
...@@ -1219,5 +1219,276 @@ BOOST_AUTO_TEST_CASE(vector_dist_remove_marked) ...@@ -1219,5 +1219,276 @@ BOOST_AUTO_TEST_CASE(vector_dist_remove_marked)
} }
BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration_gpu )
{
typedef aggregate<size_t,size_t,size_t> part_prop;
Vcluster<> & v_cl = create_vcluster();
if (v_cl.getProcessingUnits() > 24)
{return;}
float L = 1000.0;
// set the seed
// create the random generator engine
std::default_random_engine eg;
eg.seed(v_cl.rank()*4533);
std::uniform_real_distribution<float> ud(-L,L);
long int k = 4096 * v_cl.getProcessingUnits();
long int big_step = k / 4;
big_step = (big_step == 0)?1:big_step;
BOOST_TEST_CHECKPOINT( "Testing 3D periodic vector symmetric cell-list k=" << k );
Box<3,float> box({-L,-L,-L},{L,L,L});
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float r_cut = 100.0;
// ghost
Ghost<3,float> ghost(r_cut);
// Distributed vector
vector_dist_gpu<3,float,part_prop> vd(k,box,bc,ghost,BIND_DEC_TO_GHOST);
size_t start = vd.init_size_accum(k);
auto it = vd.getIterator();
while (it.isNext())
{
auto key = it.get();
vd.getPosWrite(key)[0] = ud(eg);
vd.getPosWrite(key)[1] = ud(eg);
vd.getPosWrite(key)[2] = ud(eg);
// Fill some properties randomly
vd.template getPropWrite<0>(key) = 0;
vd.template getPropWrite<1>(key) = 0;
vd.template getPropWrite<2>(key) = key.getKey() + start;
++it;
}
vd.map();
// sync the ghost
vd.template ghost_get<0,2>();
auto NN = vd.getCellList(r_cut);
auto p_it = vd.getDomainIterator();
while (p_it.isNext())
{
auto p = p_it.get();
Point<3,float> xp = vd.getPosRead(p);
auto Np = NN.getNNIterator(NN.getCell(xp));
while (Np.isNext())
{
auto q = Np.get();
if (p.getKey() == q)
{
++Np;
continue;
}
// repulsive
Point<3,float> xq = vd.getPosRead(q);
Point<3,float> f = (xp - xq);
float distance = f.norm();
// Particle should be inside 2 * r_cut range
if (distance < r_cut )
{
vd.template getPropWrite<0>(p)++;
}
++Np;
}
++p_it;
}
// We now divide the particles on 4 phases
openfpm::vector<vector_dist_gpu<3,float,part_prop>> phases;
phases.add( vector_dist_gpu<3,float,part_prop>(vd.getDecomposition(),0));
phases.add( vector_dist_gpu<3,float,part_prop>(phases.get(0).getDecomposition(),0));
phases.add( vector_dist_gpu<3,float,part_prop>(phases.get(0).getDecomposition(),0));
phases.add( vector_dist_gpu<3,float,part_prop>(phases.get(0).getDecomposition(),0));
auto it2 = vd.getDomainIterator();
while (it2.isNext())
{
auto p = it2.get();
if (p.getKey() % 4 == 0)
{
phases.get(0).add();
phases.get(0).getLastPos()[0] = vd.getPos(p)[0];
phases.get(0).getLastPos()[1] = vd.getPos(p)[1];
phases.get(0).getLastPos()[2] = vd.getPos(p)[2];
phases.get(0).getLastProp<1>() = 0;
phases.get(0).template getLastProp<2>() = vd.template getProp<2>(p);
}
else if (p.getKey() % 4 == 1)
{
phases.get(1).add();
phases.get(1).getLastPos()[0] = vd.getPos(p)[0];
phases.get(1).getLastPos()[1] = vd.getPos(p)[1];
phases.get(1).getLastPos()[2] = vd.getPos(p)[2];
phases.get(1).getLastProp<1>() = 0;
phases.get(1).template getLastProp<2>() = vd.template getProp<2>(p);
}
else if (p.getKey() % 4 == 2)
{
phases.get(2).add();
phases.get(2).getLastPos()[0] = vd.getPos(p)[0];
phases.get(2).getLastPos()[1] = vd.getPos(p)[1];
phases.get(2).getLastPos()[2] = vd.getPos(p)[2];
phases.get(2).getLastProp<1>() = 0;
phases.get(2).template getLastProp<2>() = vd.template getProp<2>(p);
}
else
{
phases.get(3).add();
phases.get(3).getLastPos()[0] = vd.getPos(p)[0];
phases.get(3).getLastPos()[1] = vd.getPos(p)[1];
phases.get(3).getLastPos()[2] = vd.getPos(p)[2];
phases.get(3).getLastProp<1>() = 0;
phases.get(3).template getLastProp<2>() = vd.template getProp<2>(p);
}
++it2;
}
// now we synchronize the ghosts
for (size_t i = 0 ; i < phases.size() ; i++)
{
phases.get(i).template ghost_get<0,1,2>();
}
typedef decltype(phases.get(0).getCellListSym(r_cut)) cell_list_type;
openfpm::vector<cell_list_type> NN_ptr;
for (size_t i = 0 ; i < phases.size() ; i++)
{
NN_ptr.add(phases.get(i).getCellListSym(r_cut));
}
// We now interact all the phases
for (size_t i = 0 ; i < phases.size() ; i++)
{
for (size_t j = 0 ; j < phases.size() ; j++)
{
auto p_it2 = phases.get(i).getDomainIterator();
while (p_it2.isNext())
{
auto p = p_it2.get();
Point<3,float> xp = phases.get(i).getPosRead(p);
auto Np = NN_ptr.get(j).getNNIteratorSymMP<NO_CHECK>(NN_ptr.get(j).getCell(xp),p.getKey(),phases.get(i).getPosVector(),phases.get(j).getPosVector());
while (Np.isNext())
{
auto q = Np.get();
if (p.getKey() == q && i == j)
{
++Np;
continue;
}
// repulsive
Point<3,float> xq = phases.get(j).getPosRead(q);
Point<3,float> f = (xp - xq);
float distance = f.norm();
// Particle should be inside r_cut range
if (distance < r_cut )
{
phases.get(i).template getPropWrite<1>(p)++;
phases.get(j).template getPropWrite<1>(q)++;
}
++Np;
}
++p_it2;
}
}
}
for (size_t i = 0 ; i < phases.size() ; i++)
{
phases.get(i).template ghost_put<add_,1>();
}
auto p_it3 = vd.getDomainIterator();
bool ret = true;
while (p_it3.isNext())
{
auto p = p_it3.get();
int ph;
if (p.getKey() % 4 == 0)
{ph = 0;}
else if (p.getKey() % 4 == 1)
{ph = 1;}
else if (p.getKey() % 4 == 2)
{ph = 2;}
else
{ph = 3;}
size_t pah = p.getKey()/4;
ret &= phases.get(ph).template getPropRead<1>(pah) == vd.template getPropRead<0>(p);
if (ret == false)
{
std::cout << "Error on particle: " << vd.template getPropRead<2>(p) << " " << v_cl.rank() << std::endl;
std::cout << "phase " << ph << " particle " << pah << " " << phases.get(ph).template getPropRead<1>(pah) << " A " << vd.template getPropRead<0>(p) << std::endl;
break;
}
++p_it3;
}
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
...@@ -168,6 +168,8 @@ void test_reorder_cl() ...@@ -168,6 +168,8 @@ void test_reorder_cl()
} }
} }
BOOST_AUTO_TEST_SUITE( vector_dist_cell_list_test_suite )
BOOST_AUTO_TEST_CASE( vector_dist_reorder_2d_test ) BOOST_AUTO_TEST_CASE( vector_dist_reorder_2d_test )
{ {
test_reorder_sfc(reorder_opt::HILBERT); test_reorder_sfc(reorder_opt::HILBERT);
...@@ -1931,9 +1933,20 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_list_multi_type ) ...@@ -1931,9 +1933,20 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_list_multi_type )
BOOST_REQUIRE_EQUAL(ret,true); BOOST_REQUIRE_EQUAL(ret,true);
} }
// Point and global id
struct point_and_gid
{
size_t id;
Point<3,float> xq;
bool operator<(const struct point_and_gid & pag) const
{
return (id < pag.id);
}
};
BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration ) template<typename vector_dist_mp>
void test_vector_dist_particle_NN_MP_iteration()
{ {
Vcluster<> & v_cl = create_vcluster(); Vcluster<> & v_cl = create_vcluster();
...@@ -1966,22 +1979,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration ) ...@@ -1966,22 +1979,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration )
// ghost // ghost
Ghost<3,float> ghost(r_cut); Ghost<3,float> ghost(r_cut);
// Point and global id // typedef aggregate<size_t,size_t,size_t,openfpm::vector<point_and_gid>,openfpm::vector<point_and_gid>> part_prop;
struct point_and_gid
{
size_t id;
Point<3,float> xq;
bool operator<(const struct point_and_gid & pag) const
{
return (id < pag.id);
}
};
typedef aggregate<size_t,size_t,size_t,openfpm::vector<point_and_gid>,openfpm::vector<point_and_gid>> part_prop;