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  }
22  internal::aligned_free(buffer);
23  }
24  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* allocate_temp(size_t num_bytes) const {
25  return allocate(num_bytes);
26  }
28  deallocate(buffer);
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 EIGEN_STRONG_INLINE size_t lastLevelCacheSize() const
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
EIGEN_DEVICE_FUNC void * aligned_malloc(std::size_t size)
Definition: Memory.h:174
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t numThreads() const
int n
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate_temp(size_t num_bytes) const
std::ptrdiff_t l3CacheSize()
EIGEN_DEVICE_FUNC void aligned_free(void *ptr)
Definition: Memory.h:198
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE int majorDeviceVersion() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyHostToDevice(void *dst, const void *src, size_t n) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t firstLevelCacheSize() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate(void *buffer) const
int data[]
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyDeviceToHost(void *dst, const void *src, size_t n) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memset(void *buffer, int c, size_t n) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate_temp(void *buffer) const
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpy(void *dst, const void *src, size_t n) const
std::ptrdiff_t l1CacheSize()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate(size_t num_bytes) const


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:36:51