42 #ifndef STOKHOS_MEMORY_TRAITS_HPP 
   43 #define STOKHOS_MEMORY_TRAITS_HPP 
   47 #include "Kokkos_Core_fwd.hpp" 
   50 #define STOKHOS_ALIGN_MEMORY 1 
   60 #if defined(__INTEL_COMPILER) && ! defined(__CUDA_ARCH__) 
   61 #define STOKHOS_HAVE_PRAGMA_IVDEP 
   65 #if 0 && ( defined(__INTEL_COMPILER) || defined(__CUDA_ARCH__) ) 
   66 #define STOKHOS_HAVE_PRAGMA_UNROLL 
   71 #if defined(STOKHOS_ALIGN_MEMORY) && defined(STOKHOS_ASSUME_ALIGNED) && defined(__INTEL_COMPILER) && ! defined(__CUDA_ARCH__) 
   72 #define STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED 
   78 template <
typename MemorySpace>
 
   85   KOKKOS_INLINE_FUNCTION
 
   86   static void* 
alloc(
const size_t size) { 
return operator new(size); }
 
   89   KOKKOS_INLINE_FUNCTION
 
   90   static void free(
void *ptr) { 
operator delete(ptr); }
 
   98 #if STOKHOS_ALIGN_MEMORY 
  101 #elif defined(__AVX__) 
  103 #elif defined(__SSE2__) 
  121   KOKKOS_INLINE_FUNCTION
 
  122   static void* 
alloc(
const size_t size) {
 
  125 #if STOKHOS_ALIGN_MEMORY 
  127       const size_t total_size = size + mask + 
sizeof(std::ptrdiff_t);
 
  128       char *ptr_alloc = 
reinterpret_cast<char*
>(std::malloc(total_size));
 
  129       char *ptr_storage = ptr_alloc + 
sizeof(std::ptrdiff_t);
 
  130       char *ptr_body = 
reinterpret_cast<char*
>(
 
  131         ( 
reinterpret_cast<size_t>(ptr_storage) + mask ) & ~mask );
 
  132       char *ptr_header = ptr_body - 
sizeof(std::ptrdiff_t);
 
  133       const std::ptrdiff_t offset = ptr_body - ptr_alloc;
 
  134       *
reinterpret_cast<std::ptrdiff_t*
>(ptr_header) = offset;
 
  135       ptr = 
reinterpret_cast<void*
>(ptr_body);
 
  137       ptr = 
operator new(size);
 
  144   KOKKOS_INLINE_FUNCTION
 
  147 #if STOKHOS_ALIGN_MEMORY 
  148       void *ptr_header = 
reinterpret_cast<char*
>(ptr) - 
sizeof(std::ptrdiff_t);
 
  149       const std::ptrdiff_t offset = *
reinterpret_cast<std::ptrdiff_t*
>(ptr_header);
 
  150       void *ptr_alloc = 
reinterpret_cast<char*
>(ptr) - offset;
 
  151       std::free(ptr_alloc);
 
  153       operator delete(ptr);
 
  160 template <
typename T>
 
  191     if (ptr == 0) 
throw std::bad_alloc();
 
  192     return reinterpret_cast<pointer>(ptr);
 
  203 template <
typename T>
 
  232     if (ptr == 0)  
throw std::bad_alloc();
 
  233     return reinterpret_cast<pointer>(ptr);
 
  243 template <
typename T, 
typename U>
 
  248 template <
typename T, 
typename U>
 
  255 #endif // STOKHOS_MEMORY_TRAITS_HPP 
static KOKKOS_INLINE_FUNCTION void free(void *ptr)
Free memory allocated by alloc() 
An aligned STL allocator. 
const_pointer address(const_reference x) const 
pointer address(reference x) const 
Specialization of MemoryTraits for host memory spaces. 
pointer allocate(size_type n, const void *=0)
const_pointer address(const_reference x) const 
bool operator==(const aligned_allocator< T > &, const aligned_allocator< U > &)
static KOKKOS_INLINE_FUNCTION void * alloc(const size_t size)
Allocate aligned memory of given size. 
static KOKKOS_INLINE_FUNCTION void free(void *ptr)
Free memory allocated by alloc() 
const T & const_reference
const T & const_reference
Stokhos::MemoryTraits< Kokkos::HostSpace > Traits
Traits class encapsulting memory alignment. 
void deallocate(pointer p, size_type)
pointer allocate(size_type n, const void *=0)
size_type max_size() const 
aligned_allocator< U > other
static const unsigned Alignment
Bytes to which memory allocations are aligned. 
void deallocate(pointer p, size_type)
std::ptrdiff_t difference_type
aligned_allocator< U > other
void construct(pointer p, const_reference val)
void construct(pointer p, const_reference val)
Stokhos::MemoryTraits< Kokkos::HostSpace > Traits
static KOKKOS_INLINE_FUNCTION void * alloc(const size_t size)
Allocate aligned memory. 
size_type max_size() const 
aligned_allocator(const aligned_allocator< U > &)
static const unsigned Alignment
Bytes to which memory allocations are aligned. 
std::ptrdiff_t difference_type
aligned_allocator(const aligned_allocator< U > &)
bool operator!=(const aligned_allocator< T > &, const aligned_allocator< U > &)