Commit 95524c6a authored by incardon's avatar incardon

Testing gitlab

parent c52f28ba
Pipeline #1147 failed with stages
in 28 minutes and 11 seconds
This diff is collapsed.
......@@ -246,8 +246,8 @@ public:
for (size_t i = 0 ; i < dim ; i++)
this->bc[i] = dec.bc[i];
(static_cast<nn_prcs<dim,T> &>(*this)).create(this->box_nn_processor, this->sub_domains);
(static_cast<nn_prcs<dim,T> &>(*this)).applyBC(ext_domain,g,this->bc);
(static_cast<nn_prcs<dim,T,layout_base,Memory> &>(*this)).create(this->box_nn_processor, this->sub_domains);
(static_cast<nn_prcs<dim,T, layout_base,Memory> &>(*this)).applyBC(ext_domain,g,this->bc);
this->Initialize_geo_cell_lists();
this->calculateGhostBoxes();
......
......@@ -100,7 +100,7 @@ class ie_ghost
* for the processor p_id
*
*/
inline size_t link_ebx_ibx(const nn_prcs<dim,T> & nn_p, size_t p_id, size_t i)
inline size_t link_ebx_ibx(const nn_prcs<dim,T,layout_base,Memory> & nn_p, size_t p_id, size_t i)
{
// Search for the correct id
size_t k = 0;
......@@ -224,9 +224,9 @@ protected:
*/
void create_box_nn_processor_ext(Vcluster<> & v_cl,
Ghost<dim,T> & ghost,
openfpm::vector<SpaceBox<dim,T>> & sub_domains,
openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains,
const openfpm::vector<openfpm::vector<long unsigned int> > & box_nn_processor,
const nn_prcs<dim,T> & nn_p)
const nn_prcs<dim,T,layout_base,Memory> & nn_p)
{
box_nn_processor_int.resize(sub_domains.size());
proc_int_box.resize(nn_p.getNNProcessors());
......@@ -326,9 +326,9 @@ protected:
*/
void create_box_nn_processor_int(Vcluster<> & v_cl,
Ghost<dim,T> & ghost,
openfpm::vector<SpaceBox<dim,T>> & sub_domains,
openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains,
const openfpm::vector<openfpm::vector<long unsigned int> > & box_nn_processor,
const nn_prcs<dim,T> & nn_p)
const nn_prcs<dim,T,layout_base,Memory> & nn_p)
{
box_nn_processor_int.resize(sub_domains.size());
proc_int_box.resize(nn_p.getNNProcessors());
......
......@@ -23,7 +23,7 @@
* \see CartDecomposition
*
*/
template<unsigned int dim, typename T>
template<unsigned int dim, typename T, template <typename> class layout_base, typename Memory>
class ie_loc_ghost
{
//! It contain the calculated local ghost boxes
......@@ -40,7 +40,7 @@ class ie_loc_ghost
*
*/
void create_loc_ghost_ebox(Ghost<dim,T> & ghost,
openfpm::vector<SpaceBox<dim,T>> & sub_domains,
openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains,
openfpm::vector<Box_loc_sub<dim,T>> & sub_domains_prc)
{
comb<dim> zero;
......@@ -101,7 +101,7 @@ class ie_loc_ghost
*
*/
void create_loc_ghost_ibox(Ghost<dim,T> & ghost,
openfpm::vector<SpaceBox<dim,T>> & sub_domains,
openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains,
openfpm::vector<Box_loc_sub<dim,T>> & sub_domains_prc)
{
comb<dim> zero;
......@@ -163,7 +163,7 @@ class ie_loc_ghost
for (size_t j = 0 ; j < cmbs.size() ; j++)
{
if (nn_prcs<dim,T>::check_valid(cmbs[j],bc) == false)
if (nn_prcs<dim,T,layout_base,Memory>::check_valid(cmbs[j],bc) == false)
continue;
Box<dim,T> bp;
......@@ -249,7 +249,7 @@ public:
* \param bc Boundary conditions
*
*/
void create(openfpm::vector<SpaceBox<dim,T>> & sub_domains, Box<dim,T> & domain , Ghost<dim,T> & ghost , const size_t (&bc)[dim] )
void create(openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains, Box<dim,T> & domain , Ghost<dim,T> & ghost , const size_t (&bc)[dim] )
{
// It will store local sub-domains + borders
openfpm::vector<Box_loc_sub<dim,T>> sub_domains_prc;
......@@ -275,13 +275,13 @@ public:
ie_loc_ghost() {};
//! Constructor from another ie_loc_ghost
ie_loc_ghost(const ie_loc_ghost<dim,T> & ilg)
ie_loc_ghost(const ie_loc_ghost<dim,T,layout_base,Memory> & ilg)
{
this->operator=(ilg);
};
//! Constructor from temporal ie_loc_ghost
ie_loc_ghost(ie_loc_ghost<dim,T> && ilg)
ie_loc_ghost(ie_loc_ghost<dim,T,layout_base,Memory> && ilg)
{
this->operator=(ilg);
}
......@@ -293,7 +293,7 @@ public:
* \return itself
*
*/
ie_loc_ghost<dim,T> & operator=(const ie_loc_ghost<dim,T> & ilg)
ie_loc_ghost<dim,T,layout_base,Memory> & operator=(const ie_loc_ghost<dim,T,layout_base,Memory> & ilg)
{
loc_ghost_box = ilg.loc_ghost_box;
return *this;
......@@ -306,12 +306,50 @@ public:
* \return itself
*
*/
ie_loc_ghost<dim,T> & operator=(ie_loc_ghost<dim,T> && ilg)
ie_loc_ghost<dim,T,layout_base,Memory> & operator=(ie_loc_ghost<dim,T,layout_base,Memory> && ilg)
{
loc_ghost_box.swap(ilg.loc_ghost_box);
return *this;
}
/*! \brief copy the ie_loc_ghost
*
* \param ilg object to copy
*
* \return itself
*
*/
template<template <typename> class layout_base2, typename Memory2>
ie_loc_ghost<dim,T,layout_base,Memory> & operator=(const ie_loc_ghost<dim,T,layout_base2,Memory2> & ilg)
{
loc_ghost_box = ilg.private_get_loc_ghost_box();
return *this;
}
/*! \brief copy the ie_loc_ghost
*
* \param ilg object to copy
*
* \return itself
*
*/
template<template <typename> class layout_base2, typename Memory2>
ie_loc_ghost<dim,T,layout_base,Memory> & operator=(ie_loc_ghost<dim,T,layout_base2,Memory2> && ilg)
{
loc_ghost_box.swap(ilg.private_get_loc_ghost_box());
return *this;
}
/*! \brief Get the internal loc_ghost_box
*
* \return the internal loc_ghost_box
*
*/
inline openfpm::vector<lBox_dom<dim,T>> & private_get_loc_ghost_box()
{
return loc_ghost_box;
}
/*! \brief Get the number of local sub-domains
*
* \return the number of local sub-domains
......@@ -590,7 +628,7 @@ public:
* \return true if they match
*
*/
bool is_equal(ie_loc_ghost<dim,T> & ilg)
bool is_equal(ie_loc_ghost<dim,T,layout_base,Memory> & ilg)
{
if (ilg.loc_ghost_box.size() != loc_ghost_box.size())
return false;
......@@ -637,7 +675,7 @@ public:
* ghost part
*
*/
bool is_equal_ng(ie_loc_ghost<dim,T> & ilg)
bool is_equal_ng(ie_loc_ghost<dim,T,layout_base,Memory> & ilg)
{
return true;
}
......
......@@ -19,7 +19,7 @@
* \see CartDecomposition
*
*/
template<unsigned int dim, typename T>
template<unsigned int dim, typename T, template <typename> class layout_base, typename Memory>
class nn_prcs
{
//! Virtual cluster
......@@ -139,7 +139,7 @@ class nn_prcs
static void * message_alloc(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, size_t tag, void * ptr)
{
// cast the pointer
nn_prcs<dim,T> * cd = static_cast< nn_prcs<dim,T> *>(ptr);
nn_prcs<dim,T,layout_base,Memory> * cd = static_cast< nn_prcs<dim,T,layout_base,Memory> *>(ptr);
cd->nn_processor_subdomains[i].bx.resize(msg_i / sizeof(::Box<dim,T>) );
......@@ -276,14 +276,14 @@ public:
{}
//! Constructor from another nn_prcs
nn_prcs(const nn_prcs<dim,T> & ilg)
nn_prcs(const nn_prcs<dim,T,layout_base,Memory> & ilg)
:v_cl(ilg.v_cl),recv_cnt(0),aBC(false)
{
this->operator=(ilg);
};
//! Constructor from temporal ie_loc_ghost
nn_prcs(nn_prcs<dim,T> && ilg)
nn_prcs(nn_prcs<dim,T,layout_base,Memory> && ilg)
:v_cl(ilg.v_cl),recv_cnt(0),aBC(false)
{
this->operator=(ilg);
......@@ -321,7 +321,7 @@ public:
* \return itself
*
*/
nn_prcs<dim,T> & operator=(const nn_prcs<dim,T> & nnp)
nn_prcs<dim,T,layout_base,Memory> & operator=(const nn_prcs<dim,T,layout_base,Memory> & nnp)
{
nn_processors = nnp.nn_processors;
nn_processor_subdomains = nnp.nn_processor_subdomains;
......@@ -338,7 +338,7 @@ public:
* \return itself
*
*/
nn_prcs<dim,T> & operator=(nn_prcs<dim,T> && nnp)
nn_prcs<dim,T,layout_base,Memory> & operator=(nn_prcs<dim,T,layout_base,Memory> && nnp)
{
nn_processors.swap(nnp.nn_processors);
nn_processor_subdomains.swap(nnp.nn_processor_subdomains);
......@@ -348,13 +348,90 @@ public:
return *this;
}
/*! \brief Copy the object
*
* \param nnp object to copy
*
* \return itself
*
*/
template<typename Memory2, template <typename> class layout_base2>
nn_prcs<dim,T,layout_base,Memory> & operator=(const nn_prcs<dim,T,layout_base2,Memory2> & nnp)
{
nn_processors = nnp.private_get_nn_processors();
nn_processor_subdomains = nnp.private_get_nn_processor_subdomains();
proc_adj_box = nnp.private_get_proc_adj_box();
boxes = nnp.private_get_boxes();
return *this;
}
/*! \brief Return the internal nn_processor struct
*
* \return the internal nn_processor struct
*
*/
openfpm::vector<size_t> & private_get_nn_processors()
{
return nn_processors;
}
/*! \brief Return the internal nn_processor_subdomains
*
* \return the internal nn_processor_subdomains
*
*/
std::unordered_map<size_t, N_box<dim,T>> & private_get_nn_processor_subdomains()
{
return nn_processor_subdomains;
}
/*! \brief Return the internal proc_adj_box
*
* \return the internal proc_adj_box
*
*/
openfpm::vector<openfpm::vector<size_t>> & private_get_proc_adj_box()
{
return proc_adj_box;
}
/*! \brief Return the internal boxes structure
*
* \return the internal boxes structure
*
*/
openfpm::vector< openfpm::vector< ::SpaceBox<dim,T>> > & private_get_boxes()
{
return boxes;
}
/*! \brief Copy the object
*
* \param nnp object to copy
*
* \return itself
*
*/
template<typename Memory2, template <typename> class layout_base2>
nn_prcs<dim,T,layout_base,Memory> & operator=(nn_prcs<dim,T,layout_base2,Memory2> && nnp)
{
nn_processors.swap(nnp.private_get_nn_processors());
nn_processor_subdomains.swap(nnp.private_get_nn_processor_subdomains());
proc_adj_box.swap(nnp.private_get_proc_adj_box());
boxes = nnp.private_get_boxes();
return *this;
}
/*! \brief Create the list of adjacent processors and the list of adjacent sub-domains
*
* \param box_nn_processor list of adjacent processors for each sub-domain
* \param sub_domains list of local sub-domains
*
*/
void create(const openfpm::vector<openfpm::vector<long unsigned int> > & box_nn_processor, const openfpm::vector<SpaceBox<dim,T>> & sub_domains)
void create(const openfpm::vector<openfpm::vector<long unsigned int> > & box_nn_processor,
const openfpm::vector<SpaceBox<dim,T>,Memory,typename layout_base<SpaceBox<dim, T>>::type,layout_base> & sub_domains)
{
// produce the list of the adjacent processor (nn_processors) list
for (size_t i = 0 ; i < box_nn_processor.size() ; i++)
......@@ -412,7 +489,7 @@ public:
nn_processor_subdomains.reserve(nn_processors.size());
// Get the sub-domains of the near processors
v_cl.sendrecvMultipleMessagesNBX(nn_processors,boxes,nn_prcs<dim,T>::message_alloc, this ,NEED_ALL_SIZE);
v_cl.sendrecvMultipleMessagesNBX(nn_processors,boxes,nn_prcs<dim,T,layout_base,Memory>::message_alloc, this ,NEED_ALL_SIZE);
// Add to all the received sub-domains the information that they live in the central sector
for ( auto it = nn_processor_subdomains.begin(); it != nn_processor_subdomains.end(); ++it )
......@@ -645,7 +722,7 @@ public:
* \return true if they are equal
*
*/
bool is_equal(nn_prcs<dim,T> & np)
bool is_equal(nn_prcs<dim,T,layout_base,Memory> & np)
{
if (np.getNNProcessors() != getNNProcessors())
return false;
......
......@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
create_decomposition2x2(box_nn_processor,sub_domains);
nn_prcs<2,float> nnp(v_cl);
nn_prcs<2,float,memory_traits_lin,HeapMemory> nnp(v_cl);
nnp.create(box_nn_processor, sub_domains);
BOOST_REQUIRE_EQUAL(nnp.getNNProcessors(),3ul);
......@@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
//////////////
nn_prcs<2,float> nnp(v_cl);
nn_prcs<2,float,memory_traits_lin,HeapMemory> nnp(v_cl);
nnp.create(box_nn_processor, sub_domains);
// check that nn_processor contain the correct boxes
......@@ -389,12 +389,6 @@ BOOST_AUTO_TEST_CASE( nn_processor_box_periodic_test)
bv.add(Box<2,float>({0.0,-0.5},{0.5,0.0}));
bv.add(Box<2,float>({1.0,-0.5},{1.5,0.0}));
/* for (size_t i = 0 ; i < nnp.getNearSubdomains(2).size() ; i++)
{
Box<2,float> b = nnp.getNearSubdomains(2).get(i);
std::cout << "BOX: " << b.toString() << std::endl;
}*/
ret = nnp.getNearSubdomains(2) == bv;
BOOST_REQUIRE_EQUAL(ret,true);
}
......
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "VCluster/VCluster.hpp"
......@@ -1054,6 +1053,186 @@ void vector_dist_dlb_on_cuda_impl(size_t k,double r_cut)
}
}
template<typename CellList_type>
void vector_dist_dlb_on_cuda_impl_async(size_t k,double r_cut)
{
typedef vector_dist_gpu<3,double,aggregate<double,double[3],double[3]>> vector_type;
Vcluster<> & v_cl = create_vcluster();
if (v_cl.getProcessingUnits() > 8)
return;
Box<3,double> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
Ghost<3,double> g(0.1);
size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
vector_type vd(0,domain,bc,g,DEC_GRAN(2048));
// Only processor 0 initialy add particles on a corner of a domain
if (v_cl.getProcessUnitID() == 0)
{
for(size_t i = 0 ; i < k ; i++)
{
vd.add();
vd.getLastPos()[0] = ((double)rand())/RAND_MAX * 0.3;
vd.getLastPos()[1] = ((double)rand())/RAND_MAX * 0.3;
vd.getLastPos()[2] = ((double)rand())/RAND_MAX * 0.3;
}
}
// Move to GPU
vd.hostToDevicePos();
vd.template hostToDeviceProp<0>();
vd.map(RUN_ON_DEVICE);
vd.template Ighost_get<>(RUN_ON_DEVICE);
vd.template ghost_wait<>(RUN_ON_DEVICE);
// now move to CPU
vd.deviceToHostPos();
vd.template deviceToHostProp<0>();
// Get the neighborhood of each particles
auto VV = vd.getVerlet(r_cut);
// store the number of neighborhood for each particles
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto p = it.get();
vd.template getProp<0>(p) = VV.getNNPart(p.getKey());
++it;
}
// Move to GPU
vd.template hostToDeviceProp<0>();
ModelSquare md;
md.factor = 10;
vd.addComputationCosts(md);
vd.getDecomposition().decompose();
vd.map(RUN_ON_DEVICE);
vd.deviceToHostPos();
// Move info to CPU for addComputationcosts
vd.addComputationCosts(md);
openfpm::vector<size_t> loads;
size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
v_cl.allGather(load,loads);
v_cl.execute();
for (size_t i = 0 ; i < loads.size() ; i++)
{
double load_f = load;
double load_fc = loads.get(i);
BOOST_REQUIRE_CLOSE(load_f,load_fc,7.0);
}
BOOST_REQUIRE(vd.size_local() != 0);
Point<3,double> v({1.0,1.0,1.0});
for (size_t i = 0 ; i < 25 ; i++)
{
// move particles to CPU and move the particles by 0.1
vd.deviceToHostPos();
auto it = vd.getDomainIterator();
while (it.isNext())
{
auto p = it.get();
vd.getPos(p)[0] += v.get(0) * 0.09;
vd.getPos(p)[1] += v.get(1) * 0.09;
vd.getPos(p)[2] += v.get(2) * 0.09;
++it;
}
//Back to GPU
vd.hostToDevicePos();
vd.map(RUN_ON_DEVICE);
vd.template Ighost_get<0>(RUN_ON_DEVICE);
vd.template ghost_wait<0>(RUN_ON_DEVICE);
vd.deviceToHostPos();
vd.template deviceToHostProp<0,1,2>();
// Check calc forces
auto NN_gpu = vd.template getCellListGPU<CellList_type>(r_cut);
auto NN_cpu = vd.getCellList(r_cut);
check_cell_list_cpu_and_gpu(vd,NN_gpu,NN_cpu);
auto VV2 = vd.getVerlet(r_cut);
auto it2 = vd.getDomainIterator();
bool match = true;
while (it2.isNext())
{
auto p = it2.get();
match &= vd.template getProp<0>(p) == VV2.getNNPart(p.getKey());
++it2;
}
BOOST_REQUIRE_EQUAL(match,true);
ModelSquare md;
vd.addComputationCosts(md);
vd.getDecomposition().redecompose(200);
vd.map(RUN_ON_DEVICE);
BOOST_REQUIRE(vd.size_local() != 0);
// vd.template ghost_get<0>(RUN_ON_DEVICE);
if (i == 9)
{
int debug = 0;
debug++;
}
// vd.template ghost_get<0>(RUN_ON_DEVICE);
vd.template Ighost_get<0>(RUN_ON_DEVICE);
vd.template ghost_wait<0>(RUN_ON_DEVICE);
vd.deviceToHostPos();
vd.template deviceToHostProp<0>();
vd.addComputationCosts(md);
openfpm::vector<size_t> loads;
size_t load = vd.getDecomposition().getDistribution().getProcessorLoad();
v_cl.allGather(load,loads);
v_cl.execute();
for (size_t i = 0 ; i < loads.size() ; i++)
{
double load_f = load;
double load_fc = loads.get(i);
BOOST_REQUIRE_CLOSE(load_f,load_fc,10.0);
}
}
}
BOOST_AUTO_TEST_CASE(vector_dist_dlb_on_cuda_async)
{
vector_dist_dlb_on_cuda_impl_async<CellList_gpu<3,double,CudaMemory,shift_only<3,double>,unsigned int,int,false>>(50000,0.01);
}
BOOST_AUTO_TEST_CASE(vector_dist_dlb_on_cuda)
{
vector_dist_dlb_on_cuda_impl<CellList_gpu<3,double,CudaMemory,shift_only<3,double>,unsigned int,int,false>>(50000,0.01);
......
......@@ -1307,9 +1307,7 @@ public:
// This function assume equal spacing in all directions
// but in the worst case we take the maximum
St r_cut = 0;
for (size_t i = 0 ; i < dim ; i++)
{r_cut = std::max(r_cut,cell_list.getCellBox().getHigh(i));}
St r_cut = cell_list.getCellBox().getRcut();
// Here we have to check that the Cell-list has been constructed
// from the same decomposition
......@@ -2243,6 +2241,26 @@ public:
#endif
this->template ghost_get_<GHOST_ASYNC,prp...>(v_pos,v_prp,g_m,opt);
}
/*! \brief It synchronize the properties and position of the ghost particles
*
* \tparam prp list of properties to get synchronize
*
* \param opt options WITH_POSITION, it send also the positional information of the particles
*
*/
template<int ... prp> inline void ghost_wait(size_t opt = WITH_POSITION)
{
#ifdef SE_CLASS1
if (getDecomposition().getProcessorBounds().isValid() == false && size_local() != 0)
{
std::cerr << __FILE__ << ":" << __LINE__ << " Error the processor " << v_cl.getProcessUnitID() << " has particles, but is supposed to be unloaded" << std::endl;
ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
}
#endif
this->template ghost_wait_<prp...>(v_pos,v_prp,g_m,opt);
#ifdef SE_CLASS3
......@@ -2252,7 +2270,6 @@ public:
#endif
}
/*! \brief It synchronize the properties and position of the ghost particles
*
* \tparam op which kind of operation to apply
......
This diff is collapsed.
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