34 #if defined(HAVE_SACADO_KOKKOSCORE)
35 #include "Kokkos_Atomic.hpp"
36 #include "impl/Kokkos_Error.hpp"
44 template <
typename T,
unsigned sl,
unsigned ss,
typename U>
57 template <
typename ValueT,
unsigned length,
unsigned stride,
60 public Expr< GeneralFad<ValueT,Fad::ViewStorage<ValueT,length,stride,BaseFadT> > > {
105 ViewFad(ValueT* v,
const int arg_size = 0,
const int arg_stride = 0) :
110 ViewFad(ValueT* dx_ptr, ValueT* val_ptr,
const int arg_size = 0,
111 const int arg_stride = 0) :
121 template <
typename S>
124 GeneralFadType::operator=(v);
131 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
136 template <
typename S>
140 GeneralFadType::operator=(x);
152 template <
typename S>
155 GeneralFadType::operator+=(x);
160 template <
typename S>
163 GeneralFadType::operator-=(x);
168 template <
typename S>
171 GeneralFadType::operator*=(x);
176 template <
typename S>
179 GeneralFadType::operator/=(x);
186 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
193 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
200 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
207 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
212 template <
typename S>
215 GeneralFadType::operator+=(x);
220 template <
typename S>
223 GeneralFadType::operator-=(x);
228 template <
typename S>
231 GeneralFadType::operator*=(x);
236 template <
typename S>
239 GeneralFadType::operator/=(x);
245 ViewFadPtr<ValueT,length,stride,BaseFadT> operator&()
const {
246 return ViewFadPtr<ValueT,length,stride,BaseFadT>(
247 this->dx_, this->val_, this->sz_.value, this->stride_.value);
255 template <
typename T,
unsigned sl,
unsigned ss,
typename U>
256 class ViewFadPtr :
public ViewFad<T,sl,ss,U> {
263 using view_fad_type::view_fad_type;
274 #if defined(HAVE_SACADO_KOKKOSCORE)
276 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
278 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x) {
279 using Kokkos::atomic_add;
283 const int xsz = x.size();
284 const int sz = dst->size();
290 "Sacado error: Fad resize within atomic_add() not supported!");
292 if (xsz != sz && sz > 0 && xsz > 0)
294 "Sacado error: Fad assignment of incompatiable sizes!");
297 if (sz > 0 && xsz > 0) {
302 atomic_add(&(dst->
val()), x.val());
306 template <
typename T,
unsigned l,
unsigned s,
typename U>
307 struct BaseExpr< GeneralFad<
T,Fad::ViewStorage<T,l,s,U> > > {
312 template <
typename T,
unsigned l,
unsigned s,
typename U>
314 static const unsigned value =
315 ExprLevel< typename ViewFad<T,l,s,U>::value_type >::value + 1;
318 template <
typename T,
unsigned l,
unsigned s,
typename U>
320 static const bool value =
true;
325 template <
typename T,
unsigned l,
unsigned s,
typename U>
327 static const bool value =
true;
330 template <
typename T,
unsigned l,
unsigned s,
typename U>
332 static const bool value =
true;
335 template <
typename T,
unsigned l,
unsigned s,
typename U>
337 static const bool value =
true;
340 template <
typename T,
unsigned l,
unsigned s,
typename U>
Expr< GeneralFadType > ExprType
KOKKOS_INLINE_FUNCTION view_fad_type * operator->()
Fad::ViewStorage< ValueT, length, stride, BaseFadT > StorageType
Base classes.
#define SACADO_FAD_THREAD_SINGLE
Base template specification for whether a type is a Fad type.
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
KOKKOS_INLINE_FUNCTION ~ViewFad()
Destructor.
Forward-mode AD class using dynamic memory allocation and expression templates.
KOKKOS_INLINE_FUNCTION ViewFad(const StorageType &s)
Constructor with supplied storage s.
KOKKOS_INLINE_FUNCTION view_fad_type & operator*()
ViewFad< T, length, stride, new_base_fad_type > type
F::template apply< A1, A2, A3, A4, A5 >::type type
#define KOKKOS_INLINE_FUNCTION
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
Determine whether a given type is a view.
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
#define SACADO_FAD_DERIV_LOOP(I, SZ)
Get the base Fad type from a view/expression.
mpl::apply< base_fad_type, T_for_base >::type new_base_fad_type
KOKKOS_INLINE_FUNCTION ViewFad(ValueT *v, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
FAD_NS::ViewFad< T, l, s, U >::base_expr_type type
KOKKOS_INLINE_FUNCTION ViewFad(ValueT *dx_ptr, ValueT *val_ptr, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
BaseExprType< T >::type T_for_base
ViewFad< T, sl, ss, U > view_fad_type
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
BaseFadT base_fad_type
Fad type view is based on.
Turn ViewFad into a meta-function class usable with mpl::apply.
ExprType::value_type value_type
Typename of values.
Derivative array storage class that is a view into a contiguous memory allocation. It does not provide proper value semantics and thus should not be used in a general-purpose scalar type.
GeneralFad< ViewStorage< T, static_length, static_stride, U > > ViewFad
GeneralFad< ValueT, StorageType > GeneralFadType