15 #include "../general/cuda.hpp"
16 #include "../general/mem_manager.hpp"
22 template <
int N,
int Dim,
typename T,
typename... Args>
27 static inline int result(
const int* sizes, T first, Args... args)
30 MFEM_ASSERT(first<sizes[N-1],
"Trying to access out of boundary.");
32 return first + sizes[N - 1] *
TensorInd < N + 1, Dim, Args... >
38 template <
int Dim,
typename T,
typename... Args>
43 static inline int result(
const int* sizes, T first, Args... args)
46 MFEM_ASSERT(first<sizes[Dim-1],
"Trying to access out of boundary.");
54 template <
int N,
int Dim,
typename T,
typename... Args>
58 static inline int result(
int* sizes, T first, Args... args)
61 return first *
Init < N + 1, Dim, Args... >
::result(sizes, args...);
66 template <
int Dim,
typename T,
typename... Args>
67 class Init<Dim, Dim, T, Args...>
70 static inline int result(
int* sizes, T first, Args... args)
72 sizes[Dim - 1] = first;
79 template<
int Dim,
typename Scalar =
double>
92 template <
typename... Args>
95 static_assert(
sizeof...(args) == Dim,
"Wrong number of arguments");
106 for (
int i = 0; i < Dim; ++i)
114 inline operator Scalar *()
const {
return data; }
117 template <
typename... Args> MFEM_HOST_DEVICE
inline
120 static_assert(
sizeof...(args) == Dim,
"Wrong number of arguments");
134 template <
typename T,
typename... Dims>
147 #endif // MFEM_DTENSOR
static MFEM_HOST_DEVICE int result(const int *sizes, T first, Args...args)
DeviceTensor()=delete
Default constructor.
MFEM_HOST_DEVICE DeviceTensor(const DeviceTensor &t)
Copy constructor.
DeviceTensor(Scalar *_data, Args...args)
Constructor to initialize a tensor from the Scalar array _data.
MFEM_HOST_DEVICE Scalar & operator()(Args...args) const
Const accessor for the data.
DeviceTensor< 2, double > DeviceMatrix
DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims...dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
DeviceTensor< 1, int > DeviceArray
static MFEM_HOST_DEVICE int result(const int *sizes, T first, Args...args)
A basic generic Tensor class, appropriate for use on the GPU.
A class to initialize the size of a Tensor.
static int result(int *sizes, T first, Args...args)
DeviceTensor< 1, double > DeviceVector
A Class to compute the real index from the multi-indices of a tensor.
static int result(int *sizes, T first, Args...args)
MFEM_HOST_DEVICE Scalar & operator[](int i) const
Subscript operator where the tensor is viewed as a 1D array.