diff options
Diffstat (limited to 'test/c')
39 files changed, 315 insertions, 26 deletions
diff --git a/test/c/Makefile b/test/c/Makefile index 4b521bb5..a2a80e06 100644 --- a/test/c/Makefile +++ b/test/c/Makefile @@ -3,16 +3,32 @@ include ../../Makefile.config CCOMP=../../ccomp CCOMPFLAGS=$(CCOMPOPTS) -stdlib ../../runtime -dc -dclight -dasm -CFLAGS=-O1 -Wall +CFLAGS+=-O2 -Wall +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 knucleotide mandelbrot nbody \ +PROGS?=fib integr qsort fft fftsp fftw sha1 sha3 aes almabench \ + lists binarytrees fannkuch mandelbrot nbody \ nsieve nsievebits spectral vmach \ - bisect chomp perlin siphash24 + 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. +# * 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) @@ -29,28 +45,22 @@ all_gcc: $(PROGS:%=%.gcc) %.gcc: %.c $(CC) $(CFLAGS) -o $*.gcc $*.c $(LIBS) -test: +test: all @for i in $(PROGS); do \ - if $(SIMU) ./$$i.compcert | cmp -s - Results/$$i; \ - then echo "$$i: passed"; \ - else echo "$$i: FAILED"; exit 2; \ - fi; \ + SIMU='$(EXECUTE)' ./Runtest $$i ./$$i.compcert;\ done -test_gcc: +test_gcc: all_gcc @for i in $(PROGS); do \ - if ./$$i.gcc | cmp -s - Results/$$i; \ - then echo "$$i: passed"; \ - else echo "$$i: FAILED"; \ - fi; \ + SIMU='$(EXECUTE)' ./Runtest $$i ./$$i.gcc;\ done -bench_gcc: +bench_gcc: all_gcc @for i in $(PROGS); do \ $(TIME) -name $$i -- ./$$i.gcc; \ done -bench: +bench: all @for i in $(PROGS); do \ $(TIME) -name $$i -- ./$$i.compcert; \ done @@ -58,3 +68,4 @@ bench: 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-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-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-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-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-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-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-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-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-mppa_k1c b/test/c/Results/mandelbrot-mppa_k1c Binary files differnew file mode 100644 index 00000000..246f7ce1 --- /dev/null +++ b/test/c/Results/mandelbrot-mppa_k1c 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-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-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-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-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-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/binarytrees.c b/test/c/binarytrees.c index b4b10232..becae164 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,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 728e7a01..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 9cc7a693..befccd8d 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,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 2bd55a18..8ab59c9a 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,19 @@ 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; 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..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 913091d9..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 e4c7d095..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 882325c3..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/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..8deb0f37 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,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 032e7d75..133d55c5 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) { +#ifdef __K1C__ + w = h = 50; +#else w = h = 1000; +#endif } else { w = h = atoi(argv[1]); } @@ -51,14 +59,22 @@ int main (int argc, char **argv) if(bit_num == 8) { + printf("%c", byte_acc); putc(byte_acc,stdout); +#ifdef __K1C__ // stdout isn't flushed enough when --syscall=libstd_scalls.so is passed to the simulator k1-cluster + fflush(stdout); +#endif byte_acc = 0; bit_num = 0; } else if(x == w-1) { byte_acc <<= (8-w%8); + printf("%c", byte_acc); putc(byte_acc,stdout); +#ifdef __K1C__ // stdout isn't flushed enough when --syscall=libstd_scalls.so is passed to the simulator k1-cluster + fflush(stdout); +#endif byte_acc = 0; bit_num = 0; } diff --git a/test/c/nbody.c b/test/c/nbody.c index 530c41fa..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 819d47f1..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 743a5ffd..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 e7bbd22d..29ebf964 100644 --- a/test/c/perlin.c +++ b/test/c/perlin.c @@ -63,13 +63,22 @@ 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(); double x, y, z, sum = 0.0; - for (x = -5.0; x < 5.0; x += 0.1) - for (y = -5.0; y < 5.0; y += 0.1) - for (z = -5.0; z < 5.0; z += 0.1) + for (x = MIN; x < MAX; x += INCREMENT) + for (y = MIN; y < MAX; y += INCREMENT) + for (z = MIN; z < MAX; z += INCREMENT) sum += noise(x, y, z); printf("%.4e\n", sum); diff --git a/test/c/qsort.c b/test/c/qsort.c index 66eef68d..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/spectral.c b/test/c/spectral.c index f7dc90ee..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 815cb710..5858d4d6 100644 --- a/test/c/vmach.c +++ b/test/c/vmach.c @@ -159,8 +159,14 @@ 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, 30, 0, 0), +/* 0 */ I(WCONST, FIBSIZE, 0, 0), /* 1 */ I(WCALL1_pop1, 0, 3-1-1, 0), /* 2 */ I(WSTOP, 0, 1, 0), /* 3 */ I(WCONST, 2, 0, 0), @@ -175,10 +181,21 @@ unsigned int wordcode_fib[] = { /* 12 */ I(WCONST, 1, 0, 0), /* 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, 6, 0, 0), -/* 1 */ I(WCONST, 12, 0, 0), -/* 2 */ I(WCONST, 18, 0, 0), +/* 0 */ I(WCONST, TAKSIZE1, 0, 0), +/* 1 */ I(WCONST, TAKSIZE2, 0, 0), +/* 2 */ I(WCONST, TAKSIZE3, 0, 0), /* 3 */ I(WCALL3, 3, 6-3-2, 0), /* 4 */ I(0, 1, 2, 0), /* 5 */ I(WSTOP, 0, 1, 0), @@ -203,8 +220,8 @@ unsigned int wordcode_tak[] = { int main(int argc, char ** argv) { - printf("fib(30) = %ld\n", wordcode_interp(wordcode_fib)); - printf("tak(18, 12, 6) = %ld\n", wordcode_interp(wordcode_tak)); + printf("fib(%d) = %ld\n", FIBSIZE, wordcode_interp(wordcode_fib)); + printf("tak(%d, %d, %d) = %ld\n", TAKSIZE3, TAKSIZE2, TAKSIZE1, wordcode_interp(wordcode_tak)); return 0; } |