| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Stokhos Package |
| 4 |
// |
| 5 |
// Copyright 2009 NTESS and the Stokhos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef SACADO_MP_VECTOR_SFS_HPP |
| 11 |
#define SACADO_MP_VECTOR_SFS_HPP |
| 12 |
|
| 13 |
#include "Stokhos_ConfigDefs.h" |
| 14 |
|
| 15 |
#ifdef HAVE_STOKHOS_SACADO |
| 16 |
|
| 17 |
//#include "Sacado_MP_Vector.hpp" |
| 18 |
#include "Stokhos_StaticFixedStorage.hpp" |
| 19 |
|
| 20 |
namespace Sacado { |
| 21 |
|
| 22 |
namespace MP { |
| 23 |
|
| 24 |
//! Vectorized evaluation class |
| 25 |
template <typename ordinal_t, typename value_t, int Num, typename device_t> |
| 26 |
class Vector< Stokhos::StaticFixedStorage<ordinal_t,value_t,Num,device_t> >{ |
| 27 |
public: |
| 28 |
|
| 29 |
//! Typename of storage class |
| 30 |
typedef Stokhos::StaticFixedStorage<ordinal_t,value_t,Num,device_t> Storage; |
| 31 |
typedef Storage storage_type; |
| 32 |
|
| 33 |
typedef typename storage_type::value_type value_type; |
| 34 |
typedef typename storage_type::ordinal_type ordinal_type; |
| 35 |
typedef typename storage_type::execution_space execution_space; |
| 36 |
typedef typename storage_type::pointer pointer; |
| 37 |
typedef typename storage_type::volatile_pointer volatile_pointer; |
| 38 |
typedef typename storage_type::const_pointer const_pointer; |
| 39 |
typedef typename storage_type::const_volatile_pointer const_volatile_pointer; |
| 40 |
typedef typename storage_type::reference reference; |
| 41 |
typedef typename storage_type::volatile_reference volatile_reference; |
| 42 |
typedef typename storage_type::const_reference const_reference; |
| 43 |
typedef typename storage_type::const_volatile_reference const_volatile_reference; |
| 44 |
|
| 45 |
typedef typename execution_space::memory_space memory_space; |
| 46 |
typedef typename Stokhos::MemoryTraits<memory_space> MemTraits; |
| 47 |
|
| 48 |
//! Typename of scalar's (which may be different from value_type) |
| 49 |
typedef typename ScalarType<value_type>::type scalar_type; |
| 50 |
|
| 51 |
//! Turn Vector into a meta-function class usable with mpl::apply |
| 52 |
template < class NewStorageType > |
| 53 |
struct apply { |
| 54 |
typedef Vector< NewStorageType > type; |
| 55 |
}; |
| 56 |
|
| 57 |
//! Number of arguments |
| 58 |
static const int num_args = 1; |
| 59 |
|
| 60 |
#if STOKHOS_ALIGN_MEMORY |
| 61 |
KOKKOS_INLINE_FUNCTION |
| 62 |
static void* operator new(std::size_t sz) { |
| 63 |
return MemTraits::alloc(sz); |
| 64 |
} |
| 65 |
KOKKOS_INLINE_FUNCTION |
| 66 |
static void* operator new[](std::size_t sz) { |
| 67 |
return MemTraits::alloc(sz); |
| 68 |
} |
| 69 |
KOKKOS_INLINE_FUNCTION |
| 70 |
static void* operator new(std::size_t sz, void* ptr) { |
| 71 |
return ptr; |
| 72 |
} |
| 73 |
KOKKOS_INLINE_FUNCTION |
| 74 |
static void* operator new[](std::size_t sz, void* ptr) { |
| 75 |
return ptr; |
| 76 |
} |
| 77 |
KOKKOS_INLINE_FUNCTION |
| 78 |
static void operator delete(void* ptr) { |
| 79 |
MemTraits::free(ptr); |
| 80 |
} |
| 81 |
KOKKOS_INLINE_FUNCTION |
| 82 |
static void operator delete[](void* ptr) { |
| 83 |
MemTraits::free(ptr); |
| 84 |
} |
| 85 |
KOKKOS_INLINE_FUNCTION |
| 86 |
static void operator delete(void* ptr, void*) { |
| 87 |
MemTraits::free(ptr); |
| 88 |
} |
| 89 |
KOKKOS_INLINE_FUNCTION |
| 90 |
static void operator delete[](void* ptr, void*) { |
| 91 |
MemTraits::free(ptr); |
| 92 |
} |
| 93 |
#endif |
| 94 |
|
| 95 |
//! Default constructor |
| 96 |
/*! |
| 97 |
* Sets size to 1 and first coefficient to 0 (represents a constant). |
| 98 |
*/ |
| 99 |
KOKKOS_INLINE_FUNCTION |
| 100 |
Vector() : s(1) {} |
| 101 |
|
| 102 |
//! Constructor with supplied value \c x |
| 103 |
/*! |
| 104 |
* Sets size to 1 and first coefficient to x (represents a constant). |
| 105 |
*/ |
| 106 |
KOKKOS_INLINE_FUNCTION |
| 107 |
Vector(const value_type& x) : s(1,x) {} |
| 108 |
|
| 109 |
//! View constructor |
| 110 |
/*! |
| 111 |
* Creates vector with pre-allocated data. Set \c owned = true |
| 112 |
* if this Vector should take over management of the data. |
| 113 |
*/ |
| 114 |
KOKKOS_INLINE_FUNCTION |
| 115 |
Vector(ordinal_type sz, pointer v, bool owned) : s(sz,v,owned) {} |
| 116 |
|
| 117 |
//! Constructor for creating a view out of pre-allocated memory |
| 118 |
/*! |
| 119 |
* This does not do any initialization of the coefficients. |
| 120 |
*/ |
| 121 |
KOKKOS_INLINE_FUNCTION |
| 122 |
Vector(ordinal_type sz, const value_type& x) : s(sz,x) {} |
| 123 |
|
| 124 |
//! Constructor with supplied storage |
| 125 |
KOKKOS_INLINE_FUNCTION |
| 126 |
Vector(const storage_type& ss) : s(ss) {} |
| 127 |
|
| 128 |
//! Copy constructor |
| 129 |
KOKKOS_INLINE_FUNCTION |
| 130 |
Vector(const Vector& x) : s(x.s) {} |
| 131 |
|
| 132 |
//! Copy constructor |
| 133 |
KOKKOS_INLINE_FUNCTION |
| 134 |
Vector(const volatile Vector& x) : s(x.s) {} |
| 135 |
|
| 136 |
//! Intialize from initializer_list |
| 137 |
/*! |
| 138 |
* No KOKKOS_INLINE_FUNCTION as it is not callable from the device |
| 139 |
*/ |
| 140 |
Vector(std::initializer_list<value_type> l) : s(l.size(), l.begin()) {} |
| 141 |
|
| 142 |
//! Destructor |
| 143 |
KOKKOS_INLINE_FUNCTION |
| 144 |
~Vector() {} |
| 145 |
|
| 146 |
//! Initialize coefficients to value |
| 147 |
KOKKOS_INLINE_FUNCTION |
| 148 |
void init(const value_type& v) { s.init(v); } |
| 149 |
|
| 150 |
//! Initialize coefficients to value |
| 151 |
KOKKOS_INLINE_FUNCTION |
| 152 |
void init(const value_type& v) volatile { s.init(v); } |
| 153 |
|
| 154 |
//! Initialize coefficients to an array of values |
| 155 |
KOKKOS_INLINE_FUNCTION |
| 156 |
void init(const value_type* v) { s.init(v); } |
| 157 |
|
| 158 |
//! Initialize coefficients to an array of values |
| 159 |
KOKKOS_INLINE_FUNCTION |
| 160 |
void init(const value_type* v) volatile { s.init(v); } |
| 161 |
|
| 162 |
//! Initialize coefficients from an Vector with different storage |
| 163 |
template <typename S> |
| 164 |
KOKKOS_INLINE_FUNCTION |
| 165 |
void init(const Vector<S>& v) { |
| 166 |
s.init(v.s.coeff(), v.s.size()); |
| 167 |
} |
| 168 |
|
| 169 |
//! Initialize coefficients from an Vector with different storage |
| 170 |
template <typename S> |
| 171 |
KOKKOS_INLINE_FUNCTION |
| 172 |
void init(const Vector<S>& v) volatile { |
| 173 |
s.init(v.s.coeff(), v.s.size()); |
| 174 |
} |
| 175 |
|
| 176 |
//! Load coefficients to an array of values |
| 177 |
KOKKOS_INLINE_FUNCTION |
| 178 |
void load(value_type* v) { s.load(v); } |
| 179 |
|
| 180 |
//! Load coefficients to an array of values |
| 181 |
KOKKOS_INLINE_FUNCTION |
| 182 |
void load(value_type* v) volatile { s.load(v); } |
| 183 |
|
| 184 |
//! Load coefficients into an Vector with different storage |
| 185 |
template <typename S> |
| 186 |
KOKKOS_INLINE_FUNCTION |
| 187 |
void load(Vector<S>& v) { s.load(v.s.coeff()); } |
| 188 |
|
| 189 |
//! Load coefficients into an Vector with different storage |
| 190 |
template <typename S> |
| 191 |
KOKKOS_INLINE_FUNCTION |
| 192 |
void load(Vector<S>& v) volatile { s.load(v.s.coeff()); } |
| 193 |
|
| 194 |
//! Reset size |
| 195 |
/*! |
| 196 |
* Coefficients are preserved. |
| 197 |
*/ |
| 198 |
KOKKOS_INLINE_FUNCTION |
| 199 |
void reset(ordinal_type sz_new) {} |
| 200 |
|
| 201 |
//! Reset size |
| 202 |
/*! |
| 203 |
* Coefficients are preserved. |
| 204 |
*/ |
| 205 |
KOKKOS_INLINE_FUNCTION |
| 206 |
void reset(ordinal_type sz_new) volatile {} |
| 207 |
|
| 208 |
//! Prepare vector for writing |
| 209 |
/*! |
| 210 |
* This method prepares the vector for writing through coeff() and |
| 211 |
* fastAccessCoeff() member functions. It ensures the handle for the |
| 212 |
* coefficients is not shared among any other vector. |
| 213 |
* If the handle is not shared it does nothing, so there |
| 214 |
* is no cost in calling this method in this case. If the handle is |
| 215 |
* shared and this method is not called, any changes to the coefficients |
| 216 |
* by coeff() or fastAccessCoeff() may change other vector objects. |
| 217 |
*/ |
| 218 |
KOKKOS_INLINE_FUNCTION |
| 219 |
void copyForWrite() volatile { } |
| 220 |
|
| 221 |
//! Returns whether two MP objects have the same values |
| 222 |
KOKKOS_INLINE_FUNCTION |
| 223 |
bool isEqualTo(const Vector& x) const { |
| 224 |
typedef IsEqual<value_type> IE; |
| 225 |
bool eq = true; |
| 226 |
for (ordinal_type i=0; i<this->size(); i++) |
| 227 |
eq = eq && IE::eval(x.coeff(i), this->coeff(i)); |
| 228 |
return eq; |
| 229 |
} |
| 230 |
|
| 231 |
//! Returns whether two MP objects have the same values |
| 232 |
KOKKOS_INLINE_FUNCTION |
| 233 |
bool isEqualTo(const Vector& x) const volatile { |
| 234 |
typedef IsEqual<value_type> IE; |
| 235 |
bool eq = true; |
| 236 |
for (ordinal_type i=0; i<this->size(); i++) |
| 237 |
eq = eq && IE::eval(x.coeff(i), this->coeff(i)); |
| 238 |
return eq; |
| 239 |
} |
| 240 |
|
| 241 |
/*! |
| 242 |
* @name Assignment operators |
| 243 |
*/ |
| 244 |
//@{ |
| 245 |
|
| 246 |
//! Assignment operator with constant right-hand-side |
| 247 |
KOKKOS_INLINE_FUNCTION |
| 248 |
Vector& operator=(const value_type& x) { |
| 249 |
s.init(x); |
| 250 |
return *this; |
| 251 |
} |
| 252 |
|
| 253 |
//! Assignment operator with constant right-hand-side |
| 254 |
KOKKOS_INLINE_FUNCTION |
| 255 |
/*volatile*/ Vector& operator=(const value_type& x) volatile { |
| 256 |
s.init(x); |
| 257 |
return const_cast<Vector&>(*this); |
| 258 |
} |
| 259 |
|
| 260 |
//! Assignment with Vector right-hand-side |
| 261 |
KOKKOS_INLINE_FUNCTION |
| 262 |
Vector& operator=(const Vector& x) { |
| 263 |
if (this != &x) { |
| 264 |
s = x.s; |
| 265 |
} |
| 266 |
|
| 267 |
return *this; |
| 268 |
} |
| 269 |
|
| 270 |
//! Assignment with Vector right-hand-side |
| 271 |
KOKKOS_INLINE_FUNCTION |
| 272 |
Vector& operator=(const volatile Vector& x) { |
| 273 |
if (this != &x) { |
| 274 |
s = x.s; |
| 275 |
} |
| 276 |
|
| 277 |
return *this; |
| 278 |
} |
| 279 |
|
| 280 |
//! Assignment with Vector right-hand-side |
| 281 |
KOKKOS_INLINE_FUNCTION |
| 282 |
/*volatile*/ Vector& operator=(const Vector& x) volatile { |
| 283 |
if (this != &x) { |
| 284 |
s = x.s; |
| 285 |
} |
| 286 |
|
| 287 |
return const_cast<Vector&>(*this); |
| 288 |
} |
| 289 |
|
| 290 |
//! Assignment with Vector right-hand-side |
| 291 |
KOKKOS_INLINE_FUNCTION |
| 292 |
/*volatile*/ Vector& operator=(const volatile Vector& x) volatile { |
| 293 |
if (this != &x) { |
| 294 |
s = x.s; |
| 295 |
} |
| 296 |
|
| 297 |
return const_cast<Vector&>(*this); |
| 298 |
} |
| 299 |
|
| 300 |
//@} |
| 301 |
|
| 302 |
/*! |
| 303 |
* Accessor methods |
| 304 |
*/ |
| 305 |
|
| 306 |
//! Returns storage object |
| 307 |
KOKKOS_INLINE_FUNCTION |
| 308 |
const volatile storage_type& storage() const volatile { return s; } |
| 309 |
|
| 310 |
//! Returns storage object |
| 311 |
KOKKOS_INLINE_FUNCTION |
| 312 |
const storage_type& storage() const { return s; } |
| 313 |
|
| 314 |
//! Returns storage object |
| 315 |
KOKKOS_INLINE_FUNCTION |
| 316 |
volatile storage_type& storage() volatile { return s; } |
| 317 |
|
| 318 |
//! Returns storage object |
| 319 |
KOKKOS_INLINE_FUNCTION |
| 320 |
storage_type& storage() { return s; } |
| 321 |
|
| 322 |
/*! |
| 323 |
* @name Value accessor methods |
| 324 |
*/ |
| 325 |
//@{ |
| 326 |
|
| 327 |
//! Returns value |
| 328 |
KOKKOS_INLINE_FUNCTION |
| 329 |
const_volatile_reference val() const volatile { return s[0]; } |
| 330 |
|
| 331 |
//! Returns value |
| 332 |
KOKKOS_INLINE_FUNCTION |
| 333 |
const_reference val() const { return s[0]; } |
| 334 |
|
| 335 |
//! Returns value |
| 336 |
KOKKOS_INLINE_FUNCTION |
| 337 |
volatile_reference val() volatile { return s[0]; } |
| 338 |
|
| 339 |
//! Returns value |
| 340 |
KOKKOS_INLINE_FUNCTION |
| 341 |
reference val() { return s[0]; } |
| 342 |
|
| 343 |
//@} |
| 344 |
|
| 345 |
/*! |
| 346 |
* @name Coefficient accessor methods |
| 347 |
*/ |
| 348 |
//@{ |
| 349 |
|
| 350 |
//! Returns size of vector |
| 351 |
KOKKOS_INLINE_FUNCTION |
| 352 |
static ordinal_type size() { return storage_type::size();} |
| 353 |
|
| 354 |
//! Returns true if vector has size >= sz |
| 355 |
KOKKOS_INLINE_FUNCTION |
| 356 |
static bool hasFastAccess(ordinal_type sz) { return true; } |
| 357 |
|
| 358 |
//! Returns coefficient array |
| 359 |
KOKKOS_INLINE_FUNCTION |
| 360 |
const_pointer coeff() const { return s.coeff();} |
| 361 |
|
| 362 |
//! Returns coefficient array |
| 363 |
KOKKOS_INLINE_FUNCTION |
| 364 |
const_volatile_pointer coeff() const volatile { return s.coeff();} |
| 365 |
|
| 366 |
//! Returns coefficient array |
| 367 |
KOKKOS_INLINE_FUNCTION |
| 368 |
volatile_pointer coeff() volatile { return s.coeff();} |
| 369 |
|
| 370 |
//! Returns coefficient array |
| 371 |
KOKKOS_INLINE_FUNCTION |
| 372 |
pointer coeff() { return s.coeff();} |
| 373 |
|
| 374 |
//! Returns term \c i with bounds checking |
| 375 |
KOKKOS_INLINE_FUNCTION |
| 376 |
value_type coeff(ordinal_type i) const volatile { return s[i]; } |
| 377 |
|
| 378 |
//! Returns term \c i with bounds checking |
| 379 |
KOKKOS_INLINE_FUNCTION |
| 380 |
value_type coeff(ordinal_type i) const { return s[i]; } |
| 381 |
|
| 382 |
//! Returns term \c i with bounds checking |
| 383 |
KOKKOS_INLINE_FUNCTION |
| 384 |
value_type coeff(ordinal_type i) volatile { return s[i]; } |
| 385 |
|
| 386 |
//! Returns term \c i with bounds checking |
| 387 |
KOKKOS_INLINE_FUNCTION |
| 388 |
value_type coeff(ordinal_type i) { return s[i]; } |
| 389 |
|
| 390 |
//! Returns term \c i without bounds checking |
| 391 |
KOKKOS_INLINE_FUNCTION |
| 392 |
const_volatile_reference fastAccessCoeff(ordinal_type i) const volatile { |
| 393 |
return s[i];} |
| 394 |
|
| 395 |
//! Returns term \c i without bounds checking |
| 396 |
KOKKOS_INLINE_FUNCTION |
| 397 |
const_reference fastAccessCoeff(ordinal_type i) const { |
| 398 |
return s[i];} |
| 399 |
|
| 400 |
//! Returns term \c i without bounds checking |
| 401 |
KOKKOS_INLINE_FUNCTION |
| 402 |
volatile_reference fastAccessCoeff(ordinal_type i) volatile { |
| 403 |
return s[i];} |
| 404 |
|
| 405 |
//! Returns term \c i without bounds checking |
| 406 |
KOKKOS_INLINE_FUNCTION |
| 407 |
reference fastAccessCoeff(ordinal_type i) { |
| 408 |
return s[i];} |
| 409 |
|
| 410 |
//! Returns term \c i without bounds checking |
| 411 |
KOKKOS_INLINE_FUNCTION |
| 412 |
const_volatile_reference operator[](ordinal_type i) const volatile { |
| 413 |
return s[i];} |
| 414 |
|
| 415 |
//! Returns term \c i without bounds checking |
| 416 |
KOKKOS_INLINE_FUNCTION |
| 417 |
const_reference operator[](ordinal_type i) const { |
| 418 |
return s[i];} |
| 419 |
|
| 420 |
//! Returns term \c i without bounds checking |
| 421 |
KOKKOS_INLINE_FUNCTION |
| 422 |
volatile_reference operator[](ordinal_type i) volatile { |
| 423 |
return s[i];} |
| 424 |
|
| 425 |
//! Returns term \c i without bounds checking |
| 426 |
KOKKOS_INLINE_FUNCTION |
| 427 |
reference operator[](ordinal_type i) { |
| 428 |
return s[i];} |
| 429 |
|
| 430 |
template <int i> |
| 431 |
KOKKOS_INLINE_FUNCTION |
| 432 |
value_type getCoeff() const volatile { |
| 433 |
return s.template getCoeff<i>(); } |
| 434 |
|
| 435 |
template <int i> |
| 436 |
KOKKOS_INLINE_FUNCTION |
| 437 |
value_type getCoeff() const { |
| 438 |
return s.template getCoeff<i>(); } |
| 439 |
|
| 440 |
template <int i> |
| 441 |
KOKKOS_INLINE_FUNCTION |
| 442 |
volatile_reference getCoeff() volatile { |
| 443 |
return s.template getCoeff<i>(); } |
| 444 |
|
| 445 |
template <int i> |
| 446 |
KOKKOS_INLINE_FUNCTION |
| 447 |
reference getCoeff() { |
| 448 |
return s.template getCoeff<i>(); } |
| 449 |
|
| 450 |
//! Return iterator to first element of coefficient array |
| 451 |
KOKKOS_INLINE_FUNCTION |
| 452 |
pointer begin() { return s.coeff(); } |
| 453 |
|
| 454 |
//! Return iterator to first element of coefficient array |
| 455 |
KOKKOS_INLINE_FUNCTION |
| 456 |
const_pointer begin() const { return s.coeff(); } |
| 457 |
|
| 458 |
//! Return iterator to first element of coefficient array |
| 459 |
KOKKOS_INLINE_FUNCTION |
| 460 |
volatile_pointer begin() volatile { return s.coeff(); } |
| 461 |
|
| 462 |
//! Return iterator to first element of coefficient array |
| 463 |
KOKKOS_INLINE_FUNCTION |
| 464 |
const_volatile_pointer begin() const volatile { return s.coeff(); } |
| 465 |
|
| 466 |
//! Return iterator to first element of coefficient array |
| 467 |
KOKKOS_INLINE_FUNCTION |
| 468 |
const_pointer cbegin() const { return s.coeff(); } |
| 469 |
|
| 470 |
//! Return iterator to first element of coefficient array |
| 471 |
KOKKOS_INLINE_FUNCTION |
| 472 |
const_volatile_pointer cbegin() const volatile { return s.coeff(); } |
| 473 |
|
| 474 |
//! Return iterator following last element of coefficient array |
| 475 |
KOKKOS_INLINE_FUNCTION |
| 476 |
pointer end() { return s.coeff() + s.size(); } |
| 477 |
|
| 478 |
//! Return iterator following last element of coefficient array |
| 479 |
KOKKOS_INLINE_FUNCTION |
| 480 |
const_pointer end() const { return s.coeff() + s.size(); } |
| 481 |
|
| 482 |
//! Return iterator following last element of coefficient array |
| 483 |
KOKKOS_INLINE_FUNCTION |
| 484 |
volatile_pointer end() volatile { return s.coeff() + s.size(); } |
| 485 |
|
| 486 |
//! Return iterator following last element of coefficient array |
| 487 |
KOKKOS_INLINE_FUNCTION |
| 488 |
const_volatile_pointer end() const volatile { return s.coeff() + s.size(); } |
| 489 |
|
| 490 |
//! Return iterator following last element of coefficient array |
| 491 |
KOKKOS_INLINE_FUNCTION |
| 492 |
const_pointer cend() const { return s.coeff()+ s.size(); } |
| 493 |
|
| 494 |
//! Return iterator following last element of coefficient array |
| 495 |
KOKKOS_INLINE_FUNCTION |
| 496 |
const_volatile_pointer cend() const volatile { return s.coeff()+ s.size(); } |
| 497 |
|
| 498 |
//@} |
| 499 |
|
| 500 |
/*! |
| 501 |
* @name Unary operators |
| 502 |
*/ |
| 503 |
//@{ |
| 504 |
|
| 505 |
//! Addition-assignment operator with constant right-hand-side |
| 506 |
KOKKOS_INLINE_FUNCTION |
| 507 |
Vector& operator += (const value_type& x) { |
| 508 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 509 |
#pragma ivdep |
| 510 |
#endif |
| 511 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 512 |
#pragma vector aligned |
| 513 |
#endif |
| 514 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 515 |
#pragma unroll |
| 516 |
#endif |
| 517 |
for (ordinal_type i=0; i<s.size(); i++) |
| 518 |
s[i] += x; |
| 519 |
return *this; |
| 520 |
} |
| 521 |
|
| 522 |
//! Addition-assignment operator with constant right-hand-side |
| 523 |
KOKKOS_INLINE_FUNCTION |
| 524 |
Vector& operator += (const volatile value_type& x) { |
| 525 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 526 |
#pragma ivdep |
| 527 |
#endif |
| 528 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 529 |
#pragma vector aligned |
| 530 |
#endif |
| 531 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 532 |
#pragma unroll |
| 533 |
#endif |
| 534 |
for (ordinal_type i=0; i<s.size(); i++) |
| 535 |
s[i] += x; |
| 536 |
return *this; |
| 537 |
} |
| 538 |
|
| 539 |
//! Addition-assignment operator with constant right-hand-side |
| 540 |
KOKKOS_INLINE_FUNCTION |
| 541 |
/*volatile*/ Vector& operator += (const value_type& x) volatile { |
| 542 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 543 |
#pragma ivdep |
| 544 |
#endif |
| 545 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 546 |
#pragma vector aligned |
| 547 |
#endif |
| 548 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 549 |
#pragma unroll |
| 550 |
#endif |
| 551 |
for (ordinal_type i=0; i<s.size(); i++) |
| 552 |
s[i] += x; |
| 553 |
return const_cast<Vector&>(*this); |
| 554 |
} |
| 555 |
|
| 556 |
//! Addition-assignment operator with constant right-hand-side |
| 557 |
KOKKOS_INLINE_FUNCTION |
| 558 |
/*volatile*/ Vector& operator += (const volatile value_type& x) volatile { |
| 559 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 560 |
#pragma ivdep |
| 561 |
#endif |
| 562 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 563 |
#pragma vector aligned |
| 564 |
#endif |
| 565 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 566 |
#pragma unroll |
| 567 |
#endif |
| 568 |
for (ordinal_type i=0; i<s.size(); i++) |
| 569 |
s[i] += x; |
| 570 |
return const_cast<Vector&>(*this); |
| 571 |
} |
| 572 |
|
| 573 |
//! Subtraction-assignment operator with constant right-hand-side |
| 574 |
KOKKOS_INLINE_FUNCTION |
| 575 |
Vector& operator -= (const value_type& x) { |
| 576 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 577 |
#pragma ivdep |
| 578 |
#endif |
| 579 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 580 |
#pragma vector aligned |
| 581 |
#endif |
| 582 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 583 |
#pragma unroll |
| 584 |
#endif |
| 585 |
for (ordinal_type i=0; i<s.size(); i++) |
| 586 |
s[i] -= x; |
| 587 |
return *this; |
| 588 |
} |
| 589 |
|
| 590 |
//! Subtraction-assignment operator with constant right-hand-side |
| 591 |
KOKKOS_INLINE_FUNCTION |
| 592 |
Vector& operator -= (const volatile value_type& x) { |
| 593 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 594 |
#pragma ivdep |
| 595 |
#endif |
| 596 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 597 |
#pragma vector aligned |
| 598 |
#endif |
| 599 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 600 |
#pragma unroll |
| 601 |
#endif |
| 602 |
for (ordinal_type i=0; i<s.size(); i++) |
| 603 |
s[i] -= x; |
| 604 |
return *this; |
| 605 |
} |
| 606 |
|
| 607 |
//! Subtraction-assignment operator with constant right-hand-side |
| 608 |
KOKKOS_INLINE_FUNCTION |
| 609 |
/*volatile*/ Vector& operator -= (const value_type& x) volatile { |
| 610 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 611 |
#pragma ivdep |
| 612 |
#endif |
| 613 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 614 |
#pragma vector aligned |
| 615 |
#endif |
| 616 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 617 |
#pragma unroll |
| 618 |
#endif |
| 619 |
for (ordinal_type i=0; i<s.size(); i++) |
| 620 |
s[i] -= x; |
| 621 |
return const_cast<Vector&>(*this); |
| 622 |
} |
| 623 |
|
| 624 |
//! Subtraction-assignment operator with constant right-hand-side |
| 625 |
KOKKOS_INLINE_FUNCTION |
| 626 |
/*volatile*/ Vector& operator -= (const volatile value_type& x) volatile { |
| 627 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 628 |
#pragma ivdep |
| 629 |
#endif |
| 630 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 631 |
#pragma vector aligned |
| 632 |
#endif |
| 633 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 634 |
#pragma unroll |
| 635 |
#endif |
| 636 |
for (ordinal_type i=0; i<s.size(); i++) |
| 637 |
s[i] -= x; |
| 638 |
return const_cast<Vector&>(*this); |
| 639 |
} |
| 640 |
|
| 641 |
//! Multiplication-assignment operator with constant right-hand-side |
| 642 |
KOKKOS_INLINE_FUNCTION |
| 643 |
Vector& operator *= (const value_type& x) { |
| 644 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 645 |
#pragma ivdep |
| 646 |
#endif |
| 647 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 648 |
#pragma vector aligned |
| 649 |
#endif |
| 650 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 651 |
#pragma unroll |
| 652 |
#endif |
| 653 |
for (ordinal_type i=0; i<s.size(); i++) |
| 654 |
s[i] *= x; |
| 655 |
return *this; |
| 656 |
} |
| 657 |
|
| 658 |
//! Multiplication-assignment operator with constant right-hand-side |
| 659 |
KOKKOS_INLINE_FUNCTION |
| 660 |
Vector& operator *= (const volatile value_type& x) { |
| 661 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 662 |
#pragma ivdep |
| 663 |
#endif |
| 664 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 665 |
#pragma vector aligned |
| 666 |
#endif |
| 667 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 668 |
#pragma unroll |
| 669 |
#endif |
| 670 |
for (ordinal_type i=0; i<s.size(); i++) |
| 671 |
s[i] *= x; |
| 672 |
return *this; |
| 673 |
} |
| 674 |
|
| 675 |
//! Multiplication-assignment operator with constant right-hand-side |
| 676 |
KOKKOS_INLINE_FUNCTION |
| 677 |
/*volatile*/ Vector& operator *= (const value_type& x) volatile { |
| 678 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 679 |
#pragma ivdep |
| 680 |
#endif |
| 681 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 682 |
#pragma vector aligned |
| 683 |
#endif |
| 684 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 685 |
#pragma unroll |
| 686 |
#endif |
| 687 |
for (ordinal_type i=0; i<s.size(); i++) |
| 688 |
s[i] *= x; |
| 689 |
return const_cast<Vector&>(*this); |
| 690 |
} |
| 691 |
|
| 692 |
//! Multiplication-assignment operator with constant right-hand-side |
| 693 |
KOKKOS_INLINE_FUNCTION |
| 694 |
/*volatile*/ Vector& operator *= (const volatile value_type& x) volatile { |
| 695 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 696 |
#pragma ivdep |
| 697 |
#endif |
| 698 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 699 |
#pragma vector aligned |
| 700 |
#endif |
| 701 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 702 |
#pragma unroll |
| 703 |
#endif |
| 704 |
for (ordinal_type i=0; i<s.size(); i++) |
| 705 |
s[i] *= x; |
| 706 |
return const_cast<Vector&>(*this); |
| 707 |
} |
| 708 |
|
| 709 |
//! Division-assignment operator with constant right-hand-side |
| 710 |
KOKKOS_INLINE_FUNCTION |
| 711 |
Vector& operator /= (const value_type& x) { |
| 712 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 713 |
#pragma ivdep |
| 714 |
#endif |
| 715 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 716 |
#pragma vector aligned |
| 717 |
#endif |
| 718 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 719 |
#pragma unroll |
| 720 |
#endif |
| 721 |
for (ordinal_type i=0; i<s.size(); i++) |
| 722 |
s[i] /= x; |
| 723 |
return *this; |
| 724 |
} |
| 725 |
|
| 726 |
//! Division-assignment operator with constant right-hand-side |
| 727 |
KOKKOS_INLINE_FUNCTION |
| 728 |
Vector& operator /= (const volatile value_type& x) { |
| 729 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 730 |
#pragma ivdep |
| 731 |
#endif |
| 732 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 733 |
#pragma vector aligned |
| 734 |
#endif |
| 735 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 736 |
#pragma unroll |
| 737 |
#endif |
| 738 |
for (ordinal_type i=0; i<s.size(); i++) |
| 739 |
s[i] /= x; |
| 740 |
return *this; |
| 741 |
} |
| 742 |
|
| 743 |
//! Division-assignment operator with constant right-hand-side |
| 744 |
KOKKOS_INLINE_FUNCTION |
| 745 |
/*volatile*/ Vector& operator /= (const value_type& x) volatile { |
| 746 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 747 |
#pragma ivdep |
| 748 |
#endif |
| 749 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 750 |
#pragma vector aligned |
| 751 |
#endif |
| 752 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 753 |
#pragma unroll |
| 754 |
#endif |
| 755 |
for (ordinal_type i=0; i<s.size(); i++) |
| 756 |
s[i] /= x; |
| 757 |
return const_cast<Vector&>(*this); |
| 758 |
} |
| 759 |
|
| 760 |
//! Division-assignment operator with constant right-hand-side |
| 761 |
KOKKOS_INLINE_FUNCTION |
| 762 |
/*volatile*/ Vector& operator /= (const volatile value_type& x) volatile { |
| 763 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 764 |
#pragma ivdep |
| 765 |
#endif |
| 766 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 767 |
#pragma vector aligned |
| 768 |
#endif |
| 769 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 770 |
#pragma unroll |
| 771 |
#endif |
| 772 |
for (ordinal_type i=0; i<s.size(); i++) |
| 773 |
s[i] /= x; |
| 774 |
return const_cast<Vector&>(*this); |
| 775 |
} |
| 776 |
|
| 777 |
//! Addition-assignment operator with Vector right-hand-side |
| 778 |
KOKKOS_INLINE_FUNCTION |
| 779 |
Vector& operator += (const Vector& x) { |
| 780 |
#ifdef STOKHOS_HAVE_PRAGMA_IVDEP |
| 781 |
#pragma ivdep |
| 782 |
#endif |
| 783 |
#ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED |
| 784 |
#pragma vector aligned |
| 785 |
#endif |
| 786 |
#ifdef STOKHOS_HAVE_PRAGMA_UNROLL |
| 787 |
#pragma unroll |
| 788 |
#endif |
| 789 |
for (ordinal_type i=0; i<s.size(); i++) |
| 790 |
s[i] += x.fastAccessCoeff(i); |
| 791 |
return *this; |
| 792 |
} |
| 793 |
|
| 794 |
//! Addition-assignment operator with Vector right-hand-side |
| 795 |
KOKKOS_INLINE_FUNCTION |
| 796 |
Vector& operator += (const volatile Vector& x) { |
| 797 |
*this = *this + x; |
| 798 |
return *this; |
| 799 |
} |
| 800 |
|
| 801 |
//! Addition-assignment operator with Vector right-hand-side |
| 802 |
KOKKOS_INLINE_FUNCTION |
| 803 |
/*volatile*/ Vector& operator += (const Vector& x) volatile { |
| 804 |
*this = *this + x; |
| 805 |
return const_cast<Vector&>(*this); |
| 806 |
} |
| 807 |
|
| 808 |
//! Addition-assignment operator with Vector right-hand-side |
| 809 |
KOKKOS_INLINE_FUNCTION |
| 810 |
/*volatile*/ Vector& operator += (const volatile Vector& x) volatile { |
| 811 |
*this = *this + x; |
| 812 |
return const_cast<Vector&>(*this); |
| 813 |
} |
| 814 |
|
| 815 |
//! Subtraction-assignment operator with Vector right-hand-side |
| 816 |
KOKKOS_INLINE_FUNCTION |
| 817 |
Vector& operator -= (const Vector& x) { |
| 818 |
*this = *this - x; |
| 819 |
return *this; |
| 820 |
} |
| 821 |
|
| 822 |
//! Subtraction-assignment operator with Vector right-hand-side |
| 823 |
KOKKOS_INLINE_FUNCTION |
| 824 |
Vector& operator -= (const volatile Vector& x) { |
| 825 |
*this = *this - x; |
| 826 |
return *this; |
| 827 |
} |
| 828 |
|
| 829 |
//! Subtraction-assignment operator with Vector right-hand-side |
| 830 |
KOKKOS_INLINE_FUNCTION |
| 831 |
/*volatile*/ Vector& operator -= (const Vector& x) volatile { |
| 832 |
*this = *this - x; |
| 833 |
return const_cast<Vector&>(*this); |
| 834 |
} |
| 835 |
|
| 836 |
//! Subtraction-assignment operator with Vector right-hand-side |
| 837 |
KOKKOS_INLINE_FUNCTION |
| 838 |
/*volatile*/ Vector& operator -= (const volatile Vector& x) volatile { |
| 839 |
*this = *this - x; |
| 840 |
return const_cast<Vector&>(*this); |
| 841 |
} |
| 842 |
|
| 843 |
//! Multiplication-assignment operator with Vector right-hand-side |
| 844 |
KOKKOS_INLINE_FUNCTION |
| 845 |
Vector& operator *= (const Vector& x) { |
| 846 |
*this = *this * x; |
| 847 |
return *this; |
| 848 |
} |
| 849 |
|
| 850 |
//! Multiplication-assignment operator with Vector right-hand-side |
| 851 |
KOKKOS_INLINE_FUNCTION |
| 852 |
Vector& operator *= (const volatile Vector& x) { |
| 853 |
*this = *this * x; |
| 854 |
return *this; |
| 855 |
} |
| 856 |
|
| 857 |
//! Multiplication-assignment operator with Vector right-hand-side |
| 858 |
KOKKOS_INLINE_FUNCTION |
| 859 |
/*volatile*/ Vector& operator *= (const Vector& x) volatile { |
| 860 |
*this = *this * x; |
| 861 |
return const_cast<Vector&>(*this); |
| 862 |
} |
| 863 |
|
| 864 |
//! Multiplication-assignment operator with Vector right-hand-side |
| 865 |
KOKKOS_INLINE_FUNCTION |
| 866 |
/*volatile*/ Vector& operator *= (const volatile Vector& x) volatile { |
| 867 |
*this = *this * x; |
| 868 |
return const_cast<Vector&>(*this); |
| 869 |
} |
| 870 |
|
| 871 |
//! Division-assignment operator with Vector right-hand-side |
| 872 |
KOKKOS_INLINE_FUNCTION |
| 873 |
Vector& operator /= (const Vector& x) { |
| 874 |
*this = *this / x; |
| 875 |
return *this; |
| 876 |
} |
| 877 |
|
| 878 |
//! Division-assignment operator with Vector right-hand-side |
| 879 |
KOKKOS_INLINE_FUNCTION |
| 880 |
Vector& operator /= (const volatile Vector& x) { |
| 881 |
*this = *this / x; |
| 882 |
return *this; |
| 883 |
} |
| 884 |
|
| 885 |
//! Division-assignment operator with Vector right-hand-side |
| 886 |
KOKKOS_INLINE_FUNCTION |
| 887 |
/*volatile*/ Vector& operator /= (const Vector& x) volatile { |
| 888 |
*this = *this / x; |
| 889 |
return const_cast<Vector&>(*this); |
| 890 |
} |
| 891 |
|
| 892 |
//! Division-assignment operator with Vector right-hand-side |
| 893 |
KOKKOS_INLINE_FUNCTION |
| 894 |
/*volatile*/ Vector& operator /= (const volatile Vector& x) volatile { |
| 895 |
*this = *this / x; |
| 896 |
return const_cast<Vector&>(*this); |
| 897 |
} |
| 898 |
|
| 899 |
//! Prefix ++ |
| 900 |
KOKKOS_INLINE_FUNCTION |
| 901 |
Vector& operator++() { |
| 902 |
for (ordinal_type i=0; i<s.size(); i++) |
| 903 |
++(s[i]); |
| 904 |
return *this; |
| 905 |
} |
| 906 |
|
| 907 |
//! Prefix ++ |
| 908 |
KOKKOS_INLINE_FUNCTION |
| 909 |
volatile Vector& operator++() volatile { |
| 910 |
for (ordinal_type i=0; i<s.size(); i++) |
| 911 |
++(s[i]); |
| 912 |
return *this; |
| 913 |
} |
| 914 |
|
| 915 |
//! Postfix ++ |
| 916 |
KOKKOS_INLINE_FUNCTION |
| 917 |
Vector operator++(int) { |
| 918 |
Vector tmp(*this); |
| 919 |
++(*this); |
| 920 |
return tmp; |
| 921 |
} |
| 922 |
|
| 923 |
//! Postfix ++ |
| 924 |
KOKKOS_INLINE_FUNCTION |
| 925 |
Vector operator++(int) volatile { |
| 926 |
Vector tmp(*this); |
| 927 |
++(*this); |
| 928 |
return tmp; |
| 929 |
} |
| 930 |
|
| 931 |
//! Prefix -- |
| 932 |
KOKKOS_INLINE_FUNCTION |
| 933 |
Vector& operator--() { |
| 934 |
for (ordinal_type i=0; i<s.size(); i++) |
| 935 |
--(s[i]); |
| 936 |
return *this; |
| 937 |
} |
| 938 |
|
| 939 |
//! Prefix -- |
| 940 |
KOKKOS_INLINE_FUNCTION |
| 941 |
volatile Vector& operator--() volatile { |
| 942 |
for (ordinal_type i=0; i<s.size(); i++) |
| 943 |
--(s[i]); |
| 944 |
return *this; |
| 945 |
} |
| 946 |
|
| 947 |
//! Postfix -- |
| 948 |
KOKKOS_INLINE_FUNCTION |
| 949 |
Vector operator--(int) { |
| 950 |
Vector tmp(*this); |
| 951 |
--(*this); |
| 952 |
return tmp; |
| 953 |
} |
| 954 |
|
| 955 |
//! Postfix -- |
| 956 |
KOKKOS_INLINE_FUNCTION |
| 957 |
Vector operator--(int) volatile { |
| 958 |
Vector tmp(*this); |
| 959 |
--(*this); |
| 960 |
return tmp; |
| 961 |
} |
| 962 |
|
| 963 |
//@} |
| 964 |
|
| 965 |
KOKKOS_INLINE_FUNCTION |
| 966 |
std::string name() const volatile { return "x"; } |
| 967 |
|
| 968 |
protected: |
| 969 |
|
| 970 |
Storage s; |
| 971 |
|
| 972 |
}; // class Vector |
| 973 |
|
| 974 |
//------------------------------------------------------------------------ |
| 975 |
//------------------------------------------------------------------------ |
| 976 |
|
| 977 |
} // namespace MP |
| 978 |
|
| 979 |
} // namespace Sacado |
| 980 |
|
| 981 |
#include "Sacado_MP_Vector_SFS_ops.hpp" |
| 982 |
|
| 983 |
#endif // HAVE_STOKHOS_SACADO |
| 984 |
|
| 985 |
#endif // SACADO_MP_VECTOR_SFS_HPP |