OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
AssignDefs.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef ASSIGN_DEFS_H
12 #define ASSIGN_DEFS_H
13 
14 // include files
15 #include "Field/AssignTags.h"
16 
17 // forward declarations
18 template<class T, unsigned int D> class BareField;
19 template<class T, unsigned int D> class BareFieldIterator;
20 template<class T, unsigned int D> class IndexedBareFieldIterator;
21 
23 //
24 // Do any of the terms in an expression have an ID equal to a given one?
25 //
27 
28 template<class T, class C, unsigned int D>
29 inline bool
31 {
32  return p.GetBareField().get_Id() == (unsigned int) s.fID;
33 }
34 
35 template<class T, class C, unsigned int D>
36 inline bool
38 {
39  return p.GetBareField().get_Id() == (unsigned int) s.fID;
40 }
41 
42 //
43 // If there is an index in the expr, it can't have the same ID.
44 //
45 template<class C>
46 inline bool
48 {
49  return false;
50 }
51 
52 //
53 // If there is a scalar in the expr, it can't have the same ID.
54 //
55 template<class T, class C>
56 inline bool
58 {
59  return false;
60 }
61 
63 //
64 // Plugbase.
65 //
67 
68 template<unsigned D>
69 struct PlugBase
70 {
72  PlugBase( const NDIndex<D>& domain ) : Domain(domain) {}
73  typedef bool PETE_Return_t;
74 };
75 
76 //
77 // Plug into an IndexedBareField.
78 //
79 template<class T, unsigned int D1, unsigned D2, class C>
80 inline bool
82 {
83  return p.plugBase(f.Domain);
84 }
85 
86 //
87 // plugbase
88 //
89 template<class C, unsigned D>
90 inline bool
92 {
93  //cout << "Plugging " << f.Domain << endl;
94  //cout << " p.id() = " << p.id() << endl;
95  for (unsigned d=0; d<D; ++d)
96  {
97  //cout << " d=" << d << ", id=" << f.Domain[d].id() << endl;
98  if ( p.id() == f.Domain[d].id() )
99  {
100  //cout << " matched." << endl;
101  return p.plugBase( f.Domain[d], d );
102  }
103  }
104  return false;
105 }
106 
107 //
108 // just return true for scalar
109 //
110 template<class T, class C, unsigned D>
111 inline bool
113 {
114  return true;
115 }
116 
118 //
119 // Ask each term if it is compressed.
120 //
122 
123 template<class T, class C, unsigned int D>
124 inline bool
126 {
127  return p.IsCompressed();
128 }
129 
130 template<class T, class C, unsigned int D>
131 inline bool
133 {
134  return p.IsCompressed();
135 }
136 
137 //
138 // Indexes are never compressed.
139 //
140 template<class C>
141 inline bool
143 {
144  return false;
145 }
146 
147 //
148 // Scalars are always compressed.
149 //
150 template<class T, class C>
151 inline bool
153 {
154  return true;
155 }
156 
158 //
159 // Evaluation functors.
160 // First, no arguments.
161 //
163 
164 template<class T, unsigned int D>
165 inline T&
167 {
168  return *p;
169 }
170 
171 //
172 // Evaluate an Index.
173 //
174 inline int
176 {
177  return *p;
178 }
179 
181 //
182 // Evaluation functors.
183 // One argument.
184 //
186 
187 template<class T, unsigned int D>
188 inline T&
190 {
191  return p.offset(e.I);
192 }
193 
194 template<class T, unsigned int D>
195 inline T&
197 {
198  return p.unit_offset(e.I);
199 }
200 
201 //
202 // Evaluate an Index.
203 //
204 inline int
206 {
207  return p.offset(e.I);
208 }
209 
210 //
211 // Evaluate a scalar.
212 //
213 template<class T>
214 inline T
216 {
217  return T(p);
218 }
219 
221 //
222 // Evaluation functors.
223 // Two arguments.
224 //
226 
227 template<class T, unsigned int D>
228 inline T&
230 {
231  return p.offset(e.I, e.J);
232 }
233 
234 template<class T, unsigned int D>
235 inline T&
237 {
238  return p.unit_offset(e.I, e.J);
239 }
240 
241 //
242 // Evaluate an Index.
243 //
244 inline int
246 {
247  return p.offset(e.I, e.J);
248 }
249 
250 //
251 // Evaluate a scalar.
252 //
253 template<class T>
254 inline T
256 {
257  return T(p);
258 }
259 
261 //
262 // Evaluation functors.
263 // Three arguments.
264 //
266 
267 template<class T, unsigned int D>
268 inline T&
270 {
271  return p.offset(e.I, e.J, e.K);
272 }
273 
274 template<class T, unsigned int D>
275 inline T&
277 {
278  return p.offset(e.I, e.J, e.K);
279 }
280 
281 //
282 // Evaluate an Index.
283 //
284 inline int
286 {
287  return p.offset(e.I, e.J, e.K);
288 }
289 
290 //
291 // Evaluate a scalar.
292 //
293 template<class T>
294 inline T
296 {
297  return T(p);
298 }
299 
301 //
302 // Get started in a given LField
303 //
305 
306 template<class T, class C, unsigned int D>
307 inline int
309 {
310  p.beginLField();
311  return 0;
312 }
313 
314 //
315 // ignore this signal
316 //
317 template<class T, class C>
318 inline int
320 {
321  return 0;
322 }
323 
325 //
326 // Go on to the next LField.
327 //
329 
330 template<class T, class C, unsigned int D>
331 inline int
333 {
334  p.nextLField();
335  return 0;
336 }
337 
338 //
339 // If there is a scalar in the expr, it ignores this signal.
340 //
341 template<class T, class C>
342 inline int
344 {
345  return 0;
346 }
347 
349 //
350 // Step in some dimension.
351 //
353 
354 template<class T, class C, unsigned int D>
355 inline int
357 {
358  p.step(s.D);
359  return 0;
360 }
361 
362 template<class T, class C, unsigned int D>
363 inline int
365 {
366  p.step(s.D);
367  return 0;
368 }
369 
370 template<class T, class C, unsigned int D>
371 inline int
373 {
374  p.step(s.D);
375  return 0;
376 }
377 
378 //
379 // Step along an Index.
380 //
381 template<class C>
382 inline int
384 {
385  p.step(s.D);
386  return 0;
387 }
388 
389 //
390 // scalar ignores step functor
391 //
392 template<class T, class C>
393 inline int
395 {
396  return 0;
397 }
398 
400 //
401 // Rewind in some dimension.
402 //
404 
405 template<class T, class C, unsigned int D>
406 inline int
408 {
409  p.rewind(s.D);
410  return 0;
411 }
412 
413 
414 template<class T, class C, unsigned int D>
415 inline int
417 {
418  p.rewind(s.D);
419  return 0;
420 }
421 
422 
423 template<class T, class C, unsigned int D>
424 inline int
426 {
427  p.rewind(s.D);
428  return 0;
429 }
430 
431 //
432 // Rewind an Index.
433 //
434 template<class C>
435 inline int
437 {
438  p.rewind(s.D);
439  return 0;
440 }
441 
442 //
443 // scalar ignores rewind functor
444 //
445 template<class T, class C>
446 inline int
448 {
449  return 0;
450 }
451 
453 //
454 // Count the number of elements in an expression.
455 //
457 
458 template<class T, class C, unsigned int D>
459 inline int
461 {
462  int size = p.size(0);
463  for (unsigned int i=1; i<D; ++i)
464  size *= p.size(i);
465  return size;
466 }
467 
468 template<class T, class C, unsigned int D>
469 inline int
471 {
472  BareField<T,D>& f = p.GetBareField();
473  int n = 0;
474  for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf)
475  n += (*lf).second->getOwned().size();
476  return n;
477 }
478 
479 template<class T, class C, unsigned int D>
480 inline int
482 {
483  BareField<T,D>& f = p.GetBareField();
484  int n = 0;
485  for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf) {
486  const NDIndex<D>& domain = (*lf).second->getOwned();
487  if ( p.getDomain().touches(domain) )
488  n += p.getDomain().intersect(domain).size();
489  }
490  return n;
491 }
492 
494 //
495 // Increment the pointers in an expression.
496 //
498 
499 template<class T, class C, unsigned int D>
500 inline int
502 {
503  ++p;
504  return 0;
505 }
506 
507 
508 template<class T, class C, unsigned int D>
509 inline int
511 {
512  ++p;
513  return 0;
514 }
515 
516 
517 template<class T, class C, unsigned int D>
518 inline int
520 {
521  ++p;
522  return 0;
523 }
524 
526 //
527 // Find out if all the BrickIterators in an expression
528 // have unit stride in the first dimension.
529 //
531 
532 template<class T, class C, unsigned int D>
533 inline bool
535 {
536  return iter.Stride(0) == 1;
537 }
538 
539 template<class T, class C, unsigned int D>
540 inline bool
542 {
543  return iter.Stride(0) == 1;
544 }
545 
546 template<class T, class C, unsigned int D>
547 inline bool
549 {
550  return iter.Stride(0) == 1;
551 }
552 
553 template<class C>
554 inline bool
556 {
557  return true;
558 }
559 
560 template<class T, class C>
561 inline bool
563 {
564  return true;
565 }
566 
568 //
569 // Ask each term to fill guard cells and compress itself
570 //
572 
573 template<class T, class C, unsigned int D, unsigned int D1, class T1>
574 inline int
576  const FillGCIfNecessaryTag<D1,T1> &f, C)
577 {
578  p.FillGCIfNecessary(*(f.bf_m));
579  return 0;
580 }
581 
582 template<class T, class C, unsigned int D, unsigned int D1, class T1>
583 inline int
585  const FillGCIfNecessaryTag<D1,T1> &, C)
586 {
587  return 0;
588 }
589 
590 template<class T, class C, unsigned int D, class T1>
591 inline int
593 {
594  return 0;
595 }
596 
597 template<class C, unsigned int D, class T1>
598 inline int
600 {
601  return 0;
602 }
603 
604 #endif // ASSIGN_DEFS_H
605 
606 /***************************************************************************
607  * $RCSfile: AssignDefs.h,v $ $Author: adelmann $
608  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
609  * IPPL_VERSION_ID: $Id: AssignDefs.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
610  ***************************************************************************/
ac_id_larray::iterator iterator_if
Definition: BareField.h:91
constexpr double e
The value of .
Definition: Physics.h:40
Definition: rbendmap.h:8
T & offset(int i) const
void FillGCIfNecessary(const BareField< T1, D1 > &lhs) const
bool PETE_Return_t
Definition: AssignDefs.h:73
const BareField< T1, D > * bf_m
Definition: AssignTags.h:141
iterator_if end_if()
Definition: BareField.h:100
int Stride(int i) const
void rewind(unsigned d)
void step(unsigned d)
Definition: Index.h:365
int id() const
Definition: Index.h:383
int size(unsigned d) const
Definition: BrickIterator.h:48
Definition: FFT.h:30
unsigned D
Definition: AssignTags.h:111
void step(unsigned d)
int offset() const
Definition: Index.h:346
unsigned D
Definition: AssignTags.h:104
bool plugBase(const NDIndex< D2 > &i)
const NDIndex< Dim > & getDomain() const
void rewind(unsigned d)
Definition: Index.h:370
bool IsCompressed() const
bool plugBase(const Index &i, unsigned d=0)
Definition: Index.h:375
bool for_each(const BareFieldIterator< T, D > &p, SameFieldID s, C)
Definition: AssignDefs.h:30
NDIndex< D > Domain
Definition: AssignDefs.h:71
iterator_if begin_if()
Definition: BareField.h:99
T & unit_offset(int i) const
PlugBase(const NDIndex< D > &domain)
Definition: AssignDefs.h:72
BareField< T, Dim > & GetBareField()