/* * * This is from AWLF. AWLF and SSE/DL/AS/AL are unable to * remove the val_lt_val guards. We hope ISL can do the job. * * Unit test for wlf * * Just the rotate part of relax(). * * All of the following problems appear to be resolved, as * of Build #18418. * * This is very weird: If you compile it with no options, * the result comes out as 39951. * * If you compile it with -doawlf -dowlf and/or with -DSTDLIB, * you get 40000. * * For the nonce, let's assume that the rotate() function * is broken, so use stdlib. * * If you compile with -doawlf -nowlf -noctz, you get segfault * and/or time2 code assert failure in AWLFI. * */ /* RESULT: with 7 1 */ //use Array:all; int[*] id( int[*] y) { return(y); } use Array:{rotate}; inline double[.,.] Synthetic2( int[2] shp) { /* Generate: * A = _reshape_VxA_([m,n], 0.5 + tod( iota( m*n))); * without using reshape primitive. */ z = with{ (. <= iv=[i,j] <= .) : _add_SxS_( 0.5, _tod_S_( _add_SxS_( j, ( _mul_SxS_( i, _sel_VxA_( [1], shp)))))); } : genarray( shp, 42.0); return( z); } inline double add( double x, double y) { z = _add_SxS_( x, y); return( z); } inline double Sum( double[+] y) { z = with { ( [0,0] <= iv < _shape_A_( y)) : _sel_VxA_( iv, y); } : fold( add, 0.0); return( z); } inline double[+] add( double[+] x, double[+] y) { z = with { ( [0,0] <= iv < _shape_A_( y)) : _add_SxS_( _sel_VxA_( iv, x), _sel_VxA_( iv, y)); } : genarray( _shape_A_( x), 0.0); return( z); } int main() { m = _max_SxS_( id( 20), 1); /* We want rotate counts to make sense */ n = _max_SxS_( id( 10), 1); A = Synthetic2( [ m, n]); //StdIO::show(A); t = relax (A); // StdIO::print( t); z = Sum( t); //StdIO::print( z); z = _toi_S_( _eq_SxS_( 40000.0, z)); z = _sub_SxS_( z, 1); return( z); } inline double[.,.] relax( double[.,.] A) { m = _sel_VxA_( [0], _shape_A_(A)); n = _sel_VxA_( [1], _shape_A_(A)); neg1 = _sub_SxS_( 0, 1); b1 = rotate( 0, 1, A); b2 = rotate( 0, neg1, A); B = add( b1, b2); return( B); }