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"
31 template<
typename T,
typename D = memory>
58 if (this->mem != NULL)
62 if (this->mem->ref() == 0 && &mem != this->
mem)
100 mem->resize( sz*
sizeof(T) );
161 void * mem_tmp =
static_cast<void*
>(
mem);
162 void * mem_r_tmp =
static_cast<void*
>(
mem_r);
169 mem_obj.
mem =
static_cast<D*
>(mem_tmp);
213 template<
typename T,
unsigned int N>
216 enum { value =
mult<T,N-1>::value * boost::mpl::at<T,boost::mpl::int_<N>>::type::value };
219 template <
typename T>
222 enum { value = boost::mpl::at<T,boost::mpl::int_<1>>::type::value };
240 template<
typename T,
typename D>
247 template<
int S>
using int_ = boost::mpl::int_<S>;
250 typedef typename boost::mpl::size<T>
size_p;
253 template<
typename S,
unsigned int n>
using at = boost::mpl::at<S,boost::mpl::int_<n> >;
258 typedef typename boost::multi_array_ref<base,size_p::value>::size_type
size_type;
268 template<
size_t index,
size_t N>
struct ordering
270 enum { value = (N-index) % N };
281 template<
size_t index,
size_t N>
struct ascending
283 enum { value =
true };
296 if (this->mem != NULL)
300 if (this->mem->ref() == 0 && &mem != this->
mem)
332 typedef typename generate_array_vector<size_type,T>::result dims;
335 std::array<size_type ,size_p::value> dimensions;
339 for (
int i = 0 ; i < size_p::value-1 ; i++)
340 {dimensions[i+1] = dims::data[i];}
346 typedef typename generate_array<bool,size_p::value, ascending>::result asc;
349 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));
356 typedef boost::multi_array<base,size_p::value>
type;
362 boost::multi_array_ref<base,boost::mpl::size<T>::value> *
mem_r;
memory & getMemory()
This function get the object that 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.
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
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.
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. ...
boost::multi_array< base, size_p::value > type
This class is a container for the memory interface like HeapMemory CudaMemory.
This class give a representation to a chunk or memory.
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. ...
bool allocate(const size_t sz)
This function allocate memory.