Commit c9206f56 authored by incardon's avatar incardon
Browse files

Fixing the test

parent 08df56ec
......@@ -134,14 +134,6 @@ fi
AX_LIB_HILBERT([],[echo "Cannot detect libhilbert, use the --with-libhilbert option if it is not installed in the default location"
exit 210])
##########
## Check for PETSC
AX_LIB_PETSC()
## Check for quadmath
have_quad_lib=no
have_quad_head=no
......@@ -372,6 +364,12 @@ AX_LAPACK([],[])
AX_SUITESPARSE([],[])
##########
## Check for PETSC
AX_LIB_PETSC()
###### Checking for EIGEN
AX_EIGEN([],[])
......
......@@ -716,7 +716,7 @@ int main(int argc, char* argv[])
// Grid points on x=128 y=64 z=64
// if we use Re = 7500
// long int sz[] = {1600,400,400};
long int sz[] = {96,96,96};
long int sz[] = {128,128,128};
size_t szu[] = {(size_t)sz[0],(size_t)sz[1],(size_t)sz[2]};
periodicity<3> bc = {{PERIODIC,PERIODIC,PERIODIC}};
......
......@@ -105,7 +105,7 @@ AC_DEFUN([AX_LIB_PETSC], [
AX_OPENMP([CFLAGS="$OPENMP_CFLAGS"
LDFLAGS="$OPENMP_LDFLAGS"],[])
CFLAGS="$CFLAGS -I$with_petsc/include $HDF5_INCLUDE $METIS_INCLUDE "
LDFLAGS="$LDFLAGS -L$with_petsc/lib $HDF5_LDFLAGS $HDF5_LIBS $METIS_LIB -lmetis "
LDFLAGS="$LDFLAGS -L$with_petsc/lib $HDF5_LDFLAGS $HDF5_LIBS $METIS_LIB -lmetis $SUITESPARSE_LIBS"
CC=$CXX
AC_LANG_SAVE
......
openfpm_io @ a0466487
Subproject commit 701d310eb6c3347e52327ddcf9a814c22b0dadbd
Subproject commit a0466487a3c6a1a8c8e29f02afd4db6beb9186ea
......@@ -34,7 +34,7 @@ if [ x"$platform" == x"cygwin" ]; then
fi
echo "Compiling SuiteSparse without CUDA (old variable $CUDA)"
make "CUDA=no" "BLAS=-L$1/OPENBLAS/lib -lopenblas" "LAPACK="
make "CUDA=no" "BLAS=-L$1/OPENBLAS/lib -lopenblas -pthread" "LAPACK="
if [ $? != 0 ]; then
echo "Failed to compile SuiteSparse"
exit 1
......
LINKLIBS = $(HDF5_LDFLAGS) $(HDF5_LIBS) $(OPENMP_LDFLAGS) $(LIBHILBERT_LIB) $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) $(PETSC_LIB) $(PARMETIS_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(BOOST_CHRONO_LIB) $(BOOST_TIMER_LIB) $(BOOST_SYSTEM_LIB) $(LIBIFCORE)
LINKLIBS = $(HDF5_LDFLAGS) $(HDF5_LIBS) $(OPENMP_LDFLAGS) $(LIBHILBERT_LIB) $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) $(PETSC_LIB) $(PARMETIS_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(BOOST_CHRONO_LIB) $(BOOST_TIMER_LIB) $(BOOST_SYSTEM_LIB) $(LIBIFCORE) $(SUITESPARSE_LIBS)
noinst_PROGRAMS = pdata
pdata_SOURCES = main.cpp Grid/tests/grid_dist_id_HDF5_chckpnt_restart_test.cpp Grid/tests/grid_dist_id_unit_test.cpp Grid/tests/staggered_grid_dist_unit_test.cpp Vector/tests/vector_dist_cell_list_tests.cpp Vector/tests/vector_dist_complex_prp_unit_test.cpp Vector/tests/vector_dist_HDF5_chckpnt_restart_test.cpp Vector/tests/vector_dist_MP_unit_tests.cpp Vector/tests/vector_dist_NN_tests.cpp Vector/tests/vector_dist_unit_test.cpp pdata_performance.cpp Decomposition/tests/CartDecomposition_unit_test.cpp Decomposition/tests/shift_vect_converter_tests.cpp lib/pdata.cpp test_multiple_o.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster/VCluster.cpp ../openfpm_devices/src/Memleak_check.cpp
......
......@@ -319,57 +319,38 @@ BOOST_AUTO_TEST_CASE( vector_dist_particle_iteration )
BOOST_REQUIRE_EQUAL((long int)count,k);
}
BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration )
BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_update_with_limit )
{
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessingUnits() > 24)
{return;}
float L = 1000.0;
if (v_cl.getProcessingUnits() > 12)
return;
// set the seed
// create the random generator engine
std::srand(0);
std::srand(v_cl.getProcessUnitID());
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(-L,L);
long int k = 4096 * v_cl.getProcessingUnits();
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
long int big_step = k / 4;
big_step = (big_step == 0)?1:big_step;
long int k = 750 * v_cl.getProcessingUnits();
print_test_v("Testing 3D periodic vector symmetric cell-list k=",k);
BOOST_TEST_CHECKPOINT( "Testing 3D periodic vector symmetric cell-list k=" << k );
print_test_v("Testing 3D particle cell-list with radius at limit= ",k);
BOOST_TEST_CHECKPOINT( "Testing 3D particle cell-list with radius at limit= " << k );
Box<3,float> box({-L,-L,-L},{L,L,L});
Box<3,float> box({0.0,0.0,0.0},{0.1,0.39,0.39});
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float r_cut = 100.0;
float r_cut = 0.1;
// ghost
Ghost<3,float> ghost(r_cut);
// 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);
}
};
typedef aggregate<size_t,size_t,size_t,openfpm::vector<point_and_gid>,openfpm::vector<point_and_gid>> part_prop;
typedef aggregate<float> part_prop;
// Distributed vector
vector_dist<3,float, part_prop > vd(k,box,bc,ghost,BIND_DEC_TO_GHOST);
size_t start = vd.init_size_accum(k);
vector_dist<3,float, part_prop > vd(k,box,bc,ghost);
auto it = vd.getIterator();
......@@ -377,15 +358,13 @@ BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration )
{
auto key = it.get();
vd.getPosWrite(key)[0] = ud(eg);
vd.getPosWrite(key)[1] = ud(eg);
vd.getPosWrite(key)[2] = ud(eg);
vd.getPos(key)[0] = ud(eg);
vd.getPos(key)[1] = ud(eg);
vd.getPos(key)[2] = ud(eg);
// Fill some properties randomly
vd.getPropWrite<0>(key) = 0;
vd.getPropWrite<1>(key) = 0;
vd.getPropWrite<2>(key) = key.getKey() + start;
vd.getProp<0>(key) = 0.0;
++it;
}
......@@ -393,228 +372,110 @@ BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration )
vd.map();
// sync the ghost
vd.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
vd.ghost_get<0>();
if (distance < r_cut )
{
vd.getPropWrite<0>(p)++;
vd.getPropWrite<3>(p).add();
vd.getPropWrite<3>(p).last().xq = xq;
vd.getPropWrite<3>(p).last().id = vd.getPropWrite<2>(q);
}
auto NN = vd.getCellListSym(r_cut);
++Np;
}
auto cell1 = NN.getCellBox();
++p_it;
}
vd.getDecomposition().decompose();
vd.map();
// We now divide the particles on 4 phases
vd.updateCellListSym(NN);
openfpm::vector<vector_dist<3,float, part_prop >> phases;
phases.add( vector_dist<3,float, part_prop >(vd.getDecomposition(),0));
phases.add( vector_dist<3,float, part_prop >(phases.get(0).getDecomposition(),0));
phases.add( vector_dist<3,float, part_prop >(phases.get(0).getDecomposition(),0));
phases.add( vector_dist<3,float, part_prop >(phases.get(0).getDecomposition(),0));
auto cell2 = NN.getCellBox();
auto it2 = vd.getDomainIterator();
BOOST_REQUIRE_EQUAL(cell1.getHigh(0),cell2.getHigh(0));
BOOST_REQUIRE_EQUAL(cell1.getHigh(1),cell2.getHigh(1));
BOOST_REQUIRE_EQUAL(cell1.getHigh(2),cell2.getHigh(2));
}
while (it2.isNext())
{
auto p = it2.get();
BOOST_AUTO_TEST_CASE( vector_dist_particle_getCellListSym_with_div )
{
Vcluster & v_cl = create_vcluster();
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];
if (v_cl.getProcessingUnits() > 12)
return;
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];
// set the seed
// create the random generator engine
std::srand(v_cl.getProcessUnitID());
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(0.0f, 1.0f);
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];
long int k = 750 * v_cl.getProcessingUnits();
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];
print_test_v("Testing 3D particle getCellListSym with div =",k);
BOOST_TEST_CHECKPOINT( "Testing 3D particle getCellListSym with div = " << k );
phases.get(3).template getLastProp<2>() = vd.template getProp<2>(p);
}
Box<3,float> box({0.0,0.0,0.0},{0.1,0.39,0.39});
++it2;
}
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
// now we get all the Cell-lists
float r_cut = 0.1;
for (size_t i = 0 ; i < phases.size() ; i++)
{
phases.get(i).ghost_get<0,2>();
}
// ghost
Ghost<3,float> ghost(r_cut);
openfpm::vector<CellList<3, float, Mem_fast<>, shift<3, float> >> NN_ptr;
typedef aggregate<float> part_prop;
for (size_t i = 0 ; i < phases.size() ; i++)
{
NN_ptr.add(phases.get(i).getCellListSym(r_cut));
}
// Distributed vector
vector_dist<3,float, part_prop > vd(k,box,bc,ghost);
// We now interact all the phases
auto it = vd.getIterator();
for (size_t i = 0 ; i < phases.size() ; i++)
while (it.isNext())
{
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).getPropWrite<1>(p)++;
phases.get(j).getPropWrite<1>(q)++;
auto key = it.get();
phases.get(i).getPropWrite<4>(p).add();
phases.get(j).getPropWrite<4>(q).add();
vd.getPos(key)[0] = ud(eg);
vd.getPos(key)[1] = ud(eg);
vd.getPos(key)[2] = ud(eg);
phases.get(i).getPropWrite<4>(p).last().xq = xq;
phases.get(j).getPropWrite<4>(q).last().xq = xp;
phases.get(i).getPropWrite<4>(p).last().id = phases.get(j).getProp<2>(q);
phases.get(j).getPropWrite<4>(q).last().id = phases.get(i).getProp<2>(p);
}
// Fill some properties randomly
++Np;
}
vd.getProp<0>(key) = 0.0;
++p_it2;
}
}
}
for (size_t i = 0 ; i < phases.size() ; i++)
{
phases.get(i).ghost_put<add_,1>();
phases.get(i).ghost_put<merge_,4>();
++it;
}
auto p_it3 = vd.getDomainIterator();
bool ret = true;
while (p_it3.isNext())
{
auto p = p_it3.get();
vd.map();
int ph;
// sync the ghost
vd.ghost_get<0>();
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;}
auto NN1 = vd.getCellListSym(r_cut);
size_t pah = p.getKey()/4;
ret &= phases.get(ph).getPropRead<1>(pah) == vd.getPropRead<0>(p);
size_t div_wp[3] = {NN1.getDivWP()[0],NN1.getDivWP()[1],NN1.getDivWP()[2]};
size_t pad[3] = {NN1.getPadding()[0],NN1.getPadding()[1],NN1.getPadding()[2]};
vd.getPropRead<3>(p).sort();
phases.get(ph).getPropRead<4>(pah).sort();
auto NN2 = vd.getCellListSym(div_wp,pad);
ret &= vd.getPropRead<3>(p).size() == phases.get(ph).getPropRead<4>(pah).size();
// Check that the two Cell list are identical
for (size_t i = 0 ; i < vd.getPropRead<3>(p).size() ; i++)
ret &= vd.getPropRead<3>(p).get(i).id == phases.get(ph).getPropRead<4>(pah).get(i).id;
// grid info
size_t div[3] = {NN1.getInternalGrid().getSize()[0],
NN1.getInternalGrid().getSize()[1],
NN1.getInternalGrid().getSize()[2]};
if (ret == false)
{
std::cout << "Error on particle: " << vd.getPropRead<2>(p) << " " << v_cl.rank() << std::endl;
grid_sm<3,void> g_info(div);
std::cout << vd.getPropRead<3>(p).size() << " " << phases.get(ph).getPropRead<4>(pah).size() << " " << v_cl.rank() << std::endl;
bool match = true;
for (size_t i = 0 ; i < vd.getPropRead<3>(p).size() ; i++)
std::cout << vd.getPropRead<3>(p).get(i).id << " " << phases.get(ph).getPropRead<4>(pah).get(i).id << " " << v_cl.rank() << std::endl;
// Create a grid iterator
grid_key_dx_iterator<3> g_it(g_info);
std::cout << phases.get(ph).getPropRead<1>(pah) << " A " << vd.getPropRead<0>(p) << std::endl;
while (g_it.isNext())
{
size_t cell = g_info.LinId(g_it.get());
size_t n_ele1 = NN1.getNelements(cell);
size_t n_ele2 = NN2.getNelements(cell);
break;
}
match &= n_ele1 == n_ele2;
++p_it3;
++g_it;
}
BOOST_REQUIRE_EQUAL(ret,true);
BOOST_REQUIRE_EQUAL(match,true);
}
......@@ -1854,3 +1854,303 @@ BOOST_AUTO_TEST_CASE( vector_dist_cell_list_multi_type )
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_MP_iteration )
{
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;
print_test_v("Testing 3D periodic vector symmetric cell-list k=",k);
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);
// 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);
}
};
typedef aggregate<size_t,size_t,size_t,openfpm::vector<point_and_gid>,openfpm::vector<point_and_gid>> part_prop;
// Distributed vector
vector_dist<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.getPropWrite<0>(key) = 0;
vd.getPropWrite<1>(key) = 0;
vd.getPropWrite<2>(key) = key.getKey() + start;
++it;
}
vd.map();
// sync the ghost
vd.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.getPropWrite<0>(p)++;
vd.getPropWrite<3>(p).add();
vd.getPropWrite<3>(p).last().xq = xq;
vd.getPropWrite<3>(p).last().id = vd.getPropWrite<2>(q);