10 #ifndef SACADO_FAD_KOKKOS_VIEW_SUPPORT_INCLUDES
11 #error "This file can only be included by Sacado_Fad_Kokkos_View_Support.hpp"
23 template <
unsigned Str
ide,
typename T>
45 template <
typename T,
int N>
class StaticStorage;
46 template <
typename S>
class GeneralFad;
49 template <
typename T,
int N,
unsigned Str
ide>
52 static const int Ns = (
N + Stride - 1) / Stride;
55 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
57 template <
typename T,
int N>
class SLFad;
59 template <
typename T,
int N,
unsigned Str
ide>
61 static const int Ns = (
N + Stride - 1) / Stride;
72 template <
typename T,
typename U>
class DynamicStorage;
73 template <
typename T,
int N>
class StaticFixedStorage;
74 template <
typename T,
int N>
class StaticStorage;
75 template <
typename S>
class GeneralFad;
78 template <
typename T,
int N,
unsigned Str
ide>
81 static const int Ns = (
N + Stride - 1) / Stride;
82 typedef typename std::conditional<
88 #ifndef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
90 template <
typename T,
int N>
class SFad;
92 template <
typename T,
int N,
unsigned Str
ide>
94 static const int Ns = (
N + Stride - 1) / Stride;
100 #if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
102 #ifndef SACADO_VIEW_CUDA_HIERARCHICAL_DFAD
103 template <
unsigned Str
ide,
typename T,
typename U>
111 const int size = (
x.size() + blockDim.x - threadIdx.x - 1) / blockDim.x;
112 const int offset = threadIdx.x;
113 ret_type xp(size,
x.val());
119 const T *
dx =
x.dx();
120 for (
int i = 0;
i < size; ++
i)
121 xp.fastAccessDx(
i) = dx[offset +
i * Stride];
126 template <
unsigned Str
ide,
typename T,
int N>
127 KOKKOS_INLINE_FUNCTION
typename LocalScalarType<
128 Fad::Exp::GeneralFad<Fad::Exp::StaticStorage<T, N>>, Stride>::type
130 typedef typename LocalScalarType<
131 Fad::Exp::GeneralFad<Fad::Exp::StaticStorage<T, N>>, Stride>::type
133 const int size = (
x.size() + blockDim.x - threadIdx.x - 1) / blockDim.x;
134 const int offset = threadIdx.x;
135 ret_type xp(size,
x.val());
136 for (
int i = 0;
i < size; ++
i)
137 xp.fastAccessDx(
i) =
x.fastAccessDx(offset +
i * Stride);
140 template <
unsigned Str
ide,
typename T,
int N>
141 KOKKOS_INLINE_FUNCTION
typename LocalScalarType<
142 Fad::Exp::GeneralFad<Fad::Exp::StaticFixedStorage<T, N>>, Stride>::type
144 const Fad::Exp::GeneralFad<Fad::Exp::StaticFixedStorage<T, N>> &
x) {
145 typedef typename LocalScalarType<
146 Fad::Exp::GeneralFad<Fad::Exp::StaticFixedStorage<T, N>>, Stride>::type
148 const int size = (
x.size() + blockDim.x - threadIdx.x - 1) / blockDim.x;
149 const int offset = threadIdx.x;
150 ret_type xp(size,
x.val());
151 for (
int i = 0;
i < size; ++
i)
152 xp.fastAccessDx(
i) =
x.fastAccessDx(offset +
i * Stride);
157 template <
typename ViewType,
typename Enabled =
void>
159 typedef typename ViewType::non_const_value_type
type;
162 template <
typename ViewType>
165 typename std::enable_if<is_view_fad_contiguous<ViewType>::value>
::type> {
172 enum { PartitionedFadStride = TraitsType::array_layout::scalar_stride };
177 PartitionedFadStaticDimension =
178 Impl::computeFadPartitionSize(FadStaticDimension, PartitionedFadStride)
180 #ifdef KOKKOS_ENABLE_CUDA
182 fad_type, unsigned(PartitionedFadStride)>
::type strided_scalar_type;
183 typedef typename std::conditional<
185 strided_scalar_type, fad_type>
::type thread_local_scalar_type;
186 #elif defined(KOKKOS_ENABLE_HIP)
188 fad_type, unsigned(PartitionedFadStride)>
::type strided_scalar_type;
189 typedef typename std::conditional<
191 strided_scalar_type, fad_type>
::type thread_local_scalar_type;
KOKKOS_INLINE_FUNCTION const T & partition_scalar(const T &x)
fad_type thread_local_scalar_type
LocalScalarType< T, Stride >::type lst
GeneralFad< StaticStorage< T, Num > > SLFad
ViewType::non_const_value_type type
Base template specification for static size.
std::conditional< Ns==N/Stride, Fad::Exp::GeneralFad< Fad::Exp::StaticFixedStorage< T, Ns > >, Fad::Exp::GeneralFad< Fad::Exp::StaticStorage< T, Ns > > >::type type
Forward-mode AD class templated on the storage for the derivative array.
Derivative array storage class using dynamic memory allocation.
Fad::Exp::GeneralFad< Fad::Exp::StaticStorage< T, Ns > > type
thread_local_scalar_type type
typename ViewType::value_type fad_type
std::conditional< Ns==N/Stride, Fad::SFad< T, Ns >, Fad::SLFad< T, Ns > >::type type
ViewType::traits TraitsType
GeneralFad< StaticFixedStorage< T, Num > > SFad