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);
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);
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>
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) {
299 atomic_add(&(dst->fastAccessDx(
i)),
x.fastAccessDx(
i));
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>
315 ExprLevel< typename ViewFad<T,l,s,U>::value_type >
::value + 1;
318 template <
typename T,
unsigned l,
unsigned s,
typename U>
325 template <
typename T,
unsigned l,
unsigned s,
typename U>
330 template <
typename T,
unsigned l,
unsigned s,
typename U>
335 template <
typename T,
unsigned l,
unsigned s,
typename U>
340 template <
typename T,
unsigned l,
unsigned s,
typename U>
#define SACADO_INLINE_FUNCTION
#define SACADO_FAD_THREAD_SINGLE
#define SACADO_FAD_DERIV_LOOP(I, SZ)
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
ViewFad< T, sl, ss, U > view_fad_type
SACADO_INLINE_FUNCTION view_fad_type & operator*()
SACADO_INLINE_FUNCTION view_fad_type * operator->()
Forward-mode AD class using dynamic memory allocation and expression templates.
GeneralFad< ValueT, StorageType > GeneralFadType
SACADO_INLINE_FUNCTION ViewFad(ValueT *v, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
Expr< GeneralFadType > ExprType
ExprType::value_type value_type
Typename of values.
BaseFadT base_fad_type
Fad type view is based on.
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
SACADO_INLINE_FUNCTION ~ViewFad()
Destructor.
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
Fad::ViewStorage< ValueT, length, stride, BaseFadT > StorageType
Base classes.
SACADO_INLINE_FUNCTION ViewFad(const StorageType &s)
Constructor with supplied storage s.
SACADO_INLINE_FUNCTION ViewFad(ValueT *dx_ptr, ValueT *val_ptr, const int arg_size=0, const int arg_stride=0)
View-specific constructor.
Fad specializations for Teuchos::BLAS wrappers.
FAD_NS::ViewFad< T, l, s, U >::base_expr_type type
Get the base Fad type from a view/expression.
Turn ViewFad into a meta-function class usable with mpl::apply.
ViewFad< T, length, stride, new_base_fad_type > type
mpl::apply< base_fad_type, T_for_base >::type new_base_fad_type
BaseExprType< T >::type T_for_base
Base template specification for whether a type is a Fad type.
Determine whether a given type is a view.
F::template apply< A1, A2, A3, A4, A5 >::type type