OpMask.h File Reference

These classes implement the two argument where. More...

#include "PETE/PETE.h"

Include dependency graph for OpMask.h:

This graph shows which files directly or indirectly include this file:


Classes

struct  MaskAssign< T >
struct  OpMask< Op >
struct  BinaryReturn< T1, T2, OpMask< Op > >
struct  ReductionTraits< OpMask< Op >, T >
struct  WhereMask
struct  BinaryReturn< T1, T2, WhereMask >
struct  ForEach< BinaryNode< WhereMask, A, B >, FTag, OpCombine >

Detailed Description

These classes implement the two argument where.

The expression,

a += where(f, b);

implements the following code:

 for (loc in domain)
 {
   if (f(loc))
     a(loc) += b(loc);
 }
 

To implement this behaviour, the expression is translated to the tree:

        OpMask<OpAddAssign>
           /        |
          A        WhereMask
                     /    |
                    F     B
 

ForEach is specialized for WhereMask to evaluate B only if F is true. The result is returned in a MaskAssign<B::Element_t>, which contains the bool from F and the value from B if F is true. OpMask applies the operator Op to the result from A and B if F is true.

This design has the advantage that A is on the LHS and F and B are on the RHS, so we apply write locks to A and read locks to F and B. Another approach is the tree OpMask(F, OpAddAssign(A,B)), which would lead to complicated interpretation of expressions. Pooma r1 used the implementation OpAddAssign(A, OpWhere(F, B)), which meant that operators needed specializations to deal with the MaskAssign<T> object.

WhereProxy wraps f and b so that the assignment operator can convert it to the WhereMask object that goes on the RHS and convert the operator into OpMask.


Generated on Wed Mar 16 06:18:16 2011 for FreePOOMA by  doxygen 1.5.9