8 #include <boost/multi_array.hpp>
9 #include <boost/fusion/mpl.hpp>
10 #include <boost/fusion/include/mpl.hpp>
11 #include <boost/mpl/vector.hpp>
13 #include "util/ct_array.hpp"
14 #include "memory_array.hpp"
15 #include "memory/memory.hpp"
30 template<
typename T,
typename D = memory>
57 if (this->mem != NULL)
61 if (this->mem->
ref() == 0 && &mem != this->
mem)
94 bool allocate(
const size_t sz,
bool skip_initialization =
false)
99 mem->
resize( sz*
sizeof(T) );
160 void * mem_tmp =
static_cast<void*
>(
mem);
161 void * mem_r_tmp =
static_cast<void*
>(
mem_r);
168 mem_obj.
mem =
static_cast<D*
>(mem_tmp);
212 template<
typename T,
unsigned int N>
215 enum { value =
mult<T,N-1>::value * boost::mpl::at<T,boost::mpl::int_<N>>::type::value };
218 template <
typename T>
221 enum { value = boost::mpl::at<T,boost::mpl::int_<1>>::type::value };
239 template<
typename T,
typename D>
246 template<
int S>
using int_ = boost::mpl::int_<S>;
249 typedef typename boost::mpl::size<T>
size_p;
252 template<
typename S,
unsigned int n>
using at = boost::mpl::at<S,boost::mpl::int_<n> >;
257 typedef typename boost::multi_array_ref<base,size_p::value>::size_type
size_type;
267 template<
size_t index,
size_t N>
struct ordering
269 enum { value = (N-index) % N };
280 template<
size_t index,
size_t N>
struct ascending
282 enum { value =
true };
295 if (this->mem != NULL)
299 if (this->mem->
ref() == 0 && &mem != this->
mem)
334 std::array<size_type ,size_p::value> dimensions;
338 for (
int i = 0 ; i < size_p::value-1 ; i++)
339 {dimensions[i+1] = dims::data[i];}
345 typedef typename generate_array<bool,size_p::value, ascending>::result asc;
348 mem_r =
new boost::multi_array_ref<base,size_p::value>(
static_cast<base *
>(mem->
getPointer()),dimensions,boost::general_storage_order<size_p::value>(ord::data,asc::data));
355 typedef boost::multi_array<base,size_p::value>
type;
361 boost::multi_array_ref<base,boost::mpl::size<T>::value> *
mem_r;
393 void * mem_tmp =
static_cast<void*
>(
mem);
394 void * mem_r_tmp =
static_cast<void*
>(
mem_r);
401 mem_obj.
mem =
static_cast<D*
>(mem_tmp);
402 mem_obj.
mem_r =
static_cast<decltype(mem_obj.
mem_r)
>(mem_r_tmp);
memory & getMemory()
This function get the object that allocate memory.
Derivative second order on h (spacing)
bool allocate(const size_t sz, bool skip_initialization=false)
This function allocate memory.
void swap(memory_c &mem_obj)
swap the memory
bool allocate(const size_t sz)
This function allocate memory and associate the representation to mem_r.
virtual bool resize(size_t sz)=0
resize on device a buffer
T & reference
define a reference to T
void setMemory(memory &mem)
This function set the object that allocate memory.
Main class to generate compile-time array.
boost::mpl::at< S, boost::mpl::int_< n > > at
Define "at" meta function without boost::mpl.
void setMemory(memory &mem)
This function set the object that allocate memory.
D * mem
Reference to an object to allocate memory.
memory_c< T > type
define T
virtual long int ref()=0
Return the actual reference counter.
D * mem
object that allocate memory like HeapMemory or CudaMemory
memory_array< T > * mem_r
object that represent the memory as an array of objects T
boost::multi_array_ref< base, boost::mpl::size< T >::value > * mem_r
object that represent the memory as an multi-dimensional array of objects T
boost::mpl::int_< S > int_
define T
boost::mpl::size< T > size_p
define the template vector size it give a number at compile time
void set_mem(memory &mem)
set the device memory interface, the object that allocate memory
memory & getMemory()
This function get the object that allocate memory.
void move_copy(memory_c &mem_c)
It absorb the allocated object from another memory_c.
generate_array_vector_impl< T, boost::mpl::size< F >::value-1, F >::result result
generate compile-time array vector
this class multiply all the elements in a boost::mpl::vector excluding the first element ...
const memory & getMemory() const
This function get the object that allocate memory.
This class is a trick to indicate the compiler a specific specialization pattern. ...
void swap(memory_c &mem_obj)
swap the memory
virtual void decRef()=0
Decrement the internal reference counter.
boost::multi_array< base, size_p::value > type
virtual bool isInitialized()=0
Return if the actual memory that is going to be allocated is already initialized. ...
This class is a container for the memory interface like HeapMemory CudaMemory.
This class give a representation to a chunk or memory.
virtual void * getPointer()=0
return a data pointer
virtual void incRef()=0
Increment the internal reference counter.
boost::multi_array_ref< base, size_p::value >::size_type size_type
define size_type
This class is a trick to indicate the compiler a specific specialization pattern. ...