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) {
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>
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>
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>