Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
Stokhos_MP_Vector_MaskTraits_expr_relops_tmpl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 namespace Sacado {
43  namespace MP {
44 
45  template <typename V, typename V2>
46  KOKKOS_INLINE_FUNCTION
47  Mask<V>
48  operator OPNAME (const Expr<V> &a1,
49  const Expr<V2> &a2)
50  {
51  const V& v1 = a1.derived();
52  const V2& v2 = a2.derived();
53  Mask<V> mask;
54  if (v2.hasFastAccess(v1.size())) {
55 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
56 #pragma ivdep
57 #endif
58 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
59 #pragma vector aligned
60 #endif
61 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
62 #pragma unroll
63 #endif
64  for(std::size_t i=0; i<mask.size; ++i)
65  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.fastAccessCoeff(i));
66  }
67  else{
68 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
69 #pragma ivdep
70 #endif
71 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
72 #pragma vector aligned
73 #endif
74 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
75 #pragma unroll
76 #endif
77  for(std::size_t i=0; i<mask.size; ++i)
78  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.coeff(i));
79  }
80  return mask;
81  }
82 
83  template <typename V, typename V2>
84  KOKKOS_INLINE_FUNCTION
85  Mask<V>
86  operator OPNAME (const volatile Expr<V> &a1,
87  const volatile Expr<V2> &a2)
88  {
89  const volatile V& v1 = a1.derived();
90  const volatile V2& v2 = a2.derived();
91  Mask<V> mask;
92  if (v2.hasFastAccess(v1.size())) {
93 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
94 #pragma ivdep
95 #endif
96 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
97 #pragma vector aligned
98 #endif
99 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
100 #pragma unroll
101 #endif
102  for(std::size_t i=0; i<mask.size; ++i)
103  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.fastAccessCoeff(i));
104  }
105  else{
106 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
107 #pragma ivdep
108 #endif
109 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
110 #pragma vector aligned
111 #endif
112 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
113 #pragma unroll
114 #endif
115  for(std::size_t i=0; i<mask.size; ++i)
116  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.coeff(i));
117  }
118  return mask;
119  }
120 
121  template <typename V, typename V2>
122  KOKKOS_INLINE_FUNCTION
123  Mask<V>
124  operator OPNAME (const Expr<V> &a1,
125  const volatile Expr<V2> &a2)
126  {
127  const V& v1 = a1.derived();
128  const volatile V2& v2 = a2.derived();
129  Mask<V> mask;
130  if (v2.hasFastAccess(v1.size())) {
131 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
132 #pragma ivdep
133 #endif
134 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
135 #pragma vector aligned
136 #endif
137 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
138 #pragma unroll
139 #endif
140  for(std::size_t i=0; i<mask.size; ++i)
141  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.fastAccessCoeff(i));
142  }
143  else{
144 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
145 #pragma ivdep
146 #endif
147 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
148 #pragma vector aligned
149 #endif
150 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
151 #pragma unroll
152 #endif
153  for(std::size_t i=0; i<mask.size; ++i)
154  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.coeff(i));
155  }
156  return mask;
157  }
158 
159  template <typename V, typename V2>
160  KOKKOS_INLINE_FUNCTION
161  Mask<V>
162  operator OPNAME (const volatile Expr<V> &a1,
163  const Expr<V2> &a2)
164  {
165  const volatile V& v1 = a1.derived();
166  const V2& v2 = a2.derived();
167  Mask<V> mask;
168  if (v2.hasFastAccess(v1.size())) {
169 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
170 #pragma ivdep
171 #endif
172 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
173 #pragma vector aligned
174 #endif
175 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
176 #pragma unroll
177 #endif
178  for(std::size_t i=0; i<mask.size; ++i)
179  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.fastAccessCoeff(i));
180  }
181  else{
182 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
183 #pragma ivdep
184 #endif
185 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
186 #pragma vector aligned
187 #endif
188 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
189 #pragma unroll
190 #endif
191  for(std::size_t i=0; i<mask.size; ++i)
192  mask.set(i, v1.fastAccessCoeff(i) OPNAME v2.coeff(i));
193  }
194  return mask;
195  }
196 
197  template <typename V>
198  KOKKOS_INLINE_FUNCTION
199  Mask<V>
200  operator OPNAME (const Expr<V> &a1,
201  const typename V::value_type &a2)
202  {
203  const V& v1 = a1.derived();
204  Mask<V> mask;
205 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
206 #pragma ivdep
207 #endif
208 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
209 #pragma vector aligned
210 #endif
211 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
212 #pragma unroll
213 #endif
214  for(std::size_t i=0; i<mask.size; ++i)
215  mask.set(i, v1.fastAccessCoeff(i) OPNAME a2);
216  return mask;
217  }
218 
219  template <typename V>
220  KOKKOS_INLINE_FUNCTION
221  Mask<V>
222  operator OPNAME (const volatile Expr<V> &a1,
223  const typename V::value_type &a2)
224  {
225  const volatile V& v1 = a1.derived();
226  Mask<V> mask;
227 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
228 #pragma ivdep
229 #endif
230 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
231 #pragma vector aligned
232 #endif
233 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
234 #pragma unroll
235 #endif
236  for(std::size_t i=0; i<mask.size; ++i)
237  mask.set(i, v1.fastAccessCoeff(i) OPNAME a2);
238  return mask;
239  }
240 
241  template <typename V>
242  KOKKOS_INLINE_FUNCTION
243  Mask<V>
244  operator OPNAME (const typename V::value_type &a1,
245  const Expr<V> &a2)
246  {
247  const V& v2 = a2.derived();
248  Mask<V> mask;
249 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
250 #pragma ivdep
251 #endif
252 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
253 #pragma vector aligned
254 #endif
255 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
256 #pragma unroll
257 #endif
258  for(std::size_t i=0; i<mask.size; ++i)
259  mask.set(i, a1 OPNAME v2.fastAccessCoeff(i));
260  return mask;
261  }
262 
263  template <typename V>
264  KOKKOS_INLINE_FUNCTION
265  Mask<V>
266  operator OPNAME (const typename V::value_type &a1,
267  const volatile Expr<V> &a2)
268  {
269  const volatile V& v2 = a2.derived();
270  Mask<V> mask;
271 #ifdef STOKHOS_HAVE_PRAGMA_IVDEP
272 #pragma ivdep
273 #endif
274 #ifdef STOKHOS_HAVE_PRAGMA_VECTOR_ALIGNED
275 #pragma vector aligned
276 #endif
277 #ifdef STOKHOS_HAVE_PRAGMA_UNROLL
278 #pragma unroll
279 #endif
280  for(std::size_t i=0; i<mask.size; ++i)
281  mask.set(i, a1 OPNAME v2.fastAccessCoeff(i));
282  return mask;
283  }
284  }
285 }
static const std::size_t size
KOKKOS_INLINE_FUNCTION void set(int i, bool b)
KOKKOS_INLINE_FUNCTION Vector< Stokhos::StaticFixedStorage< O, T, N, D > > OPNAME(const Vector< Stokhos::StaticFixedStorage< O, T, N, D > > &a, const Vector< Stokhos::StaticFixedStorage< O, T, N, D > > &b)