diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-11-13 14:14:17 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-11-13 14:14:17 +0100 |
commit | f2cf6d4e0600d4a58677a7531e8516a37fe1d0da (patch) | |
tree | adf79d4780ffb2aa8733a70da461239270e5c21e /test | |
parent | 24406a351e9d64c2953b0b9fc7ef0b3d79db9b85 (diff) | |
parent | 847554275608bafcbfad635684e588501e00ac31 (diff) | |
download | compcert-kvx-f2cf6d4e0600d4a58677a7531e8516a37fe1d0da.tar.gz compcert-kvx-f2cf6d4e0600d4a58677a7531e8516a37fe1d0da.zip |
Merge remote-tracking branch 'origin/mppa-work' into mppa-work-upstream-merge
Diffstat (limited to 'test')
77 files changed, 557 insertions, 180 deletions
diff --git a/test/Makefile b/test/Makefile index 037fdc8f..7efcd8f1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,8 +1,12 @@ include ../Makefile.config #DIRS=c compression raytracer spass regression + # Kalray note - removing compression, raytracer and spass that cannot be executed by the simulator in reasonable time -DIRS=c regression +ifeq ($(ARCH),mppa_k1c) + DIRS:=c regression +endif + ifeq ($(CLIGHTGEN),true) DIRS+=clightgen endif diff --git a/test/c/Makefile b/test/c/Makefile index 72054179..a2a80e06 100644 --- a/test/c/Makefile +++ b/test/c/Makefile @@ -8,7 +8,9 @@ EXECUTE:=timeout --signal=SIGTERM 20s $(EXECUTE) LIBS=$(LIBMATH) -TIME=ocaml unix.cma ../../tools/xtime.ml -o /dev/null -mintime 2.0 -minruns 4 +TIME=time >/dev/null +# FIXME - maybe this is better? From v3.6 +# TIME=ocaml unix.cma ../../tools/xtime.ml -o /dev/null -mintime 2.0 -minruns 4 PROGS?=fib integr qsort fft fftsp fftw sha1 sha3 aes almabench \ lists binarytrees fannkuch mandelbrot nbody \ @@ -23,6 +25,10 @@ PROGS?=fib integr qsort fft fftsp fftw sha1 sha3 aes almabench \ # * also removed bisect, who is exhibiting different float values on the Kalray # architecture than using x86 GCC (for both CompCert and GCC ports) (tested with n=10) ## +ifeq ($(ARCH),mppa_k1c) + PROGS:=$(filter-out knucleotide,$(PROGS)) + PROGS:=$(filter-out bisect,$(PROGS)) +endif all: $(PROGS:%=%.compcert) @@ -41,20 +47,12 @@ all_gcc: $(PROGS:%=%.gcc) test: all @for i in $(PROGS); do \ - $(EXECUTE) ./$$i.compcert > $$i.compcert.out;\ - if cmp -s $$i.compcert.out Results/$$i; \ - then echo "$$i: passed"; \ - else echo "$$i: FAILED"; exit 2; \ - fi; \ + SIMU='$(EXECUTE)' ./Runtest $$i ./$$i.compcert;\ done test_gcc: all_gcc @for i in $(PROGS); do \ - $(EXECUTE) ./$$i.gcc > $$i.gcc.out;\ - if cmp -s $$i.gcc.out Results/$$i; \ - then echo "$$i: passed"; \ - else echo "$$i: FAILED"; exit 2;\ - fi; \ + SIMU='$(EXECUTE)' ./Runtest $$i ./$$i.gcc;\ done bench_gcc: all_gcc diff --git a/test/c/Results/binarytrees b/test/c/Results/binarytrees index 72654db9..9dfe1355 100644 --- a/test/c/Results/binarytrees +++ b/test/c/Results/binarytrees @@ -1,4 +1,7 @@ -stretch tree of depth 7 check: -1 -128 trees of depth 4 check: -128 -32 trees of depth 6 check: -32 -long lived tree of depth 6 check: -1 +stretch tree of depth 13 check: -1 +8192 trees of depth 4 check: -8192 +2048 trees of depth 6 check: -2048 +512 trees of depth 8 check: -512 +128 trees of depth 10 check: -128 +32 trees of depth 12 check: -32 +long lived tree of depth 12 check: -1 diff --git a/test/c/Results/binarytrees-mppa_k1c b/test/c/Results/binarytrees-mppa_k1c new file mode 100644 index 00000000..72654db9 --- /dev/null +++ b/test/c/Results/binarytrees-mppa_k1c @@ -0,0 +1,4 @@ +stretch tree of depth 7 check: -1 +128 trees of depth 4 check: -128 +32 trees of depth 6 check: -32 +long lived tree of depth 6 check: -1 diff --git a/test/c/Results/chomp b/test/c/Results/chomp index 7898d32f..145b603a 100644 --- a/test/c/Results/chomp +++ b/test/c/Results/chomp @@ -1,4 +1,10 @@ player 0 plays at (1,1) +player 1 plays at (6,0) +player 0 plays at (0,6) +player 1 plays at (5,0) +player 0 plays at (0,5) +player 1 plays at (4,0) +player 0 plays at (0,4) player 1 plays at (3,0) player 0 plays at (0,3) player 1 plays at (2,0) diff --git a/test/c/Results/chomp-mppa_k1c b/test/c/Results/chomp-mppa_k1c new file mode 100644 index 00000000..7898d32f --- /dev/null +++ b/test/c/Results/chomp-mppa_k1c @@ -0,0 +1,9 @@ +player 0 plays at (1,1) +player 1 plays at (3,0) +player 0 plays at (0,3) +player 1 plays at (2,0) +player 0 plays at (0,2) +player 1 plays at (1,0) +player 0 plays at (0,1) +player 1 plays at (0,0) +player 1 loses diff --git a/test/c/Results/fannkuch b/test/c/Results/fannkuch index 09ecc715..be1815d4 100644 --- a/test/c/Results/fannkuch +++ b/test/c/Results/fannkuch @@ -1,31 +1,31 @@ -123456 -213456 -231456 -321456 -312456 -132456 -234156 -324156 -342156 -432156 -423156 -243156 -341256 -431256 -413256 -143256 -134256 -314256 -412356 -142356 -124356 -214356 -241356 -421356 -234516 -324516 -342516 -432516 -423516 -243516 -Pfannkuchen(6) = 10 +12345678910 +21345678910 +23145678910 +32145678910 +31245678910 +13245678910 +23415678910 +32415678910 +34215678910 +43215678910 +42315678910 +24315678910 +34125678910 +43125678910 +41325678910 +14325678910 +13425678910 +31425678910 +41235678910 +14235678910 +12435678910 +21435678910 +24135678910 +42135678910 +23451678910 +32451678910 +34251678910 +43251678910 +42351678910 +24351678910 +Pfannkuchen(10) = 38 diff --git a/test/c/Results/fannkuch-mppa_k1c b/test/c/Results/fannkuch-mppa_k1c new file mode 100644 index 00000000..09ecc715 --- /dev/null +++ b/test/c/Results/fannkuch-mppa_k1c @@ -0,0 +1,31 @@ +123456 +213456 +231456 +321456 +312456 +132456 +234156 +324156 +342156 +432156 +423156 +243156 +341256 +431256 +413256 +143256 +134256 +314256 +412356 +142356 +124356 +214356 +241356 +421356 +234516 +324516 +342516 +432516 +423516 +243516 +Pfannkuchen(6) = 10 diff --git a/test/c/Results/fft b/test/c/Results/fft index 0fc1c969..a48608b0 100644 --- a/test/c/Results/fft +++ b/test/c/Results/fft @@ -1 +1 @@ -1024 points, result OK +262144 points, result OK diff --git a/test/c/Results/fft-mppa_k1c b/test/c/Results/fft-mppa_k1c new file mode 100644 index 00000000..0fc1c969 --- /dev/null +++ b/test/c/Results/fft-mppa_k1c @@ -0,0 +1 @@ +1024 points, result OK diff --git a/test/c/Results/fftsp b/test/c/Results/fftsp index 2b5711a6..cbeb0999 100644 --- a/test/c/Results/fftsp +++ b/test/c/Results/fftsp @@ -1 +1 @@ -8 points, result OK +4096 points, result OK diff --git a/test/c/Results/fftsp-mppa_k1c b/test/c/Results/fftsp-mppa_k1c new file mode 100644 index 00000000..2b5711a6 --- /dev/null +++ b/test/c/Results/fftsp-mppa_k1c @@ -0,0 +1 @@ +8 points, result OK diff --git a/test/c/Results/fftw-mppa_k1c b/test/c/Results/fftw-mppa_k1c new file mode 100644 index 00000000..a1b6130c --- /dev/null +++ b/test/c/Results/fftw-mppa_k1c @@ -0,0 +1,16 @@ +o[0] = 2.918193e+01 +o[1] = -3.230611e+01 +o[2] = 1.271687e+01 +o[3] = -1.099040e+01 +o[4] = 5.728673e+00 +o[5] = -4.918940e+00 +o[6] = 1.880764e+00 +o[7] = -1.292782e+00 +o[8] = 1.104073e+02 +o[9] = -5.867858e+01 +o[10] = 2.768382e+01 +o[11] = -2.073843e+01 +o[12] = 1.229410e+01 +o[13] = -9.195029e+00 +o[14] = 4.307537e+00 +o[15] = -2.080713e+00 diff --git a/test/c/Results/fib b/test/c/Results/fib index 0e0fa4d1..84ce6474 100644 --- a/test/c/Results/fib +++ b/test/c/Results/fib @@ -1 +1 @@ -fib(15) = 987 +fib(35) = 14930352 diff --git a/test/c/Results/fib-mppa_k1c b/test/c/Results/fib-mppa_k1c new file mode 100644 index 00000000..0e0fa4d1 --- /dev/null +++ b/test/c/Results/fib-mppa_k1c @@ -0,0 +1 @@ +fib(15) = 987 diff --git a/test/c/Results/integr b/test/c/Results/integr index c61fdcc2..973806c9 100644 --- a/test/c/Results/integr +++ b/test/c/Results/integr @@ -1 +1 @@ -integr(square, 0.0, 1.0, 100000) = 0.333328 +integr(square, 0.0, 1.0, 10000000) = 0.333333 diff --git a/test/c/Results/integr-mppa_k1c b/test/c/Results/integr-mppa_k1c new file mode 100644 index 00000000..c61fdcc2 --- /dev/null +++ b/test/c/Results/integr-mppa_k1c @@ -0,0 +1 @@ +integr(square, 0.0, 1.0, 100000) = 0.333328 diff --git a/test/c/Results/knucleotide b/test/c/Results/knucleotide index e69de29b..d13ae7dc 100644 --- a/test/c/Results/knucleotide +++ b/test/c/Results/knucleotide @@ -0,0 +1,27 @@ +A 30.284 +T 29.796 +C 20.312 +G 19.608 + +AA 9.212 +AT 8.950 +TT 8.948 +TA 8.936 +CA 6.166 +CT 6.100 +AC 6.086 +TC 6.042 +AG 6.036 +GA 5.968 +TG 5.868 +GT 5.798 +CC 4.140 +GC 4.044 +CG 3.906 +GG 3.798 + +562 GGT +152 GGTA +15 GGTATT +0 GGTATTTTAATT +0 GGTATTTTAATTTATAGT diff --git a/test/c/Results/knucleotide-mppa_k1c b/test/c/Results/knucleotide-mppa_k1c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/c/Results/knucleotide-mppa_k1c diff --git a/test/c/Results/lists-mppa_k1c b/test/c/Results/lists-mppa_k1c new file mode 100644 index 00000000..2c94e483 --- /dev/null +++ b/test/c/Results/lists-mppa_k1c @@ -0,0 +1,2 @@ +OK +OK diff --git a/test/c/Results/mandelbrot b/test/c/Results/mandelbrot Binary files differindex 246f7ce1..b81e96bf 100644 --- a/test/c/Results/mandelbrot +++ b/test/c/Results/mandelbrot diff --git a/test/c/Results/mandelbrot-mppa_k1c b/test/c/Results/mandelbrot-mppa_k1c Binary files differnew file mode 100644 index 00000000..f50961fe --- /dev/null +++ b/test/c/Results/mandelbrot-mppa_k1c diff --git a/test/c/Results/nbody b/test/c/Results/nbody index 99ad4fd1..41b648fd 100644 --- a/test/c/Results/nbody +++ b/test/c/Results/nbody @@ -1,2 +1,2 @@ -0.169075164 --0.169050762 +-0.169086185 diff --git a/test/c/Results/nbody-mppa_k1c b/test/c/Results/nbody-mppa_k1c new file mode 100644 index 00000000..99ad4fd1 --- /dev/null +++ b/test/c/Results/nbody-mppa_k1c @@ -0,0 +1,2 @@ +-0.169075164 +-0.169050762 diff --git a/test/c/Results/nsieve b/test/c/Results/nsieve index 95fea812..bb9b87dc 100644 --- a/test/c/Results/nsieve +++ b/test/c/Results/nsieve @@ -1,3 +1,3 @@ -Primes up to 12800 1526 -Primes up to 6400 834 -Primes up to 3200 452 +Primes up to 5120000 356244 +Primes up to 2560000 187134 +Primes up to 1280000 98610 diff --git a/test/c/Results/nsieve-mppa_k1c b/test/c/Results/nsieve-mppa_k1c new file mode 100644 index 00000000..95fea812 --- /dev/null +++ b/test/c/Results/nsieve-mppa_k1c @@ -0,0 +1,3 @@ +Primes up to 12800 1526 +Primes up to 6400 834 +Primes up to 3200 452 diff --git a/test/c/Results/nsievebits b/test/c/Results/nsievebits index 2131804c..bb9b87dc 100644 --- a/test/c/Results/nsievebits +++ b/test/c/Results/nsievebits @@ -1,3 +1,3 @@ -Primes up to 40000 4203 -Primes up to 20000 2262 -Primes up to 10000 1229 +Primes up to 5120000 356244 +Primes up to 2560000 187134 +Primes up to 1280000 98610 diff --git a/test/c/Results/nsievebits-mppa_k1c b/test/c/Results/nsievebits-mppa_k1c new file mode 100644 index 00000000..2131804c --- /dev/null +++ b/test/c/Results/nsievebits-mppa_k1c @@ -0,0 +1,3 @@ +Primes up to 40000 4203 +Primes up to 20000 2262 +Primes up to 10000 1229 diff --git a/test/c/Results/perlin b/test/c/Results/perlin index 8438b53c..4503fc1c 100644 --- a/test/c/Results/perlin +++ b/test/c/Results/perlin @@ -1 +1 @@ -6.0000e+00 +-4.0543e+03 diff --git a/test/c/Results/perlin-mppa_k1c b/test/c/Results/perlin-mppa_k1c new file mode 100644 index 00000000..8438b53c --- /dev/null +++ b/test/c/Results/perlin-mppa_k1c @@ -0,0 +1 @@ +6.0000e+00 diff --git a/test/c/Results/qsort-mppa_k1c b/test/c/Results/qsort-mppa_k1c new file mode 100644 index 00000000..d86bac9d --- /dev/null +++ b/test/c/Results/qsort-mppa_k1c @@ -0,0 +1 @@ +OK diff --git a/test/c/Results/sha1-mppa_k1c b/test/c/Results/sha1-mppa_k1c new file mode 100644 index 00000000..730d5406 --- /dev/null +++ b/test/c/Results/sha1-mppa_k1c @@ -0,0 +1,2 @@ +Test `abc': passed +Test `abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq': passed diff --git a/test/c/Results/spectral b/test/c/Results/spectral index b06cd560..1e35f7e0 100644 --- a/test/c/Results/spectral +++ b/test/c/Results/spectral @@ -1 +1 @@ -1.272359925 +1.274224148 diff --git a/test/c/Results/spectral-mppa_k1c b/test/c/Results/spectral-mppa_k1c new file mode 100644 index 00000000..b06cd560 --- /dev/null +++ b/test/c/Results/spectral-mppa_k1c @@ -0,0 +1 @@ +1.272359925 diff --git a/test/c/Results/vmach b/test/c/Results/vmach index a95237a6..9caa2e51 100644 --- a/test/c/Results/vmach +++ b/test/c/Results/vmach @@ -1,2 +1,2 @@ -fib(15) = 987 -tak(12, 9, 6) = 9 +fib(30) = 1346269 +tak(18, 12, 6) = 7 diff --git a/test/c/Results/vmach-mppa_k1c b/test/c/Results/vmach-mppa_k1c new file mode 100644 index 00000000..a95237a6 --- /dev/null +++ b/test/c/Results/vmach-mppa_k1c @@ -0,0 +1,2 @@ +fib(15) = 987 +tak(12, 9, 6) = 9 diff --git a/test/c/Runtest b/test/c/Runtest new file mode 100755 index 00000000..f693219a --- /dev/null +++ b/test/c/Runtest @@ -0,0 +1,71 @@ +#!/bin/sh + +# The name of the test +name="$1" +shift + +# The temp file for output +out="test$$.log" +rm -f $out +trap "rm -f $out" 0 INT QUIT + +# Is the test expected to fail? +expect_fail=false + +# The architecture and the bitsize +arch=`sed -n -e 's/^ARCH=//p' ../../Makefile.config` +bits=`sed -n -e 's/^BITSIZE=//p' ../../Makefile.config` + +# The reference output +if test -f "Results/$name-$arch-$bits"; then + ref="Results/$name-$arch-$bits" +elif test -f "Results/$name-$arch"; then + ref="Results/$name-$arch" +elif test -f "Results/$name-$bits"; then + ref="Results/$name-$bits" +elif test -f "Results/$name"; then + ref="Results/$name" +else + ref="" +fi + +# Special conditions + +if test -f "$name.cond"; then + RUN=0 SKIP=1 EXPECT_FAIL=2 sh "$name.cond" + case "$?" in + 1) echo "$name: skipped"; exit 0;; + 2) expect_fail=true;; + esac +fi + +# Administer the test +if $SIMU $* > $out +then + if $expect_fail; then + echo "$name: ERROR (should have failed but did not)" + exit 2 + elif test -n "$ref"; then + if cmp -s "$out" "$ref"; then + echo "$name: passed" + exit 0 + else + echo "$name: WRONG OUTPUT (diff follows)" + diff -u "$ref" "$out" + exit 2 + fi + else + echo "$name: passed" + exit 0 + fi +else + retcode=$? + if $expect_fail; then + echo "$name: passed (failed as expected)" + exit 0 + else + echo "$name: EXECUTION FAILED (status $retcode)" + exit 2 + fi +fi + diff --git a/test/c/aes.c b/test/c/aes.c index 16f02e47..0a64fe60 100644 --- a/test/c/aes.c +++ b/test/c/aes.c @@ -1441,6 +1441,10 @@ int main(int argc, char ** argv) (u8 *)"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF", (u8 *)"\x8E\xA2\xB7\xCA\x51\x67\x45\xBF\xEA\xFC\x49\x90\x4B\x49\x60\x89", 5, 6); +#ifdef __K1C__ + do_bench(2000); +#else do_bench(1000000); +#endif return 0; } diff --git a/test/c/almabench.c b/test/c/almabench.c index 5487b062..4417200c 100644 --- a/test/c/almabench.c +++ b/test/c/almabench.c @@ -42,10 +42,15 @@ #define R2D (180.0 / PI) #define GAUSSK 0.01720209895 #define TEST_LOOPS 20 -#define TEST_LENGTH 36525 #define sineps 0.3977771559319137 #define coseps 0.9174820620691818 +#ifdef __K1C__ +#define TEST_LENGTH 12 +#else +#define TEST_LENGTH 36525 +#endif + const double amas [8] = { 6023600.0, 408523.5, 328900.5, 3098710.0, 1047.355, 3498.5, 22869.0, 19314.0 }; const double a [8][3] = diff --git a/test/c/binarytrees.c b/test/c/binarytrees.c index adc0d7b3..becae164 100644 --- a/test/c/binarytrees.c +++ b/test/c/binarytrees.c @@ -75,7 +75,11 @@ int main(int argc, char* argv[]) unsigned N, depth, minDepth, maxDepth, stretchDepth; treeNode *stretchTree, *longLivedTree, *tempTree; +#ifdef __K1C__ N = argc < 2 ? 6 : atol(argv[1]); +#else + N = argc < 2 ? 12 : atol(argv[1]); +#endif minDepth = 4; diff --git a/test/c/chomp.c b/test/c/chomp.c index 5b3c9cfb..7e2f62c1 100644 --- a/test/c/chomp.c +++ b/test/c/chomp.c @@ -338,8 +338,13 @@ int main(void) struct _play *tree; +#ifdef __K1C__ ncol = 4; nrow = 4; +#else + ncol = 7; + nrow = 7; +#endif tree = make_play(1); /* create entire tree structure, not just the */ player = 0; /* needed part for first move */ current = make_data(nrow,ncol); /* start play at full board */ diff --git a/test/c/fannkuch.c b/test/c/fannkuch.c index 6fb7912f..befccd8d 100644 --- a/test/c/fannkuch.c +++ b/test/c/fannkuch.c @@ -102,7 +102,11 @@ fannkuch( int n ) int main( int argc, char* argv[] ) { +#ifdef __K1C__ int n = (argc>1) ? atoi(argv[1]) : 6; +#else + int n = (argc>1) ? atoi(argv[1]) : 10; +#endif printf("Pfannkuchen(%d) = %ld\n", n, fannkuch(n)); return 0; diff --git a/test/c/fft.c b/test/c/fft.c index 429181b1..8ab59c9a 100644 --- a/test/c/fft.c +++ b/test/c/fft.c @@ -152,7 +152,11 @@ int main(int argc, char ** argv) double enp, t, y, z, zr, zi, zm, a; double * xr, * xi, * pxr, * pxi; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 10; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 18; +#endif np = 1 << n; enp = np; npm = np / 2 - 1; diff --git a/test/c/fftsp.c b/test/c/fftsp.c index 2dcd4ad2..d327a74c 100644 --- a/test/c/fftsp.c +++ b/test/c/fftsp.c @@ -153,7 +153,11 @@ int main(int argc, char ** argv) float enp, t, y, z, zr, zi, zm, a; float * xr, * xi, * pxr, * pxi; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 3; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 12; +#endif np = 1 << n; enp = np; npm = np / 2 - 1; diff --git a/test/c/fftw.c b/test/c/fftw.c index 755bac7f..04d896ad 100644 --- a/test/c/fftw.c +++ b/test/c/fftw.c @@ -74,7 +74,11 @@ const E KP1_847759065 = ((E) +1.847759065022573512256366378793576573644833252); /* Test harness */ +#ifdef __K1C__ #define NRUNS (10 * 10) +#else +#define NRUNS (100 * 1000) +#endif int main() { diff --git a/test/c/fib.c b/test/c/fib.c index 439b908c..168626bc 100644 --- a/test/c/fib.c +++ b/test/c/fib.c @@ -12,7 +12,11 @@ int fib(int n) int main(int argc, char ** argv) { int n, r; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 15; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 35; +#endif r = fib(n); printf("fib(%d) = %d\n", n, r); return 0; diff --git a/test/c/integr.c b/test/c/integr.c index 19ea78ab..cd0521f5 100644 --- a/test/c/integr.c +++ b/test/c/integr.c @@ -25,7 +25,11 @@ double test(int n) int main(int argc, char ** argv) { int n; double r; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 100000; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 10000000; +#endif r = test(n); printf("integr(square, 0.0, 1.0, %d) = %g\n", n, r); return 0; diff --git a/test/c/lists.c b/test/c/lists.c index a72ec398..8deb0f37 100644 --- a/test/c/lists.c +++ b/test/c/lists.c @@ -61,8 +61,13 @@ int main(int argc, char ** argv) int n, niter, i; struct list * l; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 500; if (argc >= 3) niter = atoi(argv[1]); else niter = 100; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 1000; + if (argc >= 3) niter = atoi(argv[1]); else niter = 20000; +#endif l = buildlist(n); if (checklist(n, reverselist(l))) { printf("OK\n"); diff --git a/test/c/mandelbrot.c b/test/c/mandelbrot.c index 84fae15c..fb8b929c 100644 --- a/test/c/mandelbrot.c +++ b/test/c/mandelbrot.c @@ -17,12 +17,20 @@ int main (int argc, char **argv) { int w, h, bit_num = 0; char byte_acc = 0; +#ifdef __K1C__ int i, iter = 30; +#else + int i, iter = 50; +#endif double x, y, limit = 2.0; double Zr, Zi, Cr, Ci, Tr, Ti; if (argc < 2) { - w = h = 50; +#ifdef __K1C__ + w = h = 40; +#else + w = h = 1000; +#endif } else { w = h = atoi(argv[1]); } diff --git a/test/c/nbody.c b/test/c/nbody.c index 1ce8d788..ab0ebabe 100644 --- a/test/c/nbody.c +++ b/test/c/nbody.c @@ -140,7 +140,11 @@ void setup_bodies(void) int main(int argc, char ** argv) { +#ifdef __K1C__ int n = argc < 2 ? 100 : atoi(argv[1]); +#else + int n = argc < 2 ? 1000000 : atoi(argv[1]); +#endif int i; setup_bodies(); diff --git a/test/c/nsieve.c b/test/c/nsieve.c index fc79ba69..3954bcbe 100644 --- a/test/c/nsieve.c +++ b/test/c/nsieve.c @@ -29,10 +29,18 @@ static unsigned int nsieve(int m) { #define NITER 2 int main(int argc, char * argv[]) { +#ifdef __K1C__ int m = argc < 2 ? 6 : atoi(argv[1]); +#else + int m = argc < 2 ? 9 : atoi(argv[1]); +#endif int i, j; for (i = 0; i < 3; i++) { +#ifdef __K1C__ int n = 200 << (m-i); +#else + int n = 10000 << (m-i); +#endif unsigned count; for (j = 0; j < NITER; j++) { count = nsieve(n); } printf("Primes up to %8d %8u\n", n, count); diff --git a/test/c/nsievebits.c b/test/c/nsievebits.c index 15d31417..e3b7fd43 100644 --- a/test/c/nsievebits.c +++ b/test/c/nsievebits.c @@ -30,7 +30,11 @@ nsieve(unsigned int m) return (count); } +#ifdef __K1C__ #define NITER 1 +#else +#define NITER 2 +#endif static void test(unsigned int n) @@ -48,7 +52,11 @@ main(int ac, char **av) { unsigned int n; +#ifdef __K1C__ n = ac < 2 ? 2 : atoi(av[1]); +#else + n = ac < 2 ? 9 : atoi(av[1]); +#endif test(n); if (n >= 1) test(n - 1); diff --git a/test/c/perlin.c b/test/c/perlin.c index 79d49d62..29ebf964 100644 --- a/test/c/perlin.c +++ b/test/c/perlin.c @@ -63,9 +63,15 @@ static void init(void) { p[256+i] = p[i] = permutation[i]; } +#ifdef __K1C__ #define INCREMENT 0.5 #define MIN -3.0 #define MAX 3.0 +#else +#define INCREMENT 0.1 +#define MIN -5.0 +#define MAX 5.0 +#endif int main(int argc, char ** argv) { init(); diff --git a/test/c/qsort.c b/test/c/qsort.c index 8a035eb5..1ebe1e11 100644 --- a/test/c/qsort.c +++ b/test/c/qsort.c @@ -34,7 +34,11 @@ int main(int argc, char ** argv) int n, i, j; int * a, * b; +#ifdef __K1C__ if (argc >= 2) n = atoi(argv[1]); else n = 500; +#else + if (argc >= 2) n = atoi(argv[1]); else n = 100000; +#endif a = malloc(n * sizeof(int)); b = malloc(n * sizeof(int)); for (j = 0; j < NITER; j++) { diff --git a/test/c/sha1.c b/test/c/sha1.c index 0a6ac8fe..624030cc 100644 --- a/test/c/sha1.c +++ b/test/c/sha1.c @@ -231,6 +231,10 @@ int main(int argc, char ** argv) } do_test(test_input_1, test_output_1); do_test(test_input_2, test_output_2); +#ifdef __K1C__ + do_bench(500); +#else do_bench(200000); +#endif return 0; } diff --git a/test/c/sha3.c b/test/c/sha3.c index a0905817..164e3086 100644 --- a/test/c/sha3.c +++ b/test/c/sha3.c @@ -190,8 +190,13 @@ test_triplet_t testvec[4] = { } }; +#ifdef __K1C__ +#define DATALEN 1000 +#define NITER 7 +#else #define DATALEN 100000 #define NITER 25 +#endif int main() { diff --git a/test/c/siphash24.c b/test/c/siphash24.c index 4a42e013..ce0df78c 100644 --- a/test/c/siphash24.c +++ b/test/c/siphash24.c @@ -235,13 +235,19 @@ int test_vectors() u8 testdata[100] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 34, 56, 78, 90 }; +#ifdef __K1C__ +#define NITER 1000 +#else +#define NITER 1000000 +#endif + int speed_test(void) { u8 out[8], k[16]; int i; for(i = 0; i < 16; ++i ) k[i] = i; - for(i = 0; i < 1000000; i++) { + for(i = 0; i < NITER; i++) { testdata[99] = (u8) i; crypto_auth(out, testdata, 100, k); } diff --git a/test/c/spectral.c b/test/c/spectral.c index b3a34070..dca78fe0 100644 --- a/test/c/spectral.c +++ b/test/c/spectral.c @@ -43,7 +43,11 @@ void eval_AtA_times_u(int N, const double u[], double AtAu[]) int main(int argc, char *argv[]) { int i; +#ifdef __K1C__ int N = ((argc == 2) ? atoi(argv[1]) : 11); +#else + int N = ((argc == 2) ? atoi(argv[1]) : 1000); +#endif double * u, * v, vBv, vv; u = malloc(N * sizeof(double)); v = malloc(N * sizeof(double)); diff --git a/test/c/vmach.c b/test/c/vmach.c index 4e6848d2..5858d4d6 100644 --- a/test/c/vmach.c +++ b/test/c/vmach.c @@ -159,7 +159,11 @@ long wordcode_interp(unsigned int* code) #define I(a,b,c,d) ((a) + ((b) << 8) + ((c) << 16) + ((d) << 24)) +#ifdef __K1C__ #define FIBSIZE 15 +#else +#define FIBSIZE 30 +#endif unsigned int wordcode_fib[] = { /* 0 */ I(WCONST, FIBSIZE, 0, 0), @@ -178,9 +182,15 @@ unsigned int wordcode_fib[] = { /* 13 */ I(WRETURN, 0, 2, 0) }; +#ifdef __K1C__ #define TAKSIZE1 6 #define TAKSIZE2 9 #define TAKSIZE3 12 +#else +#define TAKSIZE1 6 +#define TAKSIZE2 12 +#define TAKSIZE3 18 +#endif unsigned int wordcode_tak[] = { /* 0 */ I(WCONST, TAKSIZE1, 0, 0), diff --git a/test/endian.h b/test/endian.h index 8be2850c..d6e121f4 100644 --- a/test/endian.h +++ b/test/endian.h @@ -1,7 +1,7 @@ #if defined(__ppc__) || defined(__PPC__) || defined(__ARMEB__) #define ARCH_BIG_ENDIAN #elif defined(__i386__) || defined(__x86_64__) || defined(__ARMEL__) \ - || defined(__riscv) || defined(__aarch64__) + || defined(__riscv) || defined(__aarch64__) || defined(__K1C__) #undef ARCH_BIG_ENDIAN #else #error "unknown endianness" diff --git a/test/monniaux/Makefile b/test/monniaux/Makefile index a6b19891..d7437eea 100644 --- a/test/monniaux/Makefile +++ b/test/monniaux/Makefile @@ -20,9 +20,12 @@ oracle_times.txt: PostpassSchedulingOracle.patch bash build_benches.sh $@ measures.csv: - (cd ../../ && make -j20 && make install) - bash build_benches.sh - bash run_benches.sh $@ + @echo "Building compcert.." + @(cd ../../ && make -s -j20 && make -s install) + @echo "Building benches..." + @bash build_benches.sh + @echo "Benches built. Running benches..." + @bash run_benches.sh $@ #compile_times.pdf: gencompile.py verifier_times.txt oracle_times.txt # python3.5 $^ $@ @@ -32,4 +35,5 @@ measures.csv: .PHONY: clean: + @bash clean_benches.sh rm -f verifier_times.txt oracle_times.txt compile_times.pdf measure_times.k1c.pdf measures.csv diff --git a/test/monniaux/README.md b/test/monniaux/README.md index dbb3f337..f2af67fb 100644 --- a/test/monniaux/README.md +++ b/test/monniaux/README.md @@ -37,6 +37,7 @@ float_mat c3, 1504675, 751514, 553235, 1929369, 1372441 - `K1C_CC`: GCC compiler (default k1-cos-gcc) - `K1C_CCOMP`: compcert compiler (default ccomp) - `EXECUTE_CYCLES`: running command (default `k1-cluster` with some options) +- `EXECUTE_ARGS`: execution arguments - `GCCiFLAGS` with i from 0 to 4: the wanted optimizations. If one of these flags is empty, nothing is done. Same for `CCOMPiFLAGS`. For now, the default values: ``` # You can define up to GCC4FLAGS and CCOMP4FLAGS @@ -68,4 +69,10 @@ The `PREFIX` are the prefixes to add to the .s, .o, etc.. You should be careful Assembly files will be generated in `asm/`, objects in `obj/`, binaries in `bin/` and outputs in `out/`. -To compile and execute all the benches : `make` +To compile and execute all the benches : `make` while in the `monniaux` directory (without any `-j` flag). + +To compile and/or execute a single bench, `cd` to the bench directory, then: +- `make` for compiling the bench +- `make run` for running it + +You can use `-j` flag when in a single bench directory diff --git a/test/monniaux/benches.sh b/test/monniaux/benches.sh index 2365063a..6014f628 100644 --- a/test/monniaux/benches.sh +++ b/test/monniaux/benches.sh @@ -1,3 +1,3 @@ -benches="binary_search bitsliced-aes bitsliced-tea complex float_mat glibc_qsort heapsort idea number_theoretic_transform quicksort sha-2 tacle-bench-lift tacle-bench-powerwindow too_slow heptagon_radio_transmitter lustrev4_lustrec_heater_control lustrev4_lv4_heater_control lustrev4_lv6-en-2cgc_heater_control lustrev6-convertible-en-2cgc xor_and_mat" +benches="binary_search bitsliced-aes bitsliced-tea complex float_mat glibc_qsort heapsort idea number_theoretic_transform quicksort sha-2 tacle-bench-lift tacle-bench-powerwindow too_slow heptagon_radio_transmitter lustrev4_lustrec_heater_control lustrev4_lv4_heater_control lustrev4_lv6-en-2cgc_heater_control lustrev6-convertible-en-2cgc xor_and_mat glpk-4.65 picosat-965 genann" # Removed for now : ternary diff --git a/test/monniaux/build_benches.sh b/test/monniaux/build_benches.sh index 931cebac..a749779d 100755 --- a/test/monniaux/build_benches.sh +++ b/test/monniaux/build_benches.sh @@ -4,11 +4,16 @@ TMPFILE=/tmp/1513times.txt source benches.sh +default="\e[39m" +magenta="\e[35m" +red="\e[31m" + rm -f commands.txt rm -f $TMPFILE for bench in $benches; do + echo -e "${magenta}Building $bench..${default}" if [ "$1" == "" ]; then - (cd $bench && make -j20) + (cd $bench && make -s -j20 > /dev/null &> /dev/null) || { echo -e "${red}Build failed" && break; } else (cd $bench && make -j20) | grep -P "\d+: \d+\.\d+" >> $TMPFILE fi diff --git a/test/monniaux/clean_benches.sh b/test/monniaux/clean_benches.sh index c0a87ff9..dff15fd4 100755 --- a/test/monniaux/clean_benches.sh +++ b/test/monniaux/clean_benches.sh @@ -1,8 +1,12 @@ source benches.sh +blue="\e[34m" +default="\e[39m" + rm -f commands.txt for bench in $benches; do - (cd $bench && make clean) + echo -e "${blue}Cleaning $bench..${default}" + (cd $bench && make -s clean) done rm -f *.o diff --git a/test/monniaux/genann/Makefile b/test/monniaux/genann/Makefile new file mode 100644 index 00000000..2e76ec63 --- /dev/null +++ b/test/monniaux/genann/Makefile @@ -0,0 +1,4 @@ +ALL_CFILES= example4shorter.c genann.c +TARGET=genann4 + +include ../rules.mk diff --git a/test/monniaux/genann/make.proto b/test/monniaux/genann/make.proto deleted file mode 100644 index 7c4248bf..00000000 --- a/test/monniaux/genann/make.proto +++ /dev/null @@ -1,2 +0,0 @@ -sources: example4shorter.c genann.c -target: genann4
\ No newline at end of file diff --git a/test/monniaux/glpk-4.65/Makefile b/test/monniaux/glpk-4.65/Makefile index a0ab40dc..eaa3f4b0 100644 --- a/test/monniaux/glpk-4.65/Makefile +++ b/test/monniaux/glpk-4.65/Makefile @@ -1,39 +1,6 @@ ALL_CFLAGS += -I src/amd -I src/colamd -I src/mpl -I src/simplex -I src/api -I src/intopt -I src/minisat -I src/npp -I src/zlib -I src/bflib -I src/env -I src/misc -I src/draft -I src - -include ../rules.mk - -LIBS = -lm - -src=examples/glpsol.c $(wildcard src/*/*.c) - -PRODUCTS?=glpsol.gcc.host glpsol.ccomp.host glpsol.gcc.k1c glpsol.gcc.o1.k1c glpsol.ccomp.k1c -PRODUCTS_OUT=$(addsuffix .out,$(PRODUCTS)) - -all: $(PRODUCTS) - -.PHONY: -run: measures.csv - - -glpsol.gcc.host: $(src:.c=.gcc.host.o) ../clock.gcc.host.o - $(CC) $(CFLAGS) $+ $(LIBS) -o $@ -glpsol.ccomp.host: $(src:.c=.ccomp.host.o) ../clock.gcc.host.o - $(CCOMP) $(CCOMPFLAGS) $+ $(LIBS) -o $@ -glpsol.gcc.k1c: $(src:.c=.gcc.k1c.o) ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS) $+ $(LIBS) -o $@ -glpsol.gcc.o1.k1c: $(src:.c=.gcc.o1.k1c.o) ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS_O1) $+ $(LIBS) -o $@ -glpsol.ccomp.k1c: $(src:.c=.ccomp.k1c.o) ../clock.gcc.k1c.o - $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ $(LIBS) -o $@ - +ALL_CFILES=examples/glpsol.c $(wildcard src/*/*.c) +TARGET=glpk EXECUTE_ARGS=--math examples/prod.mod -measures.csv: $(PRODUCTS_OUT) - echo "benches, gcc host,ccomp host,gcc k1c,gcc o1 k1c,ccomp k1c" > $@ - -.SECONDARY: - -.PHONY: -clean: - rm -f *.o *.s *.k1c *.csv - +include ../rules.mk diff --git a/test/monniaux/picosat-965/Makefile b/test/monniaux/picosat-965/Makefile index 991278ff..a887c0de 100644 --- a/test/monniaux/picosat-965/Makefile +++ b/test/monniaux/picosat-965/Makefile @@ -1,37 +1,11 @@ EXECUTE_ARGS=sudoku.sat - -include ../rules.mk - -#ALL_CFLAGS = -DNDEBUG ALL_CFLAGS = -DNALARM -DNZIP -DNGETRUSAGE -DNDEBUG -K1C_CFLAGS += $(EMBEDDED_CFLAGS) -K1C_CCOMPFLAGS += $(EMBEDDED_CFLAGS) -CCOMPFLAGS += -fbitfields -K1C_CCOMPFLAGS += -fbitfields # -fno-if-conversion - -K1C_CFLAGS += $(ALL_CFLAGS) -K1C_CCOMPFLAGS += $(ALL_CFLAGS) -CCOMPFLAGS += $(ALL_CFLAGS) -CFLAGS += $(ALL_CFLAGS) - -all: picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s picosat.gcc.k1c.s version.gcc.k1c.s app.gcc.k1c.s main.gcc.k1c.s picosat.ccomp.k1c.out picosat.gcc.o1.k1c.out picosat.gcc.k1c.out picosat picosat.ccomp.host.out picosat.gcc.host.out - -picosat.ccomp.k1c : picosat.ccomp.k1c.s version.ccomp.k1c.s app.ccomp.k1c.s main.ccomp.k1c.s ../clock.gcc.k1c.o - $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ +ALL_CCOMPFLAGS += -fbitfields # -fno-if-conversion +TARGET=picosat +ALL_CFILES=picosat.c version.c app.c main.c -picosat.gcc.k1c : picosat.gcc.k1c.s version.gcc.k1c.s app.gcc.k1c.s main.gcc.k1c.s ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ - -picosat.gcc.o1.k1c : picosat.gcc.o1.k1c.s version.gcc.o1.k1c.s app.gcc.o1.k1c.s main.gcc.o1.k1c.s ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS_O1) $+ -o $@ - -picosat.ccomp.host : picosat.ccomp.host.s version.ccomp.host.s app.ccomp.host.s main.ccomp.host.s ../clock.gcc.host.o - $(CCOMP) $(CCOMPFLAGS) $+ -o $@ - -picosat.gcc.host : picosat.gcc.host.s version.gcc.host.s app.gcc.host.s main.gcc.host.s ../clock.gcc.host.o - $(CC) $(FLAGS) $+ -o $@ - -clean: - -rm -f *.s *.k1c *.out +include ../rules.mk -.PHONY: clean +# FIXME - what were these for? +#K1C_CFLAGS += $(EMBEDDED_CFLAGS) +#K1C_CCOMPFLAGS += $(EMBEDDED_CFLAGS) diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk index 9d05b4d6..9d4f5278 100644 --- a/test/monniaux/rules.mk +++ b/test/monniaux/rules.mk @@ -7,6 +7,9 @@ ALL_CFILES?=$(wildcard *.c) # Name of the target TARGET?=toto +# Arguments of execution +EXECUTE_ARGS?= + # Name of the clock object CLOCK=../clock @@ -28,27 +31,27 @@ K1C_CCOMP?=ccomp EXECUTE_CYCLES?=k1-cluster --syscall=libstd_scalls.so --cycle-based -- # You can define up to GCC4FLAGS and CCOMP4FLAGS -GCC0FLAGS?= -GCC1FLAGS?=$(ALL_GCCFLAGS) -O1 -g +GCC0FLAGS?=$(ALL_GCCFLAGS) -O0 +GCC1FLAGS?=$(ALL_GCCFLAGS) -O1 GCC2FLAGS?=$(ALL_GCCFLAGS) -O2 GCC3FLAGS?=$(ALL_GCCFLAGS) -O3 GCC4FLAGS?= -CCOMP0FLAGS?= -CCOMP1FLAGS?=$(ALL_CCOMPFLAGS) -O1 -g -CCOMP2FLAGS?=$(ALL_CCOMPFLAGS) -CCOMP3FLAGS?= +CCOMP0FLAGS?=$(ALL_CCOMPFLAGS) -O2 -fno-postpass +CCOMP1FLAGS?=$(ALL_CCOMPFLAGS) -O2 -fpostpass= greedy +CCOMP2FLAGS?=$(ALL_CCOMPFLAGS) -O2 -fno-if-conversion +CCOMP3FLAGS?=$(ALL_CCOMPFLAGS) -O2 CCOMP4FLAGS?= # Prefix names -GCC0PREFIX?= +GCC0PREFIX?=.gcc.o0 GCC1PREFIX?=.gcc.o1 GCC2PREFIX?=.gcc.o2 GCC3PREFIX?=.gcc.o3 GCC4PREFIX?= -CCOMP0PREFIX?= -CCOMP1PREFIX?=.ccomp.o1 -CCOMP2PREFIX?=.ccomp.o2 -CCOMP3PREFIX?= +CCOMP0PREFIX?=.ccomp.nobundle +CCOMP1PREFIX?=.ccomp.greedy +CCOMP2PREFIX?=.ccomp.noif +CCOMP3PREFIX?=.ccomp CCOMP4PREFIX?= # List of outfiles, updated by gen_rules @@ -92,7 +95,7 @@ obj/%.o: asm/%.s out/%.out: bin/%.bin @mkdir -p $(@D) - $(EXECUTE_CYCLES) $< | tee $@ + $(EXECUTE_CYCLES) $< $(EXECUTE_ARGS) | tee $@ ## # Generating the rules for all the compiler/flags.. diff --git a/test/monniaux/run_benches.sh b/test/monniaux/run_benches.sh index 5f9f22cb..60eec865 100755 --- a/test/monniaux/run_benches.sh +++ b/test/monniaux/run_benches.sh @@ -3,10 +3,11 @@ source benches.sh rm -f commands.txt for bench in $benches; do - echo "(cd $bench && make -j5 run)" >> commands.txt + echo "(cd $bench && echo \"Running $bench..\" &&\ + make -j4 run > /dev/null && echo \"$bench DONE\")" >> commands.txt done -cat commands.txt | xargs -n1 -I{} -P4 bash -c '{}' +cat commands.txt | xargs -n1 -I{} -P6 bash -c '{}' ## # Gather all the CSV files diff --git a/test/regression/Makefile b/test/regression/Makefile index f3bf64bb..3447d6a5 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -10,7 +10,7 @@ LIBS=$(LIBMATH) # Can run, both in compiled mode and in interpreter mode, # and have reference output in Results -TESTS=int32 int64 floats floats-basics floats-lit \ +TESTS?=int32 int64 floats floats-basics floats-lit \ expr1 expr6 funptr2 initializers initializers2 initializers3 \ volatile1 volatile2 volatile3 volatile4 \ funct3 expr5 struct7 struct8 struct11 struct12 casts1 casts2 char1 \ @@ -20,16 +20,24 @@ TESTS=int32 int64 floats floats-basics floats-lit \ # Can run, but only in compiled mode, and have reference output in Results -TESTS_COMP=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ +TESTS_COMP?=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ bitfields5 bitfields6 bitfields7 bitfields8 \ builtins-$(ARCH) alignas \ varargs1 varargs2 varargs3 sections alias aligned\ packedstruct1 packedstruct2 +ifeq ($(ARCH),mppa_k1c) + TESTS_COMP:=$(filter-out packedstruct1,$(TESTS_COMP)) + TESTS_COMP:=$(filter-out packedstruct2,$(TESTS_COMP)) +endif + # Can run, both in compiled mode and in interpreter mode, # but produce processor-dependent results, so no reference output in Results TESTS_DIFF=NaNs +ifeq ($(ARCH),mppa_k1c) + TESTS_DIFF:=$(filter-out NaNs,$(TESTS_DIFF)) +endif # Other tests: should compile to .s without errors (but expect warnings) diff --git a/test/regression/Results/varargs2-mppa_k1c b/test/regression/Results/varargs2-mppa_k1c new file mode 100644 index 00000000..f954927e --- /dev/null +++ b/test/regression/Results/varargs2-mppa_k1c @@ -0,0 +1,11 @@ +An int: 42 +A long long: 123456789012345 +A string: Hello world +A double: 3.141592654 +A mixture: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746 +Twice: -1 1.23 +Twice: -1 1.23 +With va_copy: -1 1.23 +With va_copy: -1 1.23 +With extra args: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746 +va_list compatibility: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746 diff --git a/test/regression/builtins-mppa_k1c.c b/test/regression/builtins-mppa_k1c.c new file mode 100644 index 00000000..cbf51387 --- /dev/null +++ b/test/regression/builtins-mppa_k1c.c @@ -0,0 +1,72 @@ +/* Fun with builtins */ + +#include <stdio.h> +#include <math.h> + +char * check_relative_error(double exact, double actual, double precision) +{ + double relative_error = (actual - exact) / exact; + return fabs(relative_error) <= precision ? "OK" : "ERROR"; +} + +//unsigned int x = 0x12345678; +//unsigned int y = 0xDEADBEEF; +//unsigned long long xx = 0x1234567812345678ULL; +//double a = 3.14159; +//double b = 2.718; +//double c = 1.414; +//unsigned short s = 0x1234; + +int main(int argc, char ** argv) +{ + unsigned z; + + //printf("mulhw(%x, %x) = %x\n", x, y, __builtin_mulhw(x, y)); + //printf("mulhwu(%x, %x) = %x\n", x, y, __builtin_mulhwu(x, y)); + //printf("clz(%x) = %d\n", x, __builtin_clz(x)); + //printf("clzll(%llx) = %d\n", (unsigned long long) x, __builtin_clzll(x)); + //printf("clzll(%llx) = %d\n", xx, __builtin_clzll(xx)); + //z = __builtin_bswap(x); + //printf("clzll(%lx) = %d\n", z, __builtin_clzll(z)); + //printf("bswap(%x) = %x\n", x, __builtin_bswap(x)); + //printf("bswap16(%x) = %x\n", s, __builtin_bswap16(s)); + + //printf("fmadd(%f, %f, %f) = %f\n", a, b, c, __builtin_fmadd(a, b, c)); + //printf("fmsub(%f, %f, %f) = %f\n", a, b, c, __builtin_fmsub(a, b, c)); + //printf("fabs(%f) = %f\n", a, __builtin_fabs(a)); + //printf("fabs(%f) = %f\n", -a, __builtin_fabs(-a)); + //printf("fsqrt(%f) = %f\n", a, __builtin_fsqrt(a)); + //printf("frsqrte(%f) = %s\n", + // a, check_relative_error(1.0 / sqrt(a), __builtin_frsqrte(a), 1./32.)); + //printf("fres(%f) = %s\n", + // a, check_relative_error(1.0 / a, __builtin_fres(a), 1./256.)); + //printf("fsel(%f, %f, %f) = %f\n", a, b, c, __builtin_fsel(a, b, c)); + //printf("fsel(%f, %f, %f) = %f\n", -a, b, c, __builtin_fsel(-a, b, c)); + //printf("fcti(%f) = %d\n", a, __builtin_fcti(a)); + //printf("fcti(%f) = %d\n", b, __builtin_fcti(b)); + //printf("fcti(%f) = %d\n", c, __builtin_fcti(c)); + //__builtin_eieio(); + //__builtin_sync(); + //__builtin_isync(); + //printf("isel(%d, %d, %d) = %d\n", 0, x, y, __builtin_isel(0, x, y)); + //printf("isel(%d, %d, %d) = %d\n", 42, x, y, __builtin_isel(42, x, y)); + //printf ("read_16_rev = %x\n", __builtin_read16_reversed(&s)); + //printf ("read_32_rev = %x\n", __builtin_read32_reversed(&y)); + //__builtin_write16_reversed(&s, 0x789A); + //printf ("after write_16_rev: %x\n", s); + //__builtin_write32_reversed(&y, 0x12345678); + //printf ("after write_32_rev: %x\n", y); + //y = 0; + //__builtin_write32_reversed(&y, 0x12345678); + //printf ("CSE write_32_rev: %s\n", y == 0x78563412 ? "ok" : "ERROR"); + ///* Make sure that ignoring the result of a builtin + // doesn't cause an internal error */ + //(void) __builtin_bswap(x); + //(void) __builtin_fsqrt(a); + return 0; +} + + + + + diff --git a/test/regression/extasm.c b/test/regression/extasm.c index 297178d1..352b930b 100644 --- a/test/regression/extasm.c +++ b/test/regression/extasm.c @@ -24,6 +24,7 @@ int clobbers(int x, int z) || (defined(ARCH_riscV) && defined(MODEL_64)) \ || (defined(ARCH_powerpc) && defined(MODEL_ppc64)) \ || (defined(ARCH_powerpc) && defined(MODEL_e5500)) \ + || (defined(ARCH_mppa_k1c) && defined(MODEL_64)) \ || defined(ARCH_aarch64) #define SIXTYFOUR #else diff --git a/test/regression/packedstruct1.c b/test/regression/packedstruct1.c index 5d3e7124..ac68c698 100644 --- a/test/regression/packedstruct1.c +++ b/test/regression/packedstruct1.c @@ -2,8 +2,8 @@ #include <stdio.h> -/* offsetof is the offset computed by the verified front-end (cfrontend/) */ -#define offsetof(s,f) (int)&(((struct s *)0)->f) +/* offsetOf is the offset computed by the verified front-end (cfrontend/) */ +#define offsetOf(s,f) (int)&(((struct s *)0)->f) /* boffsetof is the offset computed by the elaborator (cparser/) */ #define boffsetof(s,f) (int)__builtin_offsetof(struct s, f) @@ -23,9 +23,9 @@ void test1(void) struct s1 s1; printf("sizeof(struct s1) = %d\n", szof(s1)); printf("precomputed sizeof(struct s1) = %d\n", bszof(s1)); - printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", - offsetof(s1,x), offsetof(s1,y), offsetof(s1,z)); - printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", + offsetOf(s1,x), offsetOf(s1,y), offsetOf(s1,z)); + printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", boffsetof(s1,x), boffsetof(s1,y), boffsetof(s1,z)); s1.x = 123; s1.y = -456; s1.z = 3.14159; printf("s1 = {x = %d, y = %d, z = %.5f}\n\n", s1.x, s1.y, s1.z); @@ -44,9 +44,9 @@ void test2(void) printf("sizeof(struct s2) = %d\n", szof(s2)); printf("precomputed sizeof(struct s2) = %d\n", bszof(s2)); printf("&s2 mod 16 = %d\n", ((int) &s2) & 0xF); - printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", - offsetof(s2,x), offsetof(s2,y), offsetof(s2,z)); - printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", + offsetOf(s2,x), offsetOf(s2,y), offsetOf(s2,z)); + printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", boffsetof(s2,x), boffsetof(s2,y), boffsetof(s2,z)); s2.x = 12345; s2.y = -456; s2.z = 3.14159; printf("s2 = {x = %d, y = %d, z = %.5f}\n\n", s2.x, s2.y, s2.z); @@ -73,8 +73,8 @@ void test3(void) printf("sizeof(struct s3) = %d\n", szof(s3)); printf("precomputed sizeof(struct s3) = %d\n", bszof(s3)); - printf("offsetof(s) = %d\n", offsetof(s3,s)); - printf("precomputed offsetof(s) = %d\n", boffsetof(s3,s)); + printf("offsetOf(s) = %d\n", offsetOf(s3,s)); + printf("precomputed offsetOf(s) = %d\n", boffsetof(s3,s)); s3.x = 123; s3.y = 45678; s3.z = 0x80000001U; @@ -103,9 +103,9 @@ void test4(void) printf("sizeof(struct s4) = %d\n", szof(s4)); printf("precomputed sizeof(struct s4) = %d\n", bszof(s4)); - printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", - offsetof(s4,x), offsetof(s4,y), offsetof(s4,z)); - printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", + offsetOf(s4,x), offsetOf(s4,y), offsetOf(s4,z)); + printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", boffsetof(s4,x), boffsetof(s4,y), boffsetof(s4,z)); s4.x = 123; s4.y = -456; s4.z = 3.14159; printf("s4 = {x = %d, y = %d, z = %.5f}\n\n", s4.x, s4.y, s4.z); @@ -121,9 +121,9 @@ void test5(void) printf("sizeof(struct s5) = %d\n", szof(s5)); printf("precomputed sizeof(struct s5) = %d\n", bszof(s5)); - printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", - offsetof(s5,x), offsetof(s5,y), offsetof(s5,z)); - printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", + offsetOf(s5,x), offsetOf(s5,y), offsetOf(s5,z)); + printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", boffsetof(s5,x), boffsetof(s5,y), boffsetof(s5,z)); s5.x = 123; s5.y = -456; s5.z = 3.14159; printf("s5 = {x = %d, y = %d, z = %.5f}\n\n", s5.x, s5.y, s5.z); @@ -139,9 +139,9 @@ void test6(void) printf("sizeof(struct s6) = %d\n", szof(s6)); printf("precomputed sizeof(struct s6) = %d\n", bszof(s6)); - printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", - offsetof(s6,x), offsetof(s6,y), offsetof(s6,z)); - printf("precomputed offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + printf("offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", + offsetOf(s6,x), offsetOf(s6,y), offsetOf(s6,z)); + printf("precomputed offsetOf(x) = %d, offsetOf(y) = %d, offsetOf(z) = %d\n", boffsetof(s6,x), boffsetof(s6,y), boffsetof(s6,z)); s62.x = 123; s62.y = -456; s62.z = 3.14159; printf("s62 = {x = %d, y = %d, z = %.5f}\n\n", s62.x, s62.y, s62.z); diff --git a/test/regression/varargs2.c b/test/regression/varargs2.c index b96d1940..84860ef3 100644 --- a/test/regression/varargs2.c +++ b/test/regression/varargs2.c @@ -115,15 +115,27 @@ void printf_compat(const char * fmt, ...) } /* The test harness */ - int main() { miniprintf("An int: %d\n", 42); miniprintf("A long long: %l\n", 123456789012345LL); miniprintf("A string: %s\n", "Hello world"); miniprintf("A double: %e\n", 3.141592654); + +#ifndef __K1C__ miniprintf("A small struct: %y\n", (struct Y) { 'x', 12 }); miniprintf("A bigger struct: %z\n", (struct Z) { 123, 456, 789 }); +#endif + +#ifdef __K1C__ + miniprintf("A mixture: %c & %s & %d & %l & %e & %f\n", + 'x', + "Hello, world!", + 42, + 123456789012345LL, + 3.141592654, + 2.71828182); +#else miniprintf("A mixture: %c & %s & %y & %d & %l & %e & %f\n", 'x', "Hello, world!", @@ -132,6 +144,8 @@ int main() 123456789012345LL, 3.141592654, 2.71828182); +#endif + miniprintf2("Twice: %d %e\n", -1, 1.23); miniprintf3("With va_copy: %d %e\n", -1, 1.23); miniprintf_extra(0, 1, 2, 3, 4, 5, 6, 7, |