Commit 07505978 authored by incardon's avatar incardon
Browse files

Add build script for jenkins

parent b4d4c120
#! /bin/bash
sh ./configure
make
......@@ -2,7 +2,7 @@
LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
bin_PROGRAMS = mem_map
mem_map_SOURCES = main.cpp Memleak_check.cpp ../../OpenFPM_devices/src/memory/CudaMemory.cu ../../OpenFPM_devices/src/memory/HeapMemory.cpp
mem_map_SOURCES = main.cpp Memleak_check.cpp ../../OpenFPM_devices/src/memory/CudaMemory.cu ../../OpenFPM_devices/src/memory/HeapMemory.cpp ../../OpenFPM_devices/src/memory/PtrMemory.cpp
mem_map_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH)
mem_map_CFLAGS = $(CUDA_CFLAGS)
mem_map_LDADD = $(LINKLIBS) -L/usr/lib64/nvidia-bumblebee/ -lboost_unit_test_framework
......
......@@ -13,7 +13,7 @@ size_t delete_data;
std::map<byte_ptr, size_t> active_ptr;
// Running process id
size_t process_v_cl;
long int process_v_cl;
// Process to print
long int process_to_print = 0;
......
......@@ -14,7 +14,7 @@ extern size_t delete_data;
extern std::map<byte_ptr,size_t> active_ptr;
extern size_t process_v_cl;
extern long int process_v_cl;
extern long int process_to_print;
/*! \brief Check and remove the active pointer
......
......@@ -33,7 +33,7 @@ class CellList
};
#include "CellListFast.hpp"
//#include "CellListBal.hpp"
//#include "CellListMem.hpp"
#include "CellListBal.hpp"
#include "CellListMem.hpp"
#endif /* CELLLIST_HPP_ */
......@@ -29,8 +29,30 @@
*
*/
template<unsigned int dim, typename T, typename base>
class CellList<dim,T,BALANCED,base>
class CellList<dim,T,BALANCED,base>: public CellDecomposer_sm<dim,T>
{
// The array contain the neighborhood of the cell-id in case of asymmetric interaction
//
// * * *
// * x *
// * * *
long int NNc_full[openfpm::math::pow(3,dim)];
// The array contain the neighborhood of the cell-id in case of symmetric interaction
//
// * * *
// x *
//
long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
// The array contain the neighborhood of the cell-id in case of symmetric interaction (Optimized)
//
// * *
// x *
//
long int NNc_cr[openfpm::math::pow(2,dim)];
// each cell has a pointer to a dynamic structure
// that store the elements in the cell
openfpm::vector<base *> cl_base;
......@@ -46,6 +68,9 @@ class CellList<dim,T,BALANCED,base>
public:
// Object type that the structure store
typedef T value_type;
/*! \brief Cell list
*
* \param box Domain where this cell list is living
......@@ -53,54 +78,55 @@ public:
* \param div grid size on each dimension
*
*/
CellList(SpaceBox<dim,T> & box, size_t div[dim], Point<dim,T> org)
CellList(SpaceBox<dim,T> & box, size_t (&div)[dim], Point<dim,T> & org)
:box(box),gr_cell(div)
{
}
/*
* ! \brief Add an element in the cell list
/*! \brief Add an element in the cell list
*
* \param pos array that contain the
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
void addElement(T (& pos)[dim], typename base::value_type ele)
void add(const T (& pos)[dim], typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = getCell(pos);
// Get the number of element the cell is storing
size_t nl = getNelements(cell_id);
size_t cell_id = this->getCell(pos);
// add a new element
cl_base.add(ele);
cl_base.get(cell_id).add(ele);
}
/*! \brief Get the cell-id
/*! \brief Add an element in the cell list
*
* Convert the point coordinates into the cell id
*
* \param pos Point position
*
* \return the cell-id
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
size_t getCell(T (& pos)[dim])
void add(const Point<dim,T> & pos, typename base::value_type ele)
{
typedef SpaceBox<dim,T> sb;
// calculate the Cell id
size_t cell_id = 0;
size_t cell_id = this->getCell(pos);
for (size_t s = 0 ; s < dim ; s++)
{
cell_id += box_unit.template get<sb::p2>()[s] * gr_cell.size(s);
}
// add a new element
cl_base.get(cell_id)->add(ele);
}
return cell_id;
/*! \brief remove an element from the cell
*
* \param cell cell id
* \param ele element id
*
*/
void remove(size_t cell, size_t ele)
{
cl_base.get(cell)->remove(ele);
}
/*! \brief Return the number of element in the cell
......@@ -121,10 +147,36 @@ public:
* \param ele element id
*
*/
typename base::element getElement(size_t cell, size_t ele)
auto get(size_t cell, size_t ele) -> decltype(cl_base.get(cell)->get(ele))
{
return cl_base.get(cell)->get(ele);
}
/*! \brief Get the Nearest Neighborhood iterator
*
* \param cell cell id
*
*/
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,BALANCED,base>,FULL,impl> getNNIterator(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,BALANCED,base>,FULL,impl> cln(cell,NNc_full,*this);
return cln;
}
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,BALANCED,base>,SYM,impl> getNNIteratorSym(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,BALANCED,base>,SYM,impl> cln(cell,NNc_sym,*this);
return cln;
}
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,BALANCED,base>,CRS,impl> getNNIteratorCross(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,BALANCED,base>,CRS,impl> cln(cell,NNc_cr,*this);
return cln;
}
};
......
......@@ -30,8 +30,30 @@
*
*/
template<unsigned int dim, typename T, typename base>
class CellList<dim,T,MEMORY,base>
class CellList<dim,T,MEMORY,base> : public CellDecomposer_sm<dim,T>
{
// The array contain the neighborhood of the cell-id in case of asymmetric interaction
//
// * * *
// * x *
// * * *
long int NNc_full[openfpm::math::pow(3,dim)];
// The array contain the neighborhood of the cell-id in case of symmetric interaction
//
// * * *
// x *
//
long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
// The array contain the neighborhood of the cell-id in case of symmetric interaction (Optimized)
//
// * *
// x *
//
long int NNc_cr[openfpm::math::pow(2,dim)];
// each cell has a pointer to a dynamic structure
// that store the elements in the cell
std::unordered_map<size_t,base *> cl_base;
......@@ -47,6 +69,9 @@ class CellList<dim,T,MEMORY,base>
public:
// Object type that the structure store
typedef T value_type;
/*! \brief Cell list
*
* \param box Domain where this cell list is living
......@@ -54,7 +79,7 @@ public:
* \param div grid size on each dimension
*
*/
CellList(SpaceBox<dim,T> & box, size_t div[dim], Point<dim,T> org)
CellList(SpaceBox<dim,T> & box, size_t (&div)[dim], Point<dim,T> & org)
:box(box),gr_cell(div)
{
}
......@@ -65,7 +90,7 @@ public:
* \param ele element to store
*
*/
void addElement(T (& pos)[dim], typename base::value_type ele)
void add(T (& pos)[dim], typename base::value_type ele)
{
// calculate the Cell id
......@@ -73,30 +98,24 @@ public:
// Get the number of element the cell is storing
cl_base[cell_id].add(ele);
cl_base[cell_id]->add(ele);
}
/*! \brief Get the cell-id
*
* Convert the point coordinates into the cell id
*
* \param pos Point position
/*! \brief Add an element in the cell list
*
* \return the cell-id
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
size_t getCell(T (& pos)[dim])
void add(const Point<dim,T> & pos, typename base::value_type ele)
{
typedef SpaceBox<dim,T> sb;
// calculate the Cell id
size_t cell_id = 0;
size_t cell_id = this->getCell(pos);
for (size_t s = 0 ; s < dim ; s++)
{
cell_id += box_unit.template get<sb::p2>()[s] * gr_cell.size(s);
}
// add a new element
return cell_id;
cl_base[cell_id]->add(ele);
}
/*! \brief Return the number of element in the cell
......@@ -108,7 +127,18 @@ public:
*/
size_t getNelements(size_t cell_id)
{
return cl_base.get(cell_id)->size();
return cl_base[cell_id]->size();
}
/*! \brief remove an element from the cell
*
* \param cell cell id
* \param ele element id
*
*/
void remove(size_t cell, size_t ele)
{
cl_base[cell]->remove(ele);
}
/*! \brief Get an element in the cell
......@@ -117,9 +147,35 @@ public:
* \param ele element id
*
*/
typename base::value_type getElement(size_t cell, size_t ele)
auto get(size_t cell, size_t ele) -> decltype(cl_base[cell]->get(ele))
{
return cl_base.get(cell)->get(ele);
return cl_base[cell]->get(ele);
}
/*! \brief Get the Nearest Neighborhood iterator
*
* \param cell cell id
*
*/
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,MEMORY,base>,FULL,impl> getNNIterator(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,MEMORY,base>,FULL,impl> cln(cell,NNc_full,*this);
return cln;
}
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,MEMORY,base>,SYM,impl> getNNIteratorSym(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,MEMORY,base>,SYM,impl> cln(cell,NNc_sym,*this);
return cln;
}
template<unsigned int impl> CellNNIterator<dim,CellList<dim,T,BALANCED,base>,CRS,impl> getNNIteratorCross(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,MEMORY,base>,CRS,impl> cln(cell,NNc_cr,*this);
return cln;
}
};
......
......@@ -171,7 +171,9 @@ BOOST_AUTO_TEST_CASE( CellList_use)
{
std::cout << "Test cell list" << "\n";
Test_cell_s<3,double,CellList<3,double>>();
Test_cell_s<3,double,CellList<3,double,FAST>>();
// Test_cell_s<3,double,CellList<3,double,BALANCED>>();
// Test_cell_s<3,double,CellList<3,double,MEMORY>>();
std::cout << "End cell list" << "\n";
......
......@@ -443,6 +443,29 @@ namespace openfpm
}
/*! \brief Remove one entry from the vector
*
* \param key element to remove
*
*/
void remove(size_t key)
{
size_t d_k = key;
size_t s_k = key + 1;
// keys
while (s_k < size())
{
set(d_k,get(s_k));
d_k++;
s_k++;
}
// re-calculate the vector size
v_size--;
}
/*! \brief Remove several entries from the vector
*
* \param keys objects id to remove
* \param start key starting point
......
......@@ -89,6 +89,16 @@ public:
base.resize(base.size() + 1);
}
/*! \brief Remove one entry from the vector
*
* \param keys element to remove
*
*/
void remove(size_t key)
{
base.erase(base.begin() + key);
}
/*! \brief Get the last element
*
* \return the last element
......
......@@ -4,6 +4,7 @@
#include "map_vector.hpp"
#include "Point_test.hpp"
#include "memory/PreAllocHeapMemory.hpp"
#include "memory/PtrMemory.hpp"
#include <cstring>
#include "Space/Shape/Point.hpp"
......@@ -208,6 +209,75 @@ BOOST_AUTO_TEST_CASE( vector_prealloc )
}
}
BOOST_AUTO_TEST_CASE( vector_memory_repr )
{
// create a vector
openfpm::vector<Point_test<float>> v1;
// Point
Point_test<float> p;
p.setx(1.0);
p.sety(2.0);
p.setz(3.0);
p.sets(4.0);
// push objects
for (size_t i = 0 ; i < FIRST_PUSH ; i++)
{
// Modify p
p.get<P::v>()[0] = 1.0 + i;
p.get<P::v>()[1] = 2.0 + i;
p.get<P::v>()[2] = 7.0 + i;
p.get<P::t>()[0][0] = 10.0 + i;
p.get<P::t>()[0][1] = 13.0 + i;
p.get<P::t>()[0][2] = 8.0 + i;
p.get<P::t>()[1][0] = 19.0 + i;
p.get<P::t>()[1][1] = 23.0 + i;
p.get<P::t>()[1][2] = 5.0 + i;
p.get<P::t>()[2][0] = 4.0 + i;
p.get<P::t>()[2][1] = 3.0 + i;
p.get<P::t>()[2][2] = 11.0 + i;
// add p
v1.add(p);
}
PtrMemory * ptr1 = new PtrMemory(v1.getPointer(),sizeof(Point_test<float>)*FIRST_PUSH);
// create vector representation to a piece of memory already allocated
openfpm::vector<Point_test<float>,openfpm::device_cpu<Point_test<float>>,PtrMemory,openfpm::grow_policy_identity> v2;
v2.setMemory(*ptr1);
v2.resize(FIRST_PUSH);
// check
// Check if the duplicated vector match
for (size_t i = 0 ; i < FIRST_PUSH ; i++)
{
BOOST_REQUIRE_EQUAL(v1.template get<P::v>(i)[0],v2.template get<P::v>(i)[0]);
BOOST_REQUIRE_EQUAL(v1.template get<P::v>(i)[1],v2.template get<P::v>(i)[1]);
BOOST_REQUIRE_EQUAL(v1.template get<P::v>(i)[2],v2.template get<P::v>(i)[2]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[0][0],v2.template get<P::t>(i)[0][0]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[0][1],v2.template get<P::t>(i)[0][1]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[0][2],v2.template get<P::t>(i)[0][2]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[1][0],v2.template get<P::t>(i)[1][0]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[1][1],v2.template get<P::t>(i)[1][1]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[1][2],v2.template get<P::t>(i)[1][2]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[2][0],v2.template get<P::t>(i)[2][0]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[2][1],v2.template get<P::t>(i)[2][1]);
BOOST_REQUIRE_EQUAL(v1.template get<P::t>(i)[2][2],v2.template get<P::t>(i)[2][2]);
}
}
BOOST_AUTO_TEST_SUITE_END()
#endif
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