Commit 64447c56 authored by incardon's avatar incardon
Browse files

Small changes to make working distributed data-structures

parent 9fa3b84a
......@@ -190,13 +190,55 @@ struct mem_setext
}
};
/*! \brief this class is a functor for "for_each" algorithm
*
* This class is a functor for "for_each" algorithm. For each
* element of the boost::vector the operator() is called.
* Is mainly used to set each property with external memory
*
*
*/
template<typename grid_type, typename data_type, typename S>
struct mem_setext_prp
{
grid_type & grid_new;
grid_type & old;
data_type & data_;
/*! \brief constructor
*
*
*
*/
inline mem_setext_prp(grid_type & g_new, grid_type & old, data_type & data_)
:grid_new(g_new),old(old),data_(data_)
{};
//! It call the copy function for each property
template<typename T>
inline void operator()(T& t)
{
grid_new.template setMemory<T::value>(static_cast<S&>(boost::fusion::at_c<T::value>(data_).getMemory()));
}
};
//! Case memory_traits_inte
template<typename grid_type, typename S , typename layout, typename data_type>
struct mem_setext<grid_type,S,layout,data_type,1>
{
static inline void set(grid_type & grid_new, grid_type & old, data_type & data_)
{
std::cerr << __FILE__ << ":" << "__LINE__" << " Error, " << demangle(typeid(grid_type).name()) << " this structure does not support setting from external memory" << std::endl;
// std::cerr << __FILE__ << ":" << "__LINE__" << " Error, " << demangle(typeid(grid_type).name()) << " this structure does not support setting from external memory" << std::endl;
mem_setext_prp<grid_type,data_type,S> mst(grid_new,old,data_);
// Create an empty memory allocator for the actual structure
boost::mpl::for_each_ref<boost::mpl::range_c<int,0,grid_type::value_type::max_prop>>(mst);
old.setMemory();
}
};
......
......@@ -9,7 +9,7 @@
#define OPENFPM_DATA_SRC_GRID_GRID_BASE_IMPLEMENTATION_HPP_
#include "grid_base_impl_layout.hpp"
#include "util/cuda_util.hpp"
#ifdef CUDA_GPU
......@@ -50,9 +50,6 @@ struct ite_gpu
grid_key_dx<dim> start;
grid_key_dx<dim> stop;
};
#else
#define __host__
#define __device__
#endif
/*! \brief
......
......@@ -5,8 +5,6 @@
#ifndef CUDA_GPU
#include <boost/config/compiler/nvcc.hpp>
#define BOOST_FUSION_GPU_ENABLED
#define BOOST_GPU_ENABLED
#endif
//! Warning: apparently you cannot used nested boost::mpl with boost::fusion
......@@ -118,11 +116,14 @@ public:
// you can access all the properties of T
typedef typename grid_base_impl<dim,T,S,typename memory_traits_lin<T>::type, memory_traits_lin>::container container;
//! Grid_cpu has no grow policy
typedef void grow_policy;
//! Default constructor
inline grid_cpu() THROW
:grid_base_impl<dim,T,S,layout,memory_traits_lin>()
{
}
{}
/*! \brief create a grid from another grid
*
......
......@@ -121,7 +121,7 @@ template<unsigned int dim ,typename T> class Point
*/
template <typename vmpl> inline __device__ __host__ Point(const openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl> & mar)
{
for (int i = 0 ; i < dim ; i++)
for (unsigned int i = 0 ; i < dim ; i++)
{get(i) = mar[i];}
}
......
......@@ -220,6 +220,18 @@ class SpaceBox : public Box<dim,T>
SpaceBox<dim,T>() {}
};
///// Unfortunately it seem that nvcc it specialize incorrectly this data structure so we have to specialize for the broken cases
template<unsigned int dim, typename St>
struct is_typedef_and_data_same<true,SpaceBox<dim,St>>
{
enum
{
value = 1
};
};
#include "Grid/Encap.hpp"
......
......@@ -158,6 +158,9 @@ namespace openfpm
//! Type of the value the vector is storing
typedef T value_type;
//! growing policy of this vector
typedef grow_p grow_policy;
template<typename Tobj>
struct layout_base__
{
......@@ -1346,12 +1349,12 @@ namespace openfpm
* \param mem Memory object to use for allocation
*
*/
void setMemory(Memory & mem)
template<unsigned int p = 0> void setMemory(Memory & mem)
{
#ifdef SE_CLASS2
check_valid(this,8);
#endif
base.setMemory(mem);
base.template setMemory<p>(mem);
}
/*! \brief Return the pointer that store the data
......@@ -1451,7 +1454,7 @@ namespace openfpm
template <typename T> using vector_std = vector<T, HeapMemory, typename memory_traits_lin<T>::type, memory_traits_lin, openfpm::grow_policy_double, STD_VECTOR>;
template<typename T> using vector_gpu = openfpm::vector<T,CudaMemory,typename memory_traits_inte<T>::type,memory_traits_inte>;
template<typename T> using vector_gpu_single = openfpm::vector<T,CudaMemory,typename memory_traits_inte<T>::type,memory_traits_inte,openfpm::grow_policy_identity>;
}
......
......@@ -124,6 +124,9 @@ public:
typedef void base_to_copy;
//! growing policy of this vector
typedef grow_policy_double grow_policy;
//This file implements a pack and unpack for std vector
#include "vector_std_pack_unpack.ipp"
......
......@@ -138,7 +138,7 @@ struct is_typedef_and_data_same
{
enum
{
value = std::is_same<decltype(T().data),typename T::type>::value
value = std::is_same<decltype(std::declval<T>().data),typename T::type>::value
};
};
......
......@@ -97,9 +97,8 @@ struct meta_copy<T[N1]>
* \param dst destination object
*
*/
__device__ __host__
template<typename v_mpl>
static inline void meta_copy_(const openfpm::detail::multi_array::sub_array_openfpm<T,1,v_mpl> src,
__device__ __host__ static inline void meta_copy_(const openfpm::detail::multi_array::sub_array_openfpm<T,1,v_mpl> src,
openfpm::detail::multi_array::sub_array_openfpm<T,1,v_mpl> dst)
{
for (size_t i1 = 0 ; i1 < N1 ; i1++)
......@@ -114,9 +113,8 @@ struct meta_copy<T[N1]>
* \param dst destination object
*
*/
__device__ __host__
template<typename v_mpl>
static inline void meta_copy_(const openfpm::detail::multi_array::sub_array_openfpm<T,1,v_mpl> src,
__device__ __host__ static inline void meta_copy_(const openfpm::detail::multi_array::sub_array_openfpm<T,1,v_mpl> src,
T * dst)
{
for (size_t i1 = 0 ; i1 < N1 ; i1++)
......
......@@ -27,8 +27,12 @@ cuda_call; \
}
#else
#ifndef __host__
#define __host__
#define __device__
#endif
#endif
#endif /* OPENFPM_DATA_SRC_UTIL_CUDA_UTIL_HPP_ */
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