14 #if defined(HAVE_SACADO_KOKKOS)
15 #include "Kokkos_Atomic.hpp"
16 #include "impl/Kokkos_Error.hpp"
24 template <
typename T,
unsigned sl,
unsigned ss,
typename U>
37 template <
typename ValueT,
unsigned length,
unsigned stride,
40 public Expr< GeneralFad<ValueT,Fad::ViewStorage<ValueT,length,stride,BaseFadT> > > {
85 ViewFad(ValueT* v,
const int arg_size = 0,
const int arg_stride = 0) :
90 ViewFad(ValueT* dx_ptr, ValueT* val_ptr,
const int arg_size = 0,
91 const int arg_stride = 0) :
101 template <
typename S>
104 GeneralFadType::operator=(v);
111 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
116 template <
typename S>
120 GeneralFadType::operator=(x);
132 template <
typename S>
135 GeneralFadType::operator+=(x);
140 template <
typename S>
143 GeneralFadType::operator-=(x);
148 template <
typename S>
151 GeneralFadType::operator*=(x);
156 template <
typename S>
159 GeneralFadType::operator/=(x);
166 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
173 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
180 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
187 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
192 template <
typename S>
195 GeneralFadType::operator+=(x);
200 template <
typename S>
203 GeneralFadType::operator-=(x);
208 template <
typename S>
211 GeneralFadType::operator*=(x);
216 template <
typename S>
219 GeneralFadType::operator/=(x);
225 ViewFadPtr<ValueT,length,stride,BaseFadT> operator&()
const {
226 return ViewFadPtr<ValueT,length,stride,BaseFadT>(
227 this->dx_, this->
val_, this->sz_.value, this->stride_.value);
235 template <
typename T,
unsigned sl,
unsigned ss,
typename U>
236 class ViewFadPtr :
public ViewFad<T,sl,ss,U> {
243 using view_fad_type::view_fad_type;
254 #if defined(HAVE_SACADO_KOKKOS)
256 template <
typename ValT,
unsigned sl,
unsigned ss,
typename U,
typename T>
258 void atomic_add(ViewFadPtr<ValT,sl,ss,U> dst,
const Expr<T>& x) {
259 using Kokkos::atomic_add;
263 const int xsz = x.size();
264 const int sz = dst->size();
270 "Sacado error: Fad resize within atomic_add() not supported!");
272 if (xsz != sz && sz > 0 && xsz > 0)
274 "Sacado error: Fad assignment of incompatiable sizes!");
277 if (sz > 0 && xsz > 0) {
282 atomic_add(&(dst->
val()), x.val());
286 template <
typename T,
unsigned l,
unsigned s,
typename U>
287 struct BaseExpr< GeneralFad<
T,Fad::ViewStorage<T,l,s,U> > > {
292 template <
typename T,
unsigned l,
unsigned s,
typename U>
295 ExprLevel< typename ViewFad<T,l,s,U>::value_type >
::value + 1;
298 template <
typename T,
unsigned l,
unsigned s,
typename U>
305 template <
typename T,
unsigned l,
unsigned s,
typename U>
310 template <
typename T,
unsigned l,
unsigned s,
typename U>
315 template <
typename T,
unsigned l,
unsigned s,
typename U>
320 template <
typename T,
unsigned l,
unsigned s,
typename U>
Expr< GeneralFadType > ExprType
SACADO_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)
Forward-mode AD class using dynamic memory allocation and expression templates.
ViewFad< T, length, stride, new_base_fad_type > type
F::template apply< A1, A2, A3, A4, A5 >::type type
#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.
SACADO_INLINE_FUNCTION ViewFad(ValueT *v, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
mpl::apply< base_fad_type, T_for_base >::type new_base_fad_type
SACADO_INLINE_FUNCTION view_fad_type & operator*()
SACADO_INLINE_FUNCTION ViewFad(const StorageType &s)
Constructor with supplied storage s.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
FAD_NS::ViewFad< T, l, s, U >::base_expr_type type
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.
SACADO_INLINE_FUNCTION ViewFad(ValueT *dx_ptr, ValueT *val_ptr, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
SACADO_INLINE_FUNCTION ~ViewFad()
Destructor.
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
#define SACADO_INLINE_FUNCTION
GeneralFad< ValueT, StorageType > GeneralFadType