PandaRoot
nsL1::SimdAlloc< T > Class Template Reference

#include <std_alloc.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
 
 SimdAlloc () throw ()
 
 SimdAlloc (const SimdAlloc &) throw ()
 
template<class U >
 SimdAlloc (const SimdAlloc< U > &) throw ()
 
 ~SimdAlloc () throw ()
 
size_type max_size () const throw ()
 
pointer allocate (size_type num, const void *=nullptr)
 
void construct (pointer p, const T &value)
 
void destroy (pointer p)
 
void deallocate (pointer p, size_type num)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size, void *ptr)
 
void * operator new (size_t size)
 
void * operator new[] (size_t size)
 
void operator delete (void *ptr, size_t)
 
void operator delete[] (void *ptr, size_t)
 

Detailed Description

template<class T>
class nsL1::SimdAlloc< T >

Definition at line 26 of file std_alloc.h.

Member Typedef Documentation

◆ const_pointer

template<class T >
typedef const T* nsL1::SimdAlloc< T >::const_pointer

Definition at line 31 of file std_alloc.h.

◆ const_reference

template<class T >
typedef const T& nsL1::SimdAlloc< T >::const_reference

Definition at line 33 of file std_alloc.h.

◆ difference_type

template<class T >
typedef std::ptrdiff_t nsL1::SimdAlloc< T >::difference_type

Definition at line 35 of file std_alloc.h.

◆ pointer

template<class T >
typedef T* nsL1::SimdAlloc< T >::pointer

Definition at line 30 of file std_alloc.h.

◆ reference

template<class T >
typedef T& nsL1::SimdAlloc< T >::reference

Definition at line 32 of file std_alloc.h.

◆ size_type

template<class T >
typedef std::size_t nsL1::SimdAlloc< T >::size_type

Definition at line 34 of file std_alloc.h.

◆ value_type

template<class T >
typedef T nsL1::SimdAlloc< T >::value_type

Definition at line 29 of file std_alloc.h.

Constructor & Destructor Documentation

◆ SimdAlloc() [1/3]

template<class T >
nsL1::SimdAlloc< T >::SimdAlloc ( )
throw (
)
inline

Definition at line 50 of file std_alloc.h.

50 {}

◆ SimdAlloc() [2/3]

template<class T >
nsL1::SimdAlloc< T >::SimdAlloc ( const SimdAlloc< T > &  )
throw (
)
inline

Definition at line 51 of file std_alloc.h.

51 {}

◆ SimdAlloc() [3/3]

template<class T >
template<class U >
nsL1::SimdAlloc< T >::SimdAlloc ( const SimdAlloc< U > &  )
throw (
)
inline

Definition at line 53 of file std_alloc.h.

54  {
55  }

◆ ~SimdAlloc()

template<class T >
nsL1::SimdAlloc< T >::~SimdAlloc ( )
throw (
)
inline

Definition at line 56 of file std_alloc.h.

56 {}

Member Function Documentation

◆ address() [1/2]

template<class T >
pointer nsL1::SimdAlloc< T >::address ( reference  value) const
inline

Definition at line 44 of file std_alloc.h.

44 { return &value; }

◆ address() [2/2]

template<class T >
const_pointer nsL1::SimdAlloc< T >::address ( const_reference  value) const
inline

Definition at line 45 of file std_alloc.h.

45 { return &value; }

◆ allocate()

template<class T >
pointer nsL1::SimdAlloc< T >::allocate ( size_type  num,
const void *  = nullptr 
)
inline

Definition at line 62 of file std_alloc.h.

63  {
64 // print message and allocate memory with global new
65 #ifdef DEBUG_nsL1
66  std::cerr << "Allocator: allocate " << num << " element(s)"
67  << " of size " << sizeof(T) << std::endl;
68 #endif // DEBUG_nsL1
69  pointer ret = reinterpret_cast<pointer>(/*T::*/ operator new(num * sizeof(T)));
70 #ifdef DEBUG_nsL1
71  std::cerr << " allocated at: " << (void *)ret << std::endl;
72 #endif // DEBUG_nsL1
73  return ret;
74  }

◆ construct()

template<class T >
void nsL1::SimdAlloc< T >::construct ( pointer  p,
const T &  value 
)
inline

Definition at line 77 of file std_alloc.h.

78  {
79  // initialize memory with placement new
80 #ifdef DEBUG_nsL1
81  std::cerr << "Allocator: construct " << p /*<< " " << value*/ << std::endl;
82 #endif // DEBUG_nsL1
83  new (p) T(value);
84 // p = reinterpret_cast<pointer>( operator new(sizeof(T), p) );
85 // *p = value;
86 #ifdef DEBUG_nsL1
87  std::cerr << "done." << std::endl;
88 #endif // DEBUG_nsL1
89  }

◆ deallocate()

template<class T >
void nsL1::SimdAlloc< T >::deallocate ( pointer  p,
size_type  num 
)
inline

Definition at line 105 of file std_alloc.h.

106  {
107  // print message and deallocate memory with global delete
108 #ifdef DEBUG_nsL1
109  std::cerr << "Allocator: deallocate " << num << " element(s)"
110  << " of size " << sizeof(T) << " at: " << static_cast<void *>(p) << std::endl;
111 #endif // DEBUG_nsL1
112  /*T::*/ operator delete(static_cast<void *>(p), num * sizeof(T));
113 #ifdef DEBUG_nsL1
114  std::cerr << "done." << std::endl;
115 #endif // DEBUG_nsL1
116  }

◆ destroy()

template<class T >
void nsL1::SimdAlloc< T >::destroy ( pointer  p)
inline

Definition at line 92 of file std_alloc.h.

93  {
94  // destroy objects by calling their destructor
95 #ifdef DEBUG_nsL1
96  std::cerr << "Allocator: destroy " << p << std::endl;
97 #endif // DEBUG_nsL1
98  p->~T();
99 #ifdef DEBUG_nsL1
100  std::cerr << "done." << std::endl;
101 #endif // DEBUG_nsL1
102  }

◆ max_size()

template<class T >
size_type nsL1::SimdAlloc< T >::max_size ( ) const
throw (
)
inline

Definition at line 59 of file std_alloc.h.

References max().

59 { return std::numeric_limits<std::size_t>::max() / sizeof(T); }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37

◆ operator delete()

template<class T >
void nsL1::SimdAlloc< T >::operator delete ( void *  ptr,
size_t   
)
inline

Definition at line 122 of file std_alloc.h.

122 { _mm_free(ptr); }

◆ operator delete[]()

template<class T >
void nsL1::SimdAlloc< T >::operator delete[] ( void *  ptr,
size_t   
)
inline

Definition at line 123 of file std_alloc.h.

123 { _mm_free(ptr); }

◆ operator new() [1/2]

template<class T >
void* nsL1::SimdAlloc< T >::operator new ( size_t  size,
void *  ptr 
)
inline

Definition at line 118 of file std_alloc.h.

118 { return ::operator new(size, ptr); }

◆ operator new() [2/2]

template<class T >
void* nsL1::SimdAlloc< T >::operator new ( size_t  size)
inline

Definition at line 120 of file std_alloc.h.

120 { return _mm_malloc(size, 16); }

◆ operator new[]() [1/2]

template<class T >
void* nsL1::SimdAlloc< T >::operator new[] ( size_t  size,
void *  ptr 
)
inline

Definition at line 119 of file std_alloc.h.

119 { return ::operator new(size, ptr); }

◆ operator new[]() [2/2]

template<class T >
void* nsL1::SimdAlloc< T >::operator new[] ( size_t  size)
inline

Definition at line 121 of file std_alloc.h.

121 { return _mm_malloc(size, 16); }

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