VM2D  1.12
Vortex methods for 2D flows simulation
VM2D::MyAlloc< T > Class Template Reference

#include <Gpu2D.h>

Classes

struct  rebind
 

Public Types

typedef T value_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 

Public Member Functions

pointer address (reference value) const
 
const_pointer address (const_reference value) const
 
 MyAlloc () throw ()
 
 MyAlloc (const MyAlloc &) throw ()
 
template<class U >
 MyAlloc (const MyAlloc< U > &) throw ()
 
 ~MyAlloc () throw ()
 
size_type max_size () const throw ()
 
pointer allocate (size_type num, const void *=0)
 
void construct (pointer p, const T &value)
 
void destroy (pointer p)
 
void deallocate (pointer p, size_type num)
 

Detailed Description

template<class T>
class VM2D::MyAlloc< T >

Definition at line 294 of file Gpu2D.h.

Member Typedef Documentation

template<class T>
typedef const T* VM2D::MyAlloc< T >::const_pointer

Definition at line 299 of file Gpu2D.h.

template<class T>
typedef const T& VM2D::MyAlloc< T >::const_reference

Definition at line 301 of file Gpu2D.h.

template<class T>
typedef std::ptrdiff_t VM2D::MyAlloc< T >::difference_type

Definition at line 303 of file Gpu2D.h.

template<class T>
typedef T* VM2D::MyAlloc< T >::pointer

Definition at line 298 of file Gpu2D.h.

template<class T>
typedef T& VM2D::MyAlloc< T >::reference

Definition at line 300 of file Gpu2D.h.

template<class T>
typedef std::size_t VM2D::MyAlloc< T >::size_type

Definition at line 302 of file Gpu2D.h.

template<class T>
typedef T VM2D::MyAlloc< T >::value_type

Definition at line 297 of file Gpu2D.h.

Constructor & Destructor Documentation

template<class T>
VM2D::MyAlloc< T >::MyAlloc ( )
throw (
)
inline

Definition at line 322 of file Gpu2D.h.

322  {
323  }
template<class T>
VM2D::MyAlloc< T >::MyAlloc ( const MyAlloc< T > &  )
throw (
)
inline

Definition at line 324 of file Gpu2D.h.

324  {
325  }
template<class T>
template<class U >
VM2D::MyAlloc< T >::MyAlloc ( const MyAlloc< U > &  )
throw (
)
inline

Definition at line 327 of file Gpu2D.h.

327  {
328  }
template<class T>
VM2D::MyAlloc< T >::~MyAlloc ( )
throw (
)
inline

Definition at line 329 of file Gpu2D.h.

329  {
330  }

Member Function Documentation

template<class T>
pointer VM2D::MyAlloc< T >::address ( reference  value) const
inline

Definition at line 312 of file Gpu2D.h.

312  {
313  return &value;
314  }
template<class T>
const_pointer VM2D::MyAlloc< T >::address ( const_reference  value) const
inline

Definition at line 315 of file Gpu2D.h.

315  {
316  return &value;
317  }
template<class T>
pointer VM2D::MyAlloc< T >::allocate ( size_type  num,
const void *  = 0 
)
inline

Definition at line 338 of file Gpu2D.h.

338  {
339  // print message and allocate memory with global new
340  //std::cerr << "allocate " << num << " element(s)" << " of size " << sizeof(T) << std::endl;
341 
342  pointer ret = (pointer)(::operator new(num * sizeof(T)));
343 
344  //pointer ret;
345  //cudaHostAlloc((void**)&ret, num * sizeof(T), cudaHostAllocDefault);
346  cuAlloc((void**)&ret, num * sizeof(T));
347 
348  //std::cerr << " allocated at: " << (void*)ret << std::endl;
349  return ret;
350  }
T * pointer
Definition: Gpu2D.h:298
template<class T>
void VM2D::MyAlloc< T >::construct ( pointer  p,
const T &  value 
)
inline

Definition at line 353 of file Gpu2D.h.

353  {
354  // initialize memory with placement new
355  new((void*)p)T(value);
356  //std::cerr << " construct " << std::endl;
357  }
template<class T>
void VM2D::MyAlloc< T >::deallocate ( pointer  p,
size_type  num 
)
inline

Definition at line 367 of file Gpu2D.h.

367  {
368  // print message and deallocate memory with global delete
369 
370  //std::cerr << "deallocate " << num << " element(s)" << " of size " << sizeof(T) << " at: " << (void*)p << std::endl;
371 
372  //::operator delete((void*)p);
373  cuDalloc((void*)p);
374  }
template<class T>
void VM2D::MyAlloc< T >::destroy ( pointer  p)
inline

Definition at line 360 of file Gpu2D.h.

360  {
361  // destroy objects by calling their destructor
362  p->~T();
363  //std::cerr << " destroy " << std::endl;
364  }
template<class T>
size_type VM2D::MyAlloc< T >::max_size ( ) const
throw (
)
inline

Definition at line 333 of file Gpu2D.h.

333  {
334  return std::numeric_limits<std::size_t>::max() / sizeof(T);
335  }

The documentation for this class was generated from the following file: