aboutsummaryrefslogtreecommitdiffstats
path: root/test/c
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-09-10 17:50:42 +0200
committerCyril SIX <cyril.six@kalray.eu>2019-09-10 17:50:42 +0200
commit5b6c019a507688dfcf63b9ef54f7731137422ab5 (patch)
treee9b5e653c1facbedc8756c1320f5ac9563695c80 /test/c
parent8caa5a2e1f825b6e3d6b87e294c1a53c65d62612 (diff)
downloadcompcert-kvx-5b6c019a507688dfcf63b9ef54f7731137422ab5.tar.gz
compcert-kvx-5b6c019a507688dfcf63b9ef54f7731137422ab5.zip
Starting to modify official CompCert tests to be passable with the simu
Diffstat (limited to 'test/c')
-rw-r--r--test/c/Makefile23
-rw-r--r--test/c/Results/binarytrees12
-rw-r--r--test/c/Results/fannkuch62
-rw-r--r--test/c/Results/fft2
-rw-r--r--test/c/Results/fftsp2
-rw-r--r--test/c/Results/fib2
-rw-r--r--test/c/Results/integr2
-rw-r--r--test/c/Results/knucleotide27
-rw-r--r--test/c/binarytrees.c4
-rw-r--r--test/c/fannkuch.c6
-rw-r--r--test/c/fft.c5
-rw-r--r--test/c/fftsp.c2
-rw-r--r--test/c/fftw.c2
-rw-r--r--test/c/fib.c4
-rw-r--r--test/c/integr.c2
-rw-r--r--test/c/knucleotide.c6
-rw-r--r--test/c/lists.c5
-rw-r--r--test/c/qsort.c2
18 files changed, 81 insertions, 89 deletions
diff --git a/test/c/Makefile b/test/c/Makefile
index 14c856ff..9580c8cc 100644
--- a/test/c/Makefile
+++ b/test/c/Makefile
@@ -3,18 +3,22 @@ include ../../Makefile.config
CCOMP=../../ccomp
CCOMPFLAGS=$(CCOMPOPTS) -stdlib ../../runtime -dc -dclight -dasm
-CFLAGS+=-O1 -Wall
+CFLAGS+=-O2 -Wall
+EXECUTE:=timeout --signal=SIGTERM 90s $(EXECUTE)
LIBS=$(LIBMATH)
#TIME=xtime -o /dev/null -mintime 2.0 # Xavier's hack
TIME=time >/dev/null # Otherwise
-PROGS?=fib qsort fftw sha1 sha3 aes \
- lists binarytrees fannkuch \
- nsieve nsievebits vmach \
- chomp perlin siphash24\
- integr fft fftsp almabench knucleotide mandelbrot nbody spectral bisect
+PROGS?=fib integr qsort fft fftsp fftw sha1 sha3 aes almabench \
+ lists binarytrees fannkuch mandelbrot nbody \
+ nsieve nsievebits spectral vmach \
+ bisect chomp perlin siphash24
+
+# Kalray NOTE : removed knucleotide from PROGS, it is hard to edit the input
+# to modify its size without resulting in a seg fault, and the base input
+# takes a too long time to complete in the simulator.
all: $(PROGS:%=%.compcert)
@@ -33,7 +37,8 @@ all_gcc: $(PROGS:%=%.gcc)
test: all
@for i in $(PROGS); do \
- if $(EXECUTE) ./$$i.compcert | cmp -s - Results/$$i; \
+ $(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; \
@@ -41,7 +46,8 @@ test: all
test_gcc: all_gcc
@for i in $(PROGS); do \
- if $(EXECUTE) ./$$i.gcc | cmp -s - Results/$$i; \
+ $(EXECUTE) ./$$i.gcc > $$i.gcc.out;\
+ if cmp -s $$i.gcc.out Results/$$i; \
then echo "$$i: passed"; \
else echo "$$i: FAILED"; \
fi; \
@@ -60,3 +66,4 @@ bench: all
clean:
rm -f *.compcert *.gcc
rm -f *.compcert.c *.light.c *.parsed.c *.s *.o *.sdump *~
+ rm -f *.out
diff --git a/test/c/Results/binarytrees b/test/c/Results/binarytrees
index 9dfe1355..db0f0ef7 100644
--- a/test/c/Results/binarytrees
+++ b/test/c/Results/binarytrees
@@ -1,7 +1,5 @@
-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
+stretch tree of depth 9 check: -1
+512 trees of depth 4 check: -512
+128 trees of depth 6 check: -128
+32 trees of depth 8 check: -32
+long lived tree of depth 8 check: -1
diff --git a/test/c/Results/fannkuch b/test/c/Results/fannkuch
index be1815d4..dac06137 100644
--- a/test/c/Results/fannkuch
+++ b/test/c/Results/fannkuch
@@ -1,31 +1,31 @@
-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
+12345678
+21345678
+23145678
+32145678
+31245678
+13245678
+23415678
+32415678
+34215678
+43215678
+42315678
+24315678
+34125678
+43125678
+41325678
+14325678
+13425678
+31425678
+41235678
+14235678
+12435678
+21435678
+24135678
+42135678
+23451678
+32451678
+34251678
+43251678
+42351678
+24351678
+Pfannkuchen(8) = 22
diff --git a/test/c/Results/fft b/test/c/Results/fft
index a48608b0..cbeb0999 100644
--- a/test/c/Results/fft
+++ b/test/c/Results/fft
@@ -1 +1 @@
-262144 points, result OK
+4096 points, result OK
diff --git a/test/c/Results/fftsp b/test/c/Results/fftsp
index cbeb0999..36264416 100644
--- a/test/c/Results/fftsp
+++ b/test/c/Results/fftsp
@@ -1 +1 @@
-4096 points, result OK
+64 points, result OK
diff --git a/test/c/Results/fib b/test/c/Results/fib
index 84ce6474..d8beea8c 100644
--- a/test/c/Results/fib
+++ b/test/c/Results/fib
@@ -1 +1 @@
-fib(35) = 14930352
+fib(26) = 196418
diff --git a/test/c/Results/integr b/test/c/Results/integr
index 973806c9..bb755482 100644
--- a/test/c/Results/integr
+++ b/test/c/Results/integr
@@ -1 +1 @@
-integr(square, 0.0, 1.0, 10000000) = 0.333333
+integr(square, 0.0, 1.0, 1000000) = 0.333333
diff --git a/test/c/Results/knucleotide b/test/c/Results/knucleotide
index d13ae7dc..e69de29b 100644
--- a/test/c/Results/knucleotide
+++ b/test/c/Results/knucleotide
@@ -1,27 +0,0 @@
-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/binarytrees.c b/test/c/binarytrees.c
index b4b10232..f2921d9a 100644
--- a/test/c/binarytrees.c
+++ b/test/c/binarytrees.c
@@ -7,6 +7,7 @@
icc -O3 -ip -unroll -static binary-trees.c -lm
*/
+#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -24,6 +25,7 @@ treeNode* NewTreeNode(treeNode* left, treeNode* right, long item)
treeNode* new;
new = (treeNode*)malloc(sizeof(treeNode));
+ assert(new != NULL && "NewTreeNode: new malloc failed");
new->left = left;
new->right = right;
@@ -73,7 +75,7 @@ int main(int argc, char* argv[])
unsigned N, depth, minDepth, maxDepth, stretchDepth;
treeNode *stretchTree, *longLivedTree, *tempTree;
- N = argc < 2 ? 12 : atol(argv[1]);
+ N = argc < 2 ? 8 : atol(argv[1]);
minDepth = 4;
diff --git a/test/c/fannkuch.c b/test/c/fannkuch.c
index 9cc7a693..ddaa7309 100644
--- a/test/c/fannkuch.c
+++ b/test/c/fannkuch.c
@@ -8,6 +8,7 @@
* $Id: fannkuch-gcc.code,v 1.33 2006/02/25 16:38:58 igouy-guest Exp $
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -31,8 +32,11 @@ fannkuch( int n )
if( n < 1 ) return 0;
perm = calloc(n, sizeof(*perm ));
+ assert(perm != NULL && "fannkuch: perm malloc failed");
perm1 = calloc(n, sizeof(*perm1));
+ assert(perm != NULL && "fannkuch: perm1 malloc failed");
count = calloc(n, sizeof(*count));
+ assert(perm != NULL && "fannkuch: count malloc failed");
for( i=0 ; i<n ; ++i ) perm1[i] = i; /* initial (trivial) permu */
@@ -98,7 +102,7 @@ fannkuch( int n )
int
main( int argc, char* argv[] )
{
- int n = (argc>1) ? atoi(argv[1]) : 10;
+ int n = (argc>1) ? atoi(argv[1]) : 8;
printf("Pfannkuchen(%d) = %ld\n", n, fannkuch(n));
return 0;
diff --git a/test/c/fft.c b/test/c/fft.c
index 2bd55a18..f91f5300 100644
--- a/test/c/fft.c
+++ b/test/c/fft.c
@@ -3,6 +3,7 @@
by: Dave Edelblute, edelblut@cod.nosc.mil, 05 Jan 1993
*/
+#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
@@ -151,13 +152,15 @@ int main(int argc, char ** argv)
double enp, t, y, z, zr, zi, zm, a;
double * xr, * xi, * pxr, * pxi;
- if (argc >= 2) n = atoi(argv[1]); else n = 18;
+ if (argc >= 2) n = atoi(argv[1]); else n = 12;
np = 1 << n;
enp = np;
npm = np / 2 - 1;
t = PI / enp;
xr = calloc(np, sizeof(double));
+ assert(xr != NULL && "xr calloc failed");
xi = calloc(np, sizeof(double));
+ assert(xi != NULL && "xi calloc failed");
pxr = xr;
pxi = xi;
for (nruns = 0; nruns < NRUNS; nruns++) {
diff --git a/test/c/fftsp.c b/test/c/fftsp.c
index 26b18b62..316ef714 100644
--- a/test/c/fftsp.c
+++ b/test/c/fftsp.c
@@ -153,7 +153,7 @@ int main(int argc, char ** argv)
float enp, t, y, z, zr, zi, zm, a;
float * xr, * xi, * pxr, * pxi;
- if (argc >= 2) n = atoi(argv[1]); else n = 12;
+ if (argc >= 2) n = atoi(argv[1]); else n = 6;
np = 1 << n;
enp = np;
npm = np / 2 - 1;
diff --git a/test/c/fftw.c b/test/c/fftw.c
index 913091d9..1d5b6526 100644
--- a/test/c/fftw.c
+++ b/test/c/fftw.c
@@ -74,7 +74,7 @@ const E KP1_847759065 = ((E) +1.847759065022573512256366378793576573644833252);
/* Test harness */
-#define NRUNS (100 * 1000)
+#define NRUNS (100 * 10)
int main()
{
diff --git a/test/c/fib.c b/test/c/fib.c
index 19548415..77aa7bb9 100644
--- a/test/c/fib.c
+++ b/test/c/fib.c
@@ -12,11 +12,7 @@ int fib(int n)
int main(int argc, char ** argv)
{
int n, r;
-#ifdef __K1C_COS__
if (argc >= 2) n = atoi(argv[1]); else n = 26;
-#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 882325c3..9c762297 100644
--- a/test/c/integr.c
+++ b/test/c/integr.c
@@ -25,7 +25,7 @@ double test(int n)
int main(int argc, char ** argv)
{
int n; double r;
- if (argc >= 2) n = atoi(argv[1]); else n = 10000000;
+ if (argc >= 2) n = atoi(argv[1]); else n = 1000000;
r = test(n);
printf("integr(square, 0.0, 1.0, %d) = %g\n", n, r);
return 0;
diff --git a/test/c/knucleotide.c b/test/c/knucleotide.c
index 3ac469be..1982834e 100644
--- a/test/c/knucleotide.c
+++ b/test/c/knucleotide.c
@@ -8,6 +8,7 @@
http://cvs.alioth.debian.org/cgi-bin/cvsweb.cgi/shootout/bench/Include/?cvsroot=shootout
*/
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -76,9 +77,11 @@ struct ht_node *ht_node_create(char *key) {
struct ht_ht *ht_create(int size) {
int i = 0;
struct ht_ht *ht = (struct ht_ht *)malloc(sizeof(struct ht_ht));
+ assert (ht != NULL && "ht_create: ht malloc failed");
while (ht_prime_list[i] < size) { i++; }
ht->size = ht_prime_list[i];
ht->tbl = (struct ht_node **)calloc(ht->size, sizeof(struct ht_node *));
+ assert (ht->tbl != NULL && "ht_create: ht->tbl calloc failed");
ht->iter_index = 0;
ht->iter_next = 0;
ht->items = 0;
@@ -250,6 +253,7 @@ write_frequencies (int fl, char *buffer, long buflen)
size++;
}
s = calloc (size, sizeof (sorter));
+ assert(s != NULL && "write_frequencies: s alloc failed");
i = 0;
for (nd = ht_first (ht); nd != NULL; nd = ht_next (ht))
{
@@ -293,6 +297,7 @@ main ()
FILE * f;
line = malloc (256);
+ assert (line != NULL && "line alloc failed");
if (!line)
return 2;
seqlen = 0;
@@ -308,6 +313,7 @@ main ()
buflen = 10240;
buffer = malloc (buflen + 1);
+ assert (buffer != NULL && "buffer alloc failed");
if (!buffer)
return 2;
x = buffer;
diff --git a/test/c/lists.c b/test/c/lists.c
index ced384c0..d1c67954 100644
--- a/test/c/lists.c
+++ b/test/c/lists.c
@@ -1,5 +1,6 @@
/* List manipulations */
+#include <assert.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -11,6 +12,7 @@ struct list * buildlist(int n)
struct list * r;
if (n < 0) return NULL;
r = malloc(sizeof(struct list));
+ assert(r != NULL && "buildlist: r malloc failed");
r->hd = n;
r->tl = buildlist(n - 1);
return r;
@@ -21,6 +23,7 @@ struct list * reverselist (struct list * l)
struct list * r, * r2;
for (r = NULL; l != NULL; l = l->tl) {
r2 = malloc(sizeof(struct list));
+ assert(r2 != NULL && "reverselist: r2 malloc failed");
r2->hd = l->hd;
r2->tl = r;
r = r2;
@@ -58,7 +61,7 @@ int main(int argc, char ** argv)
int n, niter, i;
struct list * l;
- if (argc >= 2) n = atoi(argv[1]); else n = 1000;
+ if (argc >= 2) n = atoi(argv[1]); else n = 100;
if (argc >= 3) niter = atoi(argv[1]); else niter = 20000;
l = buildlist(n);
if (checklist(n, reverselist(l))) {
diff --git a/test/c/qsort.c b/test/c/qsort.c
index 66eef68d..a9d5757a 100644
--- a/test/c/qsort.c
+++ b/test/c/qsort.c
@@ -34,7 +34,7 @@ int main(int argc, char ** argv)
int n, i, j;
int * a, * b;
- if (argc >= 2) n = atoi(argv[1]); else n = 100000;
+ if (argc >= 2) n = atoi(argv[1]); else n = 10000;
a = malloc(n * sizeof(int));
b = malloc(n * sizeof(int));
for (j = 0; j < NITER; j++) {