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 14 of file std_alloc.h.

Member Typedef Documentation

◆ const_pointer

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

Definition at line 19 of file std_alloc.h.

◆ const_reference

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

Definition at line 21 of file std_alloc.h.

◆ difference_type

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

Definition at line 23 of file std_alloc.h.

◆ pointer

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

Definition at line 18 of file std_alloc.h.

◆ reference

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

Definition at line 20 of file std_alloc.h.

◆ size_type

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

Definition at line 22 of file std_alloc.h.

◆ value_type

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

Definition at line 17 of file std_alloc.h.

Constructor & Destructor Documentation

◆ SimdAlloc() [1/3]

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

Definition at line 38 of file std_alloc.h.

38 {}

◆ SimdAlloc() [2/3]

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

Definition at line 39 of file std_alloc.h.

39 {}

◆ SimdAlloc() [3/3]

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

Definition at line 41 of file std_alloc.h.

42  {
43  }

◆ ~SimdAlloc()

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

Definition at line 44 of file std_alloc.h.

44 {}

Member Function Documentation

◆ address() [1/2]

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

Definition at line 32 of file std_alloc.h.

32 { return &value; }

◆ address() [2/2]

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

Definition at line 33 of file std_alloc.h.

33 { return &value; }

◆ allocate()

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

Definition at line 50 of file std_alloc.h.

51  {
52 // print message and allocate memory with global new
53 #ifdef DEBUG_nsL1
54  std::cerr << "Allocator: allocate " << num << " element(s)"
55  << " of size " << sizeof(T) << std::endl;
56 #endif // DEBUG_nsL1
57  pointer ret = reinterpret_cast<pointer>(/*T::*/ operator new(num * sizeof(T)));
58 #ifdef DEBUG_nsL1
59  std::cerr << " allocated at: " << (void *)ret << std::endl;
60 #endif // DEBUG_nsL1
61  return ret;
62  }

◆ construct()

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

Definition at line 65 of file std_alloc.h.

66  {
67  // initialize memory with placement new
68 #ifdef DEBUG_nsL1
69  std::cerr << "Allocator: construct " << p /*<< " " << value*/ << std::endl;
70 #endif // DEBUG_nsL1
71  new (p) T(value);
72 // p = reinterpret_cast<pointer>( operator new(sizeof(T), p) );
73 // *p = value;
74 #ifdef DEBUG_nsL1
75  std::cerr << "done." << std::endl;
76 #endif // DEBUG_nsL1
77  }

◆ deallocate()

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

Definition at line 93 of file std_alloc.h.

94  {
95  // print message and deallocate memory with global delete
96 #ifdef DEBUG_nsL1
97  std::cerr << "Allocator: deallocate " << num << " element(s)"
98  << " of size " << sizeof(T) << " at: " << static_cast<void *>(p) << std::endl;
99 #endif // DEBUG_nsL1
100  /*T::*/ operator delete(static_cast<void *>(p), num * sizeof(T));
101 #ifdef DEBUG_nsL1
102  std::cerr << "done." << std::endl;
103 #endif // DEBUG_nsL1
104  }

◆ destroy()

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

Definition at line 80 of file std_alloc.h.

81  {
82  // destroy objects by calling their destructor
83 #ifdef DEBUG_nsL1
84  std::cerr << "Allocator: destroy " << p << std::endl;
85 #endif // DEBUG_nsL1
86  p->~T();
87 #ifdef DEBUG_nsL1
88  std::cerr << "done." << std::endl;
89 #endif // DEBUG_nsL1
90  }

◆ max_size()

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

Definition at line 47 of file std_alloc.h.

References max().

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

◆ operator delete()

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

Definition at line 110 of file std_alloc.h.

110 { _mm_free(ptr); }

◆ operator delete[]()

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

Definition at line 111 of file std_alloc.h.

111 { _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 106 of file std_alloc.h.

106 { 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 108 of file std_alloc.h.

108 { 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 107 of file std_alloc.h.

107 { 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 109 of file std_alloc.h.

109 { return _mm_malloc(size, 16); }

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