Polaris: affine.h File Reference

affine.h File Reference

Go to the source code of this file.

Functions

bool is_affine (Expression &f, set< Symbol * > &args, vector< Symbol * > &vargs, vector< Expression * > &vcoeffs)
 Returns true if 'f' can be proven to be an affine function of given args. All other symbols in f are assumed to be invariant with respect to all args.
bool check_scalars_affine (List< Expression > &elist, ProgramUnit &pgm, DoStmt &loop, vector< vector< Symbol * > > &vargs, vector< vector< Expression * > > &vcoeffs)
 Return true if all variables referenced are integer scalars, and the expression is affine with respect to all loop variants.


Function Documentation

bool is_affine Expression f,
set< Symbol * > &  args,
vector< Symbol * > &  vargs,
vector< Expression * > &  vcoeffs
 

Returns true if 'f' can be proven to be an affine function of given args. All other symbols in f are assumed to be invariant with respect to all args.

We prove that ${i=1,N}{f(x_i+y_i)} = f(x) + f(y) + f(0)$, where x, y, and 0 are vectors [1:N]. This implies that 'f' is affine.

cerr<<"\nEnter is_affine with "<<f<<" and "; for(set<Symbol*>::iterator sit=args.begin(); sit!=args.end(); ++sit){ cerr<<(*sit)->name_ref()<<", "; }

... this way they wil be removed at the end.

The original is considered f(x). Now get f(y), f(x+y), and f(0).

cerr<<"\n\tf(x) = "<<*fx; cerr<<"\n\tf(y) = "<<*fy; cerr<<"\n\tf(x+y) = "<<*fx_plus_y; cerr<<"\n\tf(0) = "<<*f0;

Build the identity.

cerr<<"\noffending: sub("<<*left<<","<<*right<<")";

cerr<<"\n\tmust_be_zero = "<<*must_be_zero;

Verify the identity.

... Save the parameters.

Return result.

Definition at line 22 of file affine.cc.

References add(), Expression::clone(), constant(), List< T >::ins_last(), is_integer_zero(), mul(), Symbol::name(), Symbol::name_ref(), OMEGA_OP, Expression::op(), simplify(), sub(), and substitute_var().

Referenced by check_scalars_affine().

bool check_scalars_affine List< Expression > &  elist,
ProgramUnit pgm,
DoStmt loop,
vector< vector< Symbol * > > &  vargs,
vector< vector< Expression * > > &  vcoeffs
 

Return true if all variables referenced are integer scalars, and the expression is affine with respect to all loop variants.

Also, return all referenced symbols.

Check that they are all integer scalars and every expression is affine with respect to all the loop variants referenced within.

Definition at line 124 of file affine.cc.

References Iterator< T >::current(), Type::data_type(), INTEGER_TYPE, Symbol::intrinsic(), is_affine(), Symbol::is_scalar(), loop(), loop_variant(), referred_symbols(), Symbol::type(), and Iterator< T >::valid().

Referenced by eg_distance().

 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:18 2005