Commit 1b651fb9 authored by Artem Shinkarov's avatar Artem Shinkarov
Browse files

Merge tag 'v1.3.3-MijasCosta'

Fixing broken ubuntu dependencies
parents 1954b48d 09335809
SAC2C := @SAC2C_EXEC@
SAC2C_FLAGS := -v0
SAC2C_FLAGS := -v0 -cppI@TESTS_BIN_DIR@
# Name wrapper around the shell script that takes two arguments
# `what' and `num' and verifies that $what is found $num times
# Name wrapper around shell script taking two arguments
# specifying a grep string and wc for same
# on the stdout.
GREP_COMMAND_OUTPUT := ./scripts/grep-command-output.sh
GREP_COMMAND_OUTPUT := @TESTS_BIN_DIR@/scripts/grep-command-output.sh
# Namewrapper for predicate script that returns true if
# all sac2c optional packages are enabled
ISALLOPTIONSON := @TESTS_BIN_DIR@/scripts/isalloptionson.sh
# Namewrapper for a script of two arguments `binary' and `ret'
# that verifies that return status of executing $binary is $ret.
CHECK_RETURN_STATUS := ./scripts/check-return-status.sh
CHECK_RETURN_STATUS := @TESTS_BIN_DIR@/scripts/check-return-status.sh
%:%.sac
$(SAC2C) $(SAC2C_FLAGS) -o $@ $<
......@@ -7,20 +7,57 @@ inline int + (int a, int b) { return _add_SxS_ (a, b); }
inline int - (int a, int b) { return _sub_SxS_ (a, b); }
inline int * (int a, int b) { return _mul_SxS_ (a, b); }
inline int / (int a, int b) { return _div_SxS_ (a, b); }
inline int - (int b) { return _sub_SxS_ (0, b); }
// Logical operationns
// Logical operations
inline bool < (int a, int b) { return _lt_SxS_ (a, b); }
inline bool <= (int a, int b) { return _le_SxS_ (a, b); }
inline bool > (int a, int b) { return _gt_SxS_ (a, b); }
inline bool >= (int a, int b) { return _ge_SxS_ (a, b); }
inline bool == (int a, int b) { return _eq_SxS_ (a, b); }
inline bool != (int a, int b) { return _neq_SxS_ (a, b); }
inline bool != (bool a, bool b) { return _neq_SxS_ (a, b); }
// Selection functions
inline int[*] sel(int[.] idx, int[*] array)
{
new_shape = _drop_SxV_ (_sel_VxA_ ([0], _shape_A_ (idx)),
_shape_A_ (array));
return with {
(. <= iv <= .) {
new_idx = _cat_VxV_ (idx, iv);
} : _sel_VxA_ (new_idx, array);
} : genarray (new_shape, 0);
}
inline int[*] sel (int idx, int[*] a)
{
return sel ([idx], a);
}
inline bool[*] sel (int[.] idx, bool[*] array)
{
new_shape = _drop_SxV_ (_sel_VxA_ ([0], _shape_A_ (idx)),
_shape_A_ (array));
return with {
(. <= iv <= .) {
new_idx = _cat_VxV_ (idx, iv);
} : _sel_VxA_ (new_idx, array);
} : genarray (new_shape, false);
}
// Selection
inline int sel (int[.] iv, int[*] a) { return _sel_VxA_ (iv, a); }
// Shape
inline int[.] shape (bool[*] a) { return _shape_A_ (a); }
inline int dim (bool[*] a) { return _dim_A_ (a); }
inline int[.] shape (int[*] a) { return _shape_A_ (a); }
inline int dim (int[*] a) { return _dim_A_ (a); }
// Scalar-vector take/drop
inline int[.] take (int a, int[.] b) { return _take_SxV_ (a,b); }
inline int[.] drop (int a, int[.] b) { return _drop_SxV_ (a,b); }
// Increment
inline int ++ (int a) { return _add_SxS_ (a, 1); }
......@@ -42,11 +79,51 @@ inline int[.] / (int a, int[.] b) { return _div_SxV_ (a, b); }
inline int[.] / (int[.] b, int a) { return _div_VxS_ (b, a); }
inline int[.] / (int[.] a, int[.] b) { return _div_VxV_ (a, b); }
// Reshape
inline int[*] reshape (int[.] a, int[*] b) { return _reshape_VxA_(a,b); }
inline bool[*] reshape (int[.] a, bool[*] b) { return _reshape_VxA_(a,b); }
inline int sum (int[*] a)
// Integer utilities
inline int[.] iota (int a)
{
return with {
(. <= iv=[k] <= .) : k;
}: genarray ([a], 0);
}
// Reductions
inline int sum (bool[+] a)
{
sh = shape (a);
return with {
(0*sh <= iv < sh): _toi_S_(a[iv]);
}: fold (+, 0);
}
inline int sum (int[+] a)
{
sh = shape (a);
return with {
(0*sh <= iv < sh): a[iv];
}: fold (+, 0);
}
inline int prod (int[*] a)
{
sh = shape (a);
return with {
(0*sh <= iv < sh): a[iv];
}: fold (*, 1);
}
// Array generation from scalar b
inline int[*] genarray (int[.] shp, int b)
{
return with {}: genarray (shp, b);
}
inline bool[*] genarray (int[.] shp, bool b)
{
return with {}: genarray (shp, b);
}
// SAC_TEST|include common.mk
// SAC_TEST|all: <file-name>
// SAC_TEST|<tab>@$(SAC2C) $< && (echo "error code expected"; exit 1) || (test $$? -eq 33)
// This program used to segfault at parsing, because the
// number of arguments to ++ are zero. So in this test
// we just test that compilation terminates at phase 33,
// and not return code 134 (abort that comes after handling
// segmentation fault).
int main ()
{
++();
return 0;
}
// SAC_TEST|include common.mk
// SAC_TEST|all: <file-name>
// SAC_TEST|<tab>@$(SAC2C) $< && (echo "error code expected"; exit 1) || (test $$? -eq 1)
// This program used to segfault at parsing, because of the
// way shape components were handled. The test ensures that
// compilation terminates with error code 1, and not error
// code 134 (abort that comes after handling segmentation fault).
int [ain () { return 0; }
// SAC_TEST|include common.mk
// SAC_TEST|all: <file-name>
// SAC_TEST|<tab>@$(SAC2C) $< && (echo "error code expected"; exit 1) || (test $$? -eq 1)
// This program used to segfault at parsing, because of
// the way shape components were paresd. This test
// ensuers that compilation terminates with exit code 1,
// and not 134 (abort that comes after handling
// segmentation fault).
int [ain,() { return 0; }
// SAC_TEST|include common.mk
// SAC_TEST|all: <file-name>
// SAC_TEST|<tab>@$(SAC2C) $< && (echo "error code expected"; exit 1) || (test $$? -eq 1)
// This program used to segfault because of the way return types were parsed.
// This test ensuers that compilation terminates with exit code 1, and not 134
// (abort that comes after handling segmentation fault).
int [[int [nt [[iî{ return
#include "ut-flags.mk"
// SAC_TEST|GREP_STR=_val_
// SAC_TEST|GREP_COUNT=0
/*
*
* Try to find crc.sac bug that puts -ecc code above if() in
* condfun.
*
* See Bug #1079 to see why this does not work properly.
*
* This test requires that we run with -dolacsi to ensure
* that the guards on the two sel() ops are removed.
* It also requires -ecc or -doawlf.
*
* PWLF note:
* As of sac2c Build #18548 (or earlier), without -doawlf
* (for our purposes, -doivext would suffice, were it an option)
* one guard is not removed, because we need extrema information
* about N within the N_cond. If we want to eliminate the need
* to drag extrema around with us, we might want to make
* PHUT treat LACFUNs better. I.e., make it do interprocedural
* analysis. This might also supplant the need for -dolacsi/-dolacso.
*
* The above PHUT extension should work.
*
*/
/* RESULT: _val_ 5 0 */
int[*] id( int[*] y)
{
return(y);
}
bool[*] cond( bool[*]y)
{
return(y);
}
inline
int[.] iota( int y)
{
z = with{ ( . <= iv=[k] <= .) : k;
} : genarray([y],42);
return( z);
}
int main()
{
N = id( 50);
N = _max_SxS_( N, 50);
XXX = iota( N);
ndx1 = 23;
ndx2 = 4;
if( cond(true)) {
z = _sel_VxA_( [ _add_SxS_( ndx1, 1)], XXX);
} else {
z = _sel_VxA_( [ _add_SxS_( ndx2, 1)], XXX);
}
z = _sub_SxS_(z, 24);
return(z);
}
// gitlab unit test boilerplate
#include "ut-flags.mk"
// SAC_TEST|GREP_STR=val_l
// SAC_TEST|GREP_COUNT=0
#include "mini-stdlib.sac"
// ipbb, converted to run under mini-stdlib
// and give entirely different answers...
/* RESULT: val_l 12 0 */
inline
int[+] ordotandBBBSTARLIKE(int[+]x, int[+]y)
{ /* CDC STAR-100 APL Algorithm for inner product */
rowsx = shape(x)[0];
colsx = shape(x)[1];
colsy = shape(y)[1];
Zrow = genarray([colsy],0);
z = with {
(. <= [row] <= .) {
Crow = Zrow;
for (colx=0; colx<colsx; colx++) {
xel = x[row,colx];
if( 0 != xel) { /* Skip iteration if it's an f identity */
Crow = Crow + y[colx];
}
}
} : Crow;
}: genarray( [rowsx], Zrow);
return(z);
}
inline
int ipbbXII(int siz)
{
ipt = reshape([siz, siz], iota(siz*siz));
ipt2 = { [i,j] -> ipt[j,i] }; // Transpose
mres = ordotandBBBSTARLIKE(ipt2, ipt);
z = sum(mres);
return(z);
}
int main()
{
z = ipbbXII( 10);
z2 = z == 49455;
zz = 1 - _toi_S_(z2);
return(zz);
}
// unit test template for POGO
// Caller must define GREP_STR and GREP_COUNT;
// GREP_STR
// is the string to look for in the compiler
// output, e.g., GREP_STR="val_l"
// GREP_COUNT
// is the number of occurrences of that string
// if all goes well, e.g., GREP_COUNT=42
// SAC_TEST|include common.mk
// Compile and execute unit test; save exit code
// SAC_TEST|SAC2C_FLAGS += -check c -dopogo -noggs -dolacsi -dowlf -nopwlf -noctz -norelcf -noainl -doplur
// SAC_TEST|SAC2C_BREAKPOINT := $(SAC2C_FLAGS) -bopt:wlbscnf2 -printfun main
// SAC_TEST|CALL_SAC2C := $(SAC2C) $(SAC2C_FLAGS)
// SAC_TEST|ifeq ($(shell $(ISALLOPTIONSON) $(SAC2C) "ISL" "BARVINOK"),yes)
// SAC_TEST|all: <file-name>
// SAC_TEST|<tab>@$(CALL_SAC2C) $< -o <file-name-we>
// SAC_TEST|<tab>$(CHECK_RETURN_STATUS) <file-name-we> 0
// Compile unit test with breakpoint
// SAC_TEST|<tab>@$(CALL_SAC2C) $(SAC2C_BREAKPOINT) $< | $(GREP_COMMAND_OUTPUT) $(GREP_STR) $(GREP_COUNT)
// SAC_TEST|else
// SAC_TEST|all:
// SAC_TEST|<tab>echo "test skipped. Unsupported sac2c configuration"
// SAC_TEST|endif
......@@ -2,13 +2,15 @@
source $(dirname $0)/common.sh
# We check the return status of this binary:
# We check the return status of binary:
# arguments are: binary, desired return status
#
binary=$1
# The return status should be this value:
ret=$2
./$binary
if test $? -ne $ret; then
die "'$binary' expected to return $ret as exit code"
exit_status=$?
if test $exit_status -ne $ret; then
die "'$binary' expected $ret as exit_status, but got $exit_status"
fi
......@@ -2,15 +2,15 @@
source $(dirname $0)/common.sh
# What are we grepping for
# What we are grepping for
what=$1
# How many times should it be there
num=$2
# We assume that we read output from stdin
# We read output from stdin
count=$(grep "$what" | wc -l)
if test $count -ne $num; then
if [ $count -ne $num ]; then
die "expected to find $num instances of '$what', found $count instead"
fi
#!@BASH@
# predicate: return true(0) if all script arguments are configured ON in sac2c,
# and print yes/no on stdout. Caller decisions are driven by the stdout value.
# Arguments are: <sac2c> <optionalpackage1> <optionalpackage2> ...
sac=$1
shift
for i in $@; do
res=$($sac -VV | grep $i:)
res=${res##*:\ }
res=$(echo $res | tr -d '[:space:]')
if [ "$res" != "ON" ]; then
echo "no"; exit 1
fi
done
# All arguments were configured ON in sac2c
echo "yes"; exit 0
......@@ -9,9 +9,15 @@ function namewe () {
# Source file that we are about to run tests on.
SAC_FILE=$1
# Location of the toplevel tests directory.
TOP_DIR=$2
# Cut the path off.
base_fname=$(basename $SAC_FILE)
# Cut the filename off.
dir_name=$(dirname $SAC_FILE)
# Generate the name for the extracted makefile.
makefile=${base_fname}.mk
......@@ -19,18 +25,19 @@ base_fname_we=$(namewe "$base_fname")
# Generate the Makefile form a sac test:
@CMAKE_C_COMPILER@ -E -C -x c $SAC_FILE \
| sed 's/[^[:print:]]//g' \
| grep "^// SAC_TEST|" \
| sed -e 's/^\/\/ SAC_TEST|//g'\
-e 's/<tab>/\t/g' \
-e "s/<file-name>/$base_fname/g" \
-e "s/<file-name-we>/$base_fname_we/g" \
-e 's/<nlslash>/\\/g' > $makefile
-e 's/<nlslash>/\\/g' > ${dir_name}/$makefile
if test $? -ne 0; then
die "cannot parse SAC_TEST specification in $SAC_FILE"
fi
if ! make -f $makefile; then
if ! (cd ${dir_name}; make -I$TOP_DIR -f $makefile); then
die "test $SAC_FILE failed"
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment