TR-mbed 1.0
Loading...
Searching...
No Matches
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
14namespace Eigen {
15
16// Default device for the machine (typically a single cpu core)
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 }
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
int n
Definition BiCGSTAB_simple.cpp:1
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
int data[]
Definition Map_placement_new.cpp:1
Scalar Scalar * c
Definition benchVecAdd.cpp:17
EIGEN_DEVICE_FUNC void * aligned_malloc(std::size_t size)
Definition Memory.h:174
EIGEN_DEVICE_FUNC void aligned_free(void *ptr)
Definition Memory.h:198
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
std::ptrdiff_t l1CacheSize()
Definition GeneralBlockPanelKernel.h:2607
std::ptrdiff_t l3CacheSize()
Definition GeneralBlockPanelKernel.h:2626
Definition TensorDeviceDefault.h:17
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memset(void *buffer, int c, size_t n) const
Definition TensorDeviceDefault.h:39
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Type get(Type data) const
Definition TensorDeviceDefault.h:43
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate(void *buffer) const
Definition TensorDeviceDefault.h:21
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyDeviceToHost(void *dst, const void *src, size_t n) const
Definition TensorDeviceDefault.h:36
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate_temp(size_t num_bytes) const
Definition TensorDeviceDefault.h:24
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpy(void *dst, const void *src, size_t n) const
Definition TensorDeviceDefault.h:30
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE int majorDeviceVersion() const
Definition TensorDeviceDefault.h:86
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t firstLevelCacheSize() const
Definition TensorDeviceDefault.h:60
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t numThreads() const
Definition TensorDeviceDefault.h:47
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void deallocate_temp(void *buffer) const
Definition TensorDeviceDefault.h:27
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyHostToDevice(void *dst, const void *src, size_t n) const
Definition TensorDeviceDefault.h:33
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t lastLevelCacheSize() const
Definition TensorDeviceDefault.h:73
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void * allocate(size_t num_bytes) const
Definition TensorDeviceDefault.h:18