/********************************************************************** * * SAC bug report: sacprelude_d.sacbugreport * ********************************************************************** * * Automatically generated on Wed Jan 18 08:24:02 EST 2017 * * using sac2c 1.2-beta-BlackForest-350-g6d6e * built 2017-01-13T15:14:18. * by user sac on host rattler. * * The compiler was called by * /home/sac/cmake-follow/build_d/sac2c_d -target seq -Xc -I/home/sac/cmake-follow/build_d/include -I/home/sac/cmake-follow/include -I/home/sac/cmake-follow/src/include -I/home/sac/cmake-follow/src/libsacphm/heap -I/home/sac/cmake-follow/src/libsacdistmem/commlib -Xtc -I/home/sac/cmake-follow/build_d/include -I/home/sac/cmake-follow/include -I/home/sac/cmake-follow/src/include -I/home/sac/cmake-follow/src/libsacphm/heap -I/home/sac/cmake-follow/src/libsacdistmem/commlib -v0 -linksetsize 0 -noprelude -o /home/sac/cmake-follow/build_d/runtime_build/src/runtime_libraries-build/lib/prelude /home/sac/cmake-follow/build_d/runtime_build/src/runtime_libraries-build/sacprelude_d.sac * * The compiler crashed in * phase: pre (Preprocessing SAC program) * sub phase: acn (Resolving axis control and dot notation) * * What follows is the contents of /home/sac/cmake-follow/build_d/runtime_build/src/runtime_libraries-build/sacprelude_d.sac. * **********************************************************************/ module sacprelude_d; /* NB: Be SURE that, for any names you add here, that you also add * them to "addspecialfuns.c" in the modules subdirectory, * Otherwise, they won't get inlined, apparently. * */ provide {sel, zero, eq, adjustLacFunParams, adjustLacFunParamsReshape, isPartitionIntersectNull, partitionMin, partitionMax, isPartitionIntersect1Part, partitionIntersectMax, partitionIntersectMin, SACarg, prod, partitionSlicer, gridFiller, ++ #if 0 /* * We need the following two functions only for the distributed memory backend but unfortunately * we cannot easily tell that we are compiling the prelude for the distributed memory * backend at the precompilation stage. So we always include these functions. * The name starts with an underscore to signalize that they are not intended to be used directly * by the programmer. */ #endif ,_selVxADistmemLocal, _selSxADistmemLocal #define MUTC 1 #ifndef SAC_BACKEND_MUTC , unwrapInt, unwrapBool, unwrapFloat, unwrapDouble, unwrapChar, isInt, isBool, isFloat, isDouble, isChar, isUdt, wrap , unwrapByte, unwrapShort, unwrapInt, unwrapLong, unwrapLonglong, unwrapUbyte, unwrapUshort, unwrapUint, unwrapUlong, unwrapUlonglong, isByte, isShort, isInt, isLong, isLonglong, isUbyte, isUshort, isUint, isUlong, isUlonglong #endif #undef MUTC }; external typedef SACarg; #pragma freefun "SACARGfree" #pragma copyfun "SACARGcopy" #define BUILT_IN( fun) \ fun( int) \ fun( float) \ fun( double) \ fun( bool) \ fun( char) \ fun( byte) \ fun( short) \ fun( long) \ fun( longlong) \ fun( ubyte) \ fun( ushort) \ fun( uint) \ fun( ulong) \ fun( ulonglong) #define SEL_VxA( a) \ inline \ a[*] sel( int[.] idx, a[*] array) \ { \ new_shape = _drop_SxV_( _sel_VxA_( [0], _shape_A_(idx)), _shape_A_(array));\ res = with { \ ( . <= iv <= . ) \ { \ new_idx = _cat_VxV_( idx, iv); \ } : _sel_VxA_(new_idx, array); \ } : genarray( new_shape, zero( array ) ); \ return( res); \ } BUILT_IN( SEL_VxA) #define SEL_VxA_distmem_local( a) \ inline \ a[*] _selVxADistmemLocal( int[.] idx, a[*] array) \ { \ new_shape = _drop_SxV_( _sel_VxA_( [0], _shape_A_(idx)), _shape_A_(array)); \ res = with { \ ( . <= iv <= . ) \ { \ new_idx = _cat_VxV_( idx, iv); \ } : _sel_VxA_distmem_local_(new_idx, array); \ } : genarray( new_shape, zero( array ) ); \ return( res); \ } BUILT_IN( SEL_VxA_distmem_local) #define SEL_SxA_distmem_local( a) \ inline \ a[*] _selSxADistmemLocal( int idx, a[*] array) \ { \ return( _selVxADistmemLocal( [idx], array)); \ } BUILT_IN( SEL_SxA_distmem_local) #define ZERO( a, za) \ inline \ a zero( a[*] A) \ { \ return( za); \ } ZERO( int, 0) ZERO( double, 0d) ZERO( float, 0f) ZERO( char, ' ') ZERO( bool, false) ZERO( byte, 0b) ZERO( short, 0s) ZERO( long, 0l) ZERO( longlong, 0ll) ZERO( ubyte, 0ub) ZERO( ushort, 0us) ZERO( uint, 0ui) ZERO( ulong, 0ul) ZERO( ulonglong, 0ull) int ++ (int a) { return _add_SxS_ (a, 1); } inline bool and( bool a, bool b) { return( _and_SxS_( a, b)); } #define EQ( a) \ inline \ bool eq( a[*] A, a[*] B) \ { \ res = with { \ ( _mul_SxV_(0, _shape_A_(A)) <= iv < _shape_A_(A) ) \ : _eq_SxS_(_sel_VxA_( iv, A), _sel_VxA_( iv, B)); \ } : fold( sacprelude_d::and, true ); \ return( res); \ } BUILT_IN( EQ) inline int * (int a, int b) { return( _mul_SxS_( a, b)); } inline int prod( int[.] v) { res = with { ([0] <= [i] < _shape_A_( v)) : _sel_VxA_( [i], v); } : fold( *, 1); return( res); } int[*] adjustLacFunParamsReshape( bool[*] p, int[*] i, int[.] iv, int[.] shp) { return ((_or_SxS_(_eq_SxS_( _dim_A_(p), 0), _eq_SxS_(_dim_A_(i), 0)) ? i : _reshape_VxA_( shp, i)[iv])); } int[*] adjustLacFunParams( bool[*] p, int[*] i, int[.] iv) { return ((_or_SxS_(_eq_SxS_( _dim_A_(p), 0), _eq_SxS_(_dim_A_(i), 0)) ? i : i[iv])); } inline int partitionMin( int x, int y) { z = _min_SxS_( x, y); return(z); } inline int partitionMax( int x, int y) { z = _max_SxS_( x, y); return(z); } inline int[.], int[.], int[.], int[.] partitionSlicer( int[.] min, int[.] max, int axis, int[.] lb, int[.] ub) { lb_i = _sel_VxA_( [axis], lb); ub_i = partitionMax( lb_i, _sel_VxA_( [axis], ub)); max_lower = _modarray_AxVxS_( max, [axis], lb_i); min_upper = _modarray_AxVxS_( min, [axis], ub_i); new_min = _modarray_AxVxS_( min, [axis], lb_i); new_max = _modarray_AxVxS_( max, [axis], ub_i); return( max_lower, min_upper, new_min, new_max); } inline int[.], int[.], int[.] gridFiller( int[.] lb, int[.] ub, int[.] wdth, int dim, int[.] maxwidth) { l_dim = partitionMin( _add_SxS_( _sel_VxA_( [dim], lb), _sel_VxA_( [dim], wdth)), _sel_VxA_( [dim], ub)); w_dim = partitionMax( _sub_SxS_( _sel_VxA_( [dim], maxwidth), _sel_VxA_( [dim], wdth)), 0); nlb = _modarray_AxVxS_( lb, [dim], l_dim ); nwidth = _modarray_AxVxS_( maxwidth, [dim], w_dim); nmaxwidth = _modarray_AxVxS_( maxwidth, [dim], _sel_VxA_( [dim], wdth)); return( nlb, nwidth, nmaxwidth); } inline bool[.] isPartitionIntersectNull( int[.] idxmin, int[.] idxmax, int[.] bound1, int[.] bound2) { /* Predicate to determine if intersection of comsumer-WL index set and * producer-WL partition bounds is null. It requires an assist from * the compiler to perform the any-reduce on this function's result. * * All arguments are normalized. * */ z = _or_VxV_( _lt_VxV_( idxmax, bound1), _ge_VxV_( idxmin, bound2)); return(z); } inline bool[.] isPartitionIntersectNull( int idxmin, int idxmax, int[.] bound1, int[.] bound2) { /* Predicate to determine if intersection of comsumer-WL index set and * producer-WL partition bounds is null. It requires an assist from * the compiler to perform the any-reduce on this function's result. * * idxmax and bound2 are normalized, i.e., they are like GENERATOR_BOUND2 * in a WL, where their value is 1 greater than the maximum value of * the index. * */ z = _or_VxV_( _lt_SxV_( idxmax, bound1), _ge_SxV_( idxmin, bound2)); return(z); } inline bool[.] isPartitionIntersect1Part( int[.] idxmin, int[.] idxmax, int[.] bound1, int[.] bound2) { /* Predicate to determine if intersection of consumer-WL index scalar and * producer-WL partition bounds lays entirely within one producer-WL partition. * If so, then AWLF can be performed with no slicing of the consumer-WL. * This function requires an assist from * the compiler to perform the all-reduce on this function's result. * * idxmax and bound2 are normalized, i.e., they are like GENERATOR_BOUND2 * in a WL, where their value is 1 greater than the maximum value of * the index. * */ z = _and_VxV_( _ge_VxV_( idxmin, bound1), _le_VxV_( idxmax, bound2)); return(z); } inline bool[.] isPartitionIntersect1Part( int idxmin, int idxmax, int[.] bound1, int[.] bound2) { /* Predicate to determine if intersection of consumer-WL index scalar and * producer-WL partition bounds lays entirely within one producer-WL partition. * If so, then AWLF can be performed with no slicing of the consumer-WL. * This function requires an assist from * the compiler to perform the all-reduce on this function's result. * * idxmax and bound2 are normalized, i.e., they are like GENERATOR_BOUND2 * in a WL, where their value is 1 greater than the maximum value of * */ z = _and_VxV_( _ge_SxV_( idxmin, bound1), _le_SxV_( idxmax, bound2)); return(z); } inline int[.] partitionIntersectMax( int[.] PWLbound1, int ivmin) { /* * Compute maximum of producerWL partition bound1 scalar * and index vector set. * */ z = _max_VxS_( PWLbound1, ivmin); return(z); } inline int[.] partitionIntersectMin( int[.] PWLbound2, int ivmax) { /* * Perform min( PWLbound2, ivmax) * */ z = _min_VxS_( PWLbound2, ivmax); return(z); } inline int[.] partitionIntersectMax( int[.] PWLbound1, int[.] ivmin) { /* * Compute maximum of producerWL partition bound1 * and index vector set. * */ z = _max_VxV_( PWLbound1, ivmin); return(z); } inline int[.] partitionIntersectMin( int[.] PWLbound2, int[.] ivmax) { /* * Function to perform min( PWLbound2, ivmax). * */ z = _min_VxV_( PWLbound2, ivmax); return(z); } #define MUTC 1 #ifndef SAC_BACKEND_MUTC external int[*] unwrapInt( SACarg arg); #pragma linkname "SACARGunwrapInt" #pragma linksign [1,2] #pragma refcounting [0,1] external float[*] unwrapFloat( SACarg arg); #pragma linkname "SACARGunwrapFloat" #pragma linksign [1,2] #pragma refcounting [0,1] external double[*] unwrapDouble( SACarg arg); #pragma linkname "SACARGunwrapDouble" #pragma linksign [1,2] #pragma refcounting [0,1] external bool[*] unwrapBool( SACarg arg); #pragma linkname "SACARGunwrapBool" #pragma linksign [1,2] #pragma refcounting [0,1] external char[*] unwrapChar( SACarg arg); #pragma linkname "SACARGunwrapChar" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( int[*] a); #pragma linkname "SACARGwrapInt" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( float[*] a); #pragma linkname "SACARGwrapFloat" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( double[*] a); #pragma linkname "SACARGwrapDouble" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( bool[*] a); #pragma linkname "SACARGwrapBool" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( char[*] a); #pragma linkname "SACARGwrapChar" #pragma linksign [1,2] #pragma refcounting [0,1] external bool isInt( SACarg a); #pragma linkname "SACARGisInt" #pragma linksign [0,1] external bool isFloat( SACarg a); #pragma linkname "SACARGisFloat" #pragma linksign [0,1] external bool isDouble( SACarg a); #pragma linkname "SACARGisDouble" #pragma linksign [0,1] external bool isBool( SACarg a); #pragma linkname "SACARGisBool" #pragma linksign [0,1] external bool isChar( SACarg a); #pragma linkname "SACARGisChar" #pragma linksign [0,1] external bool isUdt( int base, SACarg a); #pragma linkname "SACARGisUdt" #pragma linksign [0,1,2] external byte[*] unwrapByte( SACarg arg); #pragma linkname "SACARGunwrapByte" #pragma linksign [1,2] #pragma refcounting [0,1] external short[*] unwrapShort( SACarg arg); #pragma linkname "SACARGunwrapShort" #pragma linksign [1,2] #pragma refcounting [0,1] external long[*] unwrapLong( SACarg arg); #pragma linkname "SACARGunwrapLong" #pragma linksign [1,2] #pragma refcounting [0,1] external longlong[*] unwrapLonglong( SACarg arg); #pragma linkname "SACARGunwrapLonglong" #pragma linksign [1,2] #pragma refcounting [0,1] external ubyte[*] unwrapUbyte( SACarg arg); #pragma linkname "SACARGunwrapUbyte" #pragma linksign [1,2] #pragma refcounting [0,1] external ushort[*] unwrapUshort( SACarg arg); #pragma linkname "SACARGunwrapUshort" #pragma linksign [1,2] #pragma refcounting [0,1] external uint[*] unwrapUint( SACarg arg); #pragma linkname "SACARGunwrapUint" #pragma linksign [1,2] #pragma refcounting [0,1] external ulong[*] unwrapUlong( SACarg arg); #pragma linkname "SACARGunwrapUlong" #pragma linksign [1,2] #pragma refcounting [0,1] external ulonglong[*] unwrapUlonglong( SACarg arg); #pragma linkname "SACARGunwrapUlonglong" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( byte[*] a); #pragma linkname "SACARGwrapByte" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( short[*] a); #pragma linkname "SACARGwrapShort" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( long[*] a); #pragma linkname "SACARGwrapLong" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( longlong[*] a); #pragma linkname "SACARGwrapLonglong" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( ubyte[*] a); #pragma linkname "SACARGwrapUbyte" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( ushort[*] a); #pragma linkname "SACARGwrapUshort" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( uint[*] a); #pragma linkname "SACARGwrapUint" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( ulong[*] a); #pragma linkname "SACARGwrapUlong" #pragma linksign [1,2] #pragma refcounting [0,1] external SACarg wrap( ulonglong[*] a); #pragma linkname "SACARGwrapUlonglong" #pragma linksign [1,2] #pragma refcounting [0,1] external bool isByte( SACarg a); #pragma linkname "SACARGisByte" #pragma linksign [0,1] external bool isShort( SACarg a); #pragma linkname "SACARGisShort" #pragma linksign [0,1] external bool isLong( SACarg a); #pragma linkname "SACARGisLong" #pragma linksign [0,1] external bool isLonglong( SACarg a); #pragma linkname "SACARGisLonglong" #pragma linksign [0,1] external bool isUbyte( SACarg a); #pragma linkname "SACARGisUbyte" #pragma linksign [0,1] external bool isUshort( SACarg a); #pragma linkname "SACARGisUshort" #pragma linksign [0,1] external bool isUint( SACarg a); #pragma linkname "SACARGisUint" #pragma linksign [0,1] external bool isUlong( SACarg a); #pragma linkname "SACARGisUlong" #pragma linksign [0,1] external bool isUlonglong( SACarg a); #pragma linkname "SACARGisUlonglong" #pragma linksign [0,1] #endif #undef MUTC /********************************************************************** * * End of bug report * **********************************************************************/