OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BrickExpression.hpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  * This program was prepared by PSI.
7  * All rights in the program are reserved by PSI.
8  * Neither PSI nor the author(s)
9  * makes any warranty, express or implied, or assumes any liability or
10  * responsibility for the use of this software
11  *
12  * Visit www.amas.web.psi for more details
13  *
14  ***************************************************************************/
15 
16 // -*- C++ -*-
17 /***************************************************************************
18  *
19  * The IPPL Framework
20  *
21  *
22  * Visit http://people.web.psi.ch/adelmann/ for more details
23  *
24  ***************************************************************************/
25 
26 // include files
27 
28 
29 
31 // BrickExpLoop::apply member functions
32 
33 template<class LHS, class RHS, class OP, unsigned Dim>
35 {
36 public:
37  static inline void
38  apply(LHS& __restrict__ Lhs, RHS& __restrict__ Rhs, OP Op)
39  {
40  int n0 = Lhs.size(0);
41  int n1 = Lhs.size(1);
42  int n2 = Lhs.size(2);
43  if ( (n0>0)&&(n1>0)&&(n2>0) )
44  {
45  unsigned d;
46  do
47  {
48  for (int i2=0; i2<n2; ++i2)
49  for (int i1=0; i1<n1; ++i1)
50  for (int i0=0; i0<n0; ++i0)
51  PETE_apply(Op,Lhs.offset(i0,i1,i2),
52  for_each(Rhs,EvalFunctor_3(i0,i1,i2)));
53 
54  for (d=3; d<Dim; ++d)
55  {
56  Lhs.step(d);
57  // #pragma inline here
59  if ( ! Lhs.done(d) )
60  break;
61  Lhs.rewind(d);
62  // #pragma inline here
64  }
65  } while (d<Dim);
66  }
67  }
68 };
69 
70 
72 //a specialization of BrickExpLoop::apply for a 1D loop evaluation
73 template<class LHS, class RHS, class OP>
74 class BrickExpLoop<LHS,RHS,OP,1U>
75 {
76 public:
77  static inline void apply(LHS& __restrict__ Lhs, RHS& __restrict__ Rhs, OP Op)
78  {
79  int n0 = Lhs.size(0);
80  for (int i0=0; i0<n0; ++i0) {
81  PETE_apply(Op,Lhs.offset(i0),for_each(Rhs,EvalFunctor_1(i0)));
82  }
83  }
84 };
85 
87 //a specialization of BrickExpLoops::apply for a 2D loop evaluation
88 template<class LHS, class RHS, class OP>
89 class BrickExpLoop<LHS,RHS,OP,2U>
90 {
91 public:
92  static inline void
93  apply(LHS& __restrict__ Lhs, RHS& __restrict__ Rhs, OP Op)
94  {
95  int n0 = Lhs.size(0);
96  int n1 = Lhs.size(1);
97  for (int i1=0; i1<n1; ++i1)
98  for (int i0=0; i0<n0; ++i0)
99  PETE_apply(Op,Lhs.offset(i0,i1),
100  for_each(Rhs,EvalFunctor_2(i0,i1)));
101  }
102 };
103 
104 
106 //a specialization of BrickExpLoops::apply for a 3D loop evaluation
107 template<class LHS, class RHS, class OP>
108 class BrickExpLoop<LHS,RHS,OP,3U>
109 {
110 public:
111  static inline void
112  apply(LHS& __restrict__ Lhs, RHS& __restrict__ Rhs, OP Op)
113  {
114  int n0 = Lhs.size(0);
115  int n1 = Lhs.size(1);
116  int n2 = Lhs.size(2);
117  for (int i2=0; i2<n2; ++i2)
118  for (int i1=0; i1<n1; ++i1)
119  for (int i0=0; i0<n0; ++i0)
120  PETE_apply(Op,Lhs.offset(i0,i1,i2),
121  for_each(Rhs,EvalFunctor_3(i0,i1,i2)));
122  }
123 };
124 
126 // BrickExpression::apply - just use BrickExpLoop
127 // ada: remove restrict from apply to make g++ 2.95.3 happy
128 template<unsigned Dim, class LHS, class RHS, class OP>
130 {
131 
132 
133 
134  // #pragma inline here
136 }
137 
138 /***************************************************************************
139  * $RCSfile: BrickExpression.cpp,v $ $Author: adelmann $
140  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
141  * IPPL_VERSION_ID: $Id: BrickExpression.cpp,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
142  ***************************************************************************/
void PETE_apply(const OpPeriodic< T > &e, T &a, const T &b)
Definition: BCond.hpp:373
static void apply(LHS &__restrict__ Lhs, RHS &__restrict__ Rhs, OP Op)
virtual void apply()
static void apply(LHS &__restrict__ Lhs, RHS &__restrict__ Rhs, OP Op)
static void apply(LHS &__restrict__ Lhs, RHS &__restrict__ Rhs, OP Op)
static void apply(LHS &__restrict__ Lhs, RHS &__restrict__ Rhs, OP Op)
const unsigned Dim
bool for_each(const BareFieldIterator< T, D > &p, SameFieldID s, C)
Definition: AssignDefs.h:30