TensorDeviceDefault.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_DEVICE_DEFAULT_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_DEVICE_DEFAULT_H
12 
13 
14 namespace Eigen {
15 
16 // Default device for the machine (typically a single cpu core)
17 struct DefaultDevice {
18  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* allocate(size_t num_bytes) const {
19  return internal::aligned_malloc(num_bytes);
20  }
23  }
24  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* allocate_temp(size_t num_bytes) const {
25  return allocate(num_bytes);
26  }
29  }
30  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpy(void* dst, const void* src, size_t n) const {
31  ::memcpy(dst, src, n);
32  }
33  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyHostToDevice(void* dst, const void* src, size_t n) const {
34  memcpy(dst, src, n);
35  }
36  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyDeviceToHost(void* dst, const void* src, size_t n) const {
37  memcpy(dst, src, n);
38  }
39  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memset(void* buffer, int c, size_t n) const {
40  ::memset(buffer, c, n);
41  }
42  template<typename Type>
44  return data;
45  }
46 
48 #if !defined(EIGEN_GPU_COMPILE_PHASE)
49  // Running on the host CPU
50  return 1;
51 #elif defined(EIGEN_HIP_DEVICE_COMPILE)
52  // Running on a HIP device
53  return 64;
54 #else
55  // Running on a CUDA device
56  return 32;
57 #endif
58  }
59 
61 #if !defined(EIGEN_GPU_COMPILE_PHASE) && !defined(SYCL_DEVICE_ONLY)
62  // Running on the host CPU
63  return l1CacheSize();
64 #elif defined(EIGEN_HIP_DEVICE_COMPILE)
65  // Running on a HIP device
66  return 48*1024; // FIXME : update this number for HIP
67 #else
68  // Running on a CUDA device, return the amount of shared memory available.
69  return 48*1024;
70 #endif
71  }
72 
74 #if !defined(EIGEN_GPU_COMPILE_PHASE) && !defined(SYCL_DEVICE_ONLY)
75  // Running single threaded on the host CPU
76  return l3CacheSize();
77 #elif defined(EIGEN_HIP_DEVICE_COMPILE)
78  // Running on a HIP device
79  return firstLevelCacheSize(); // FIXME : update this number for HIP
80 #else
81  // Running on a CUDA device
82  return firstLevelCacheSize();
83 #endif
84  }
85 
87 #if !defined(EIGEN_GPU_COMPILE_PHASE)
88  // Running single threaded on the host CPU
89  // Should return an enum that encodes the ISA supported by the CPU
90  return 1;
91 #elif defined(EIGEN_HIP_DEVICE_COMPILE)
92  // Running on a HIP device
93  // return 1 as major for HIP
94  return 1;
95 #else
96  // Running on a CUDA device
97  return EIGEN_CUDA_ARCH / 100;
98 #endif
99  }
100 };
101 
102 } // namespace Eigen
103 
104 #endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_DEFAULT_H
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::DefaultDevice::deallocate
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate(void *buffer) const
Definition: TensorDeviceDefault.h:21
Eigen::l3CacheSize
std::ptrdiff_t l3CacheSize()
Definition: products/GeneralBlockPanelKernel.h:2626
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Eigen::DefaultDevice::memcpyHostToDevice
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyHostToDevice(void *dst, const void *src, size_t n) const
Definition: TensorDeviceDefault.h:33
buffer
Definition: pytypes.h:2270
Eigen::internal::aligned_malloc
EIGEN_DEVICE_FUNC void * aligned_malloc(std::size_t size)
Definition: Memory.h:174
Eigen::DefaultDevice::memset
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memset(void *buffer, int c, size_t n) const
Definition: TensorDeviceDefault.h:39
Eigen::DefaultDevice
Definition: TensorDeviceDefault.h:17
n
int n
Definition: BiCGSTAB_simple.cpp:1
Eigen::internal::aligned_free
EIGEN_DEVICE_FUNC void aligned_free(void *ptr)
Definition: Memory.h:198
Type
Definition: typing.h:67
Eigen::DefaultDevice::deallocate_temp
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate_temp(void *buffer) const
Definition: TensorDeviceDefault.h:27
data
int data[]
Definition: Map_placement_new.cpp:1
Eigen::DefaultDevice::memcpyDeviceToHost
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyDeviceToHost(void *dst, const void *src, size_t n) const
Definition: TensorDeviceDefault.h:36
Eigen::DefaultDevice::allocate_temp
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate_temp(size_t num_bytes) const
Definition: TensorDeviceDefault.h:24
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
Eigen::DefaultDevice::get
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Type get(Type data) const
Definition: TensorDeviceDefault.h:43
Eigen::DefaultDevice::lastLevelCacheSize
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t lastLevelCacheSize() const
Definition: TensorDeviceDefault.h:73
Eigen::DefaultDevice::firstLevelCacheSize
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t firstLevelCacheSize() const
Definition: TensorDeviceDefault.h:60
Eigen::DefaultDevice::numThreads
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t numThreads() const
Definition: TensorDeviceDefault.h:47
Eigen::DefaultDevice::allocate
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate(size_t num_bytes) const
Definition: TensorDeviceDefault.h:18
Eigen::l1CacheSize
std::ptrdiff_t l1CacheSize()
Definition: products/GeneralBlockPanelKernel.h:2607
Eigen::DefaultDevice::majorDeviceVersion
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE int majorDeviceVersion() const
Definition: TensorDeviceDefault.h:86
Eigen::DefaultDevice::memcpy
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpy(void *dst, const void *src, size_t n) const
Definition: TensorDeviceDefault.h:30


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:37:32