[llvm-commits] [test-suite] r49249 - in /test-suite/trunk/SingleSource/Benchmarks: BenchmarkGame/ BenchmarkGame/Makefile BenchmarkGame/README.txt BenchmarkGame/fannkuch.c BenchmarkGame/fasta.c BenchmarkGame/n-body.c BenchmarkGame/nsieve-bits.c BenchmarkGame/partialsums.c BenchmarkGame/recursive.c BenchmarkGame/spectral-norm.c Makefile
Owen Anderson
resistor at mac.com
Fri Apr 4 22:50:38 PDT 2008
Author: resistor
Date: Sat Apr 5 00:50:37 2008
New Revision: 49249
URL: http://llvm.org/viewvc/llvm-project?rev=49249&view=rev
Log:
Add testcases from the Benchmark Game: http://shootout.alioth.debian.org/
Added:
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/Makefile
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/README.txt
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fannkuch.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fasta.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/n-body.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/partialsums.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/recursive.c
test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/spectral-norm.c
Modified:
test-suite/trunk/SingleSource/Benchmarks/Makefile
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/Makefile?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/Makefile (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/Makefile Sat Apr 5 00:50:37 2008
@@ -0,0 +1,4 @@
+LEVEL = ../../..
+LDFLAGS += -lm
+
+include $(LEVEL)/SingleSource/Makefile.singlesrc
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/README.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/README.txt?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/README.txt (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/README.txt Sat Apr 5 00:50:37 2008
@@ -0,0 +1,4 @@
+This directory contains testcases culled from the Computer Language Benchmark Game:
+
+ http://shootout.alioth.debian.org/
+
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fannkuch.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fannkuch.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fannkuch.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fannkuch.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,105 @@
+/*
+ * The Computer Lannguage Shootout
+ * http://shootout.alioth.debian.org/
+ * Contributed by Heiner Marxen
+ *
+ * "fannkuch" for C gcc
+ *
+ * $Id: fannkuch-gcc.code,v 1.51 2008-03-06 02:23:27 igouy-guest Exp $
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define Int int
+#define Aint int
+
+ static long
+fannkuch( int n )
+{
+ Aint* perm;
+ Aint* perm1;
+ Aint* count;
+ long flips;
+ long flipsMax;
+ Int r;
+ Int i;
+ Int k;
+ Int didpr;
+ const Int n1 = n - 1;
+
+ if( n < 1 ) return 0;
+
+ perm = calloc(n, sizeof(*perm ));
+ perm1 = calloc(n, sizeof(*perm1));
+ count = calloc(n, sizeof(*count));
+
+ for( i=0 ; i<n ; ++i ) perm1[i] = i; /* initial (trivial) permu */
+
+ r = n; didpr = 0; flipsMax = 0;
+ for(;;) {
+ if( didpr < 30 ) {
+ for( i=0 ; i<n ; ++i ) printf("%d", (int)(1+perm1[i]));
+ printf("\n");
+ ++didpr;
+ }
+ for( ; r!=1 ; --r ) {
+ count[r-1] = r;
+ }
+
+#define XCH(x,y) { Aint t_mp; t_mp=(x); (x)=(y); (y)=t_mp; }
+
+ if( ! (perm1[0]==0 || perm1[n1]==n1) ) {
+ flips = 0;
+ for( i=1 ; i<n ; ++i ) { /* perm = perm1 */
+ perm[i] = perm1[i];
+ }
+ k = perm1[0]; /* cache perm[0] in k */
+ do { /* k!=0 ==> k>0 */
+ Int j;
+ for( i=1, j=k-1 ; i<j ; ++i, --j ) {
+ XCH(perm[i], perm[j])
+ }
+ ++flips;
+ /*
+ * Now exchange k (caching perm[0]) and perm[k]... with care!
+ * XCH(k, perm[k]) does NOT work!
+ */
+ j=perm[k]; perm[k]=k ; k=j;
+ }while( k );
+ if( flipsMax < flips ) {
+ flipsMax = flips;
+ }
+ }
+
+ for(;;) {
+ if( r == n ) {
+ return flipsMax;
+ }
+ /* rotate down perm[0..r] by one */
+ {
+ Int perm0 = perm1[0];
+ i = 0;
+ while( i < r ) {
+ k = i+1;
+ perm1[i] = perm1[k];
+ i = k;
+ }
+ perm1[r] = perm0;
+ }
+ if( (count[r] -= 1) > 0 ) {
+ break;
+ }
+ ++r;
+ }
+ }
+}
+
+ int
+main( int argc, char* argv[] )
+{
+ int n = 11;
+
+ printf("Pfannkuchen(%d) = %ld\n", n, fannkuch(n));
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fasta.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fasta.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fasta.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/fasta.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,134 @@
+/* The Computer Language Benchmarks Game
+ * http://shootout.alioth.debian.org/
+ * Contributed by Joern Inge Vestgaarden
+ * Modified by Jorge Peixoto de Morais Neto
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+
+#define WIDTH 60
+#define MIN(a,b) ((a) <= (b) ? (a) : (b))
+#define NELEMENTS(x) (sizeof (x) / sizeof ((x)[0]))
+
+typedef struct {
+ float p;
+ char c;
+} aminoacid_t;
+
+static inline float myrandom (float max) {
+ unsigned long const IM = 139968;
+ unsigned long const IA = 3877;
+ unsigned long const IC = 29573;
+ static unsigned long last = 42;
+ last = (last * IA + IC) % IM;
+ /*Integer to float conversions are faster if the integer is signed*/
+ return max * (long) last / IM;
+}
+
+static inline void accumulate_probabilities (aminoacid_t *genelist, size_t len) {
+ float cp = 0.0;
+ size_t i;
+ for (i = 0; i < len; i++) {
+ cp += genelist[i].p;
+ genelist[i].p = cp;
+ }
+}
+
+/* This function prints the characters of the string s. When it */
+/* reaches the end of the string, it goes back to the beginning */
+/* It stops when the total number of characters printed is count. */
+/* Between each WIDTH consecutive characters it prints a newline */
+/* This function assumes that WIDTH <= strlen (s) + 1 */
+static void repeat_fasta (char const *s, size_t count) {
+ size_t pos = 0;
+ size_t len = strlen (s);
+ char *s2 = malloc (len + WIDTH);
+ memcpy (s2, s, len);
+ memcpy (s2 + len, s, WIDTH);
+ do {
+ size_t line = MIN(WIDTH, count);
+ fwrite (s2 + pos,1,line,stdout);
+ putchar ('\n');
+ pos += line;
+ if (pos >= len) pos -= len;
+ count -= line;
+ } while (count);
+ free (s2);
+}
+
+/* This function takes a pointer to the first element of an array */
+/* Each element of the array is a struct with a character and */
+/* a float number p between 0 and 1. */
+/* The function generates a random float number r and */
+/* finds the first array element such that p >= r. */
+/* This is a weighted random selection. */
+/* The function then prints the character of the array element. */
+/* This is done count times. */
+/* Between each WIDTH consecutive characters, the function prints a newline */
+static void random_fasta (aminoacid_t const *genelist, size_t count) {
+ do {
+ size_t line = MIN(WIDTH, count);
+ size_t pos = 0;
+ char buf[WIDTH + 1];
+ do {
+ float r = myrandom (1.0);
+ size_t i = 0;
+ while (genelist[i].p < r)
+ ++i; /* Linear search */
+ buf[pos++] = genelist[i].c;
+ } while (pos < line);
+ buf[line] = '\n';
+ fwrite (buf, 1, line + 1, stdout);
+ count -= line;
+ } while (count);
+}
+
+int main (int argc, char **argv) {
+ size_t n = 5000000;
+
+ static aminoacid_t iub[] = {
+ { 0.27, 'a' },
+ { 0.12, 'c' },
+ { 0.12, 'g' },
+ { 0.27, 't' },
+ { 0.02, 'B' },
+ { 0.02, 'D' },
+ { 0.02, 'H' },
+ { 0.02, 'K' },
+ { 0.02, 'M' },
+ { 0.02, 'N' },
+ { 0.02, 'R' },
+ { 0.02, 'S' },
+ { 0.02, 'V' },
+ { 0.02, 'W' },
+ { 0.02, 'Y' }};
+
+ static aminoacid_t homosapiens[] = {
+ { 0.3029549426680, 'a' },
+ { 0.1979883004921, 'c' },
+ { 0.1975473066391, 'g' },
+ { 0.3015094502008, 't' }};
+
+ accumulate_probabilities (iub, NELEMENTS(iub));
+ accumulate_probabilities (homosapiens, NELEMENTS(homosapiens));
+
+ static char const *const alu ="\
+GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG\
+GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA\
+CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT\
+ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA\
+GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG\
+AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC\
+AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
+
+ fputs (">ONE Homo sapiens alu\n", stdout);
+ repeat_fasta (alu, 2 * n);
+ fputs (">TWO IUB ambiguity codes\n", stdout);
+ random_fasta (iub, 3 * n);
+ fputs (">THREE Homo sapiens frequency\n", stdout);
+ random_fasta (homosapiens, 5 * n);
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/n-body.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/n-body.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/n-body.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/n-body.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,141 @@
+/*
+ * The Great Computer Language Shootout
+ * http://shootout.alioth.debian.org/
+ *
+ * contributed by Christoph Bauer
+ *
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define pi 3.141592653589793
+#define solar_mass (4 * pi * pi)
+#define days_per_year 365.24
+
+struct planet {
+ double x, y, z;
+ double vx, vy, vz;
+ double mass;
+};
+
+void advance(int nbodies, struct planet * bodies, double dt)
+{
+ int i, j;
+
+ for (i = 0; i < nbodies; i++) {
+ struct planet * b = &(bodies[i]);
+ for (j = i + 1; j < nbodies; j++) {
+ struct planet * b2 = &(bodies[j]);
+ double dx = b->x - b2->x;
+ double dy = b->y - b2->y;
+ double dz = b->z - b2->z;
+ double distance = sqrt(dx * dx + dy * dy + dz * dz);
+ double mag = dt / (distance * distance * distance);
+ b->vx -= dx * b2->mass * mag;
+ b->vy -= dy * b2->mass * mag;
+ b->vz -= dz * b2->mass * mag;
+ b2->vx += dx * b->mass * mag;
+ b2->vy += dy * b->mass * mag;
+ b2->vz += dz * b->mass * mag;
+ }
+ }
+ for (i = 0; i < nbodies; i++) {
+ struct planet * b = &(bodies[i]);
+ b->x += dt * b->vx;
+ b->y += dt * b->vy;
+ b->z += dt * b->vz;
+ }
+}
+
+double energy(int nbodies, struct planet * bodies)
+{
+ double e;
+ int i, j;
+
+ e = 0.0;
+ for (i = 0; i < nbodies; i++) {
+ struct planet * b = &(bodies[i]);
+ e += 0.5 * b->mass * (b->vx * b->vx + b->vy * b->vy + b->vz * b->vz);
+ for (j = i + 1; j < nbodies; j++) {
+ struct planet * b2 = &(bodies[j]);
+ double dx = b->x - b2->x;
+ double dy = b->y - b2->y;
+ double dz = b->z - b2->z;
+ double distance = sqrt(dx * dx + dy * dy + dz * dz);
+ e -= (b->mass * b2->mass) / distance;
+ }
+ }
+ return e;
+}
+
+void offset_momentum(int nbodies, struct planet * bodies)
+{
+ double px = 0.0, py = 0.0, pz = 0.0;
+ int i;
+ for (i = 0; i < nbodies; i++) {
+ px += bodies[i].vx * bodies[i].mass;
+ py += bodies[i].vy * bodies[i].mass;
+ pz += bodies[i].vz * bodies[i].mass;
+ }
+ bodies[0].vx = - px / solar_mass;
+ bodies[0].vy = - py / solar_mass;
+ bodies[0].vz = - pz / solar_mass;
+}
+
+#define NBODIES 5
+struct planet bodies[NBODIES] = {
+ { /* sun */
+ 0, 0, 0, 0, 0, 0, solar_mass
+ },
+ { /* jupiter */
+ 4.84143144246472090e+00,
+ -1.16032004402742839e+00,
+ -1.03622044471123109e-01,
+ 1.66007664274403694e-03 * days_per_year,
+ 7.69901118419740425e-03 * days_per_year,
+ -6.90460016972063023e-05 * days_per_year,
+ 9.54791938424326609e-04 * solar_mass
+ },
+ { /* saturn */
+ 8.34336671824457987e+00,
+ 4.12479856412430479e+00,
+ -4.03523417114321381e-01,
+ -2.76742510726862411e-03 * days_per_year,
+ 4.99852801234917238e-03 * days_per_year,
+ 2.30417297573763929e-05 * days_per_year,
+ 2.85885980666130812e-04 * solar_mass
+ },
+ { /* uranus */
+ 1.28943695621391310e+01,
+ -1.51111514016986312e+01,
+ -2.23307578892655734e-01,
+ 2.96460137564761618e-03 * days_per_year,
+ 2.37847173959480950e-03 * days_per_year,
+ -2.96589568540237556e-05 * days_per_year,
+ 4.36624404335156298e-05 * solar_mass
+ },
+ { /* neptune */
+ 1.53796971148509165e+01,
+ -2.59193146099879641e+01,
+ 1.79258772950371181e-01,
+ 2.68067772490389322e-03 * days_per_year,
+ 1.62824170038242295e-03 * days_per_year,
+ -9.51592254519715870e-05 * days_per_year,
+ 5.15138902046611451e-05 * solar_mass
+ }
+};
+
+int main(int argc, char ** argv)
+{
+ int n = 5000000;
+ int i;
+
+ offset_momentum(NBODIES, bodies);
+ printf ("%.9f\n", energy(NBODIES, bodies));
+ for (i = 1; i <= n; i++)
+ advance(NBODIES, bodies, 0.01);
+ printf ("%.9f\n", energy(NBODIES, bodies));
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/nsieve-bits.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,36 @@
+/*
+** The Great Computer Language Shootout
+** http://shootout.alioth.debian.org/
+** contributed by Mike Pall
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef unsigned int bits;
+#define BBITS (sizeof(bits) * 8)
+#define BSIZE(x) (((x) / 8) + sizeof(bits))
+#define BMASK(x) (1 << ((x) % BBITS))
+#define BTEST(p, x) ((p)[(x) / BBITS] & BMASK(x))
+#define BFLIP(p, x) (p)[(x) / BBITS] ^= BMASK(x)
+
+int main(int argc, char **argv)
+{
+ unsigned int m, sz = 10000 << 12;
+ bits *primes = (bits *)malloc(BSIZE(sz));
+ if (!primes) return 1;
+ for (m = 0; m <= 2; m++) {
+ unsigned int i, j, count = 0, n = sz >> m;
+ memset(primes, 0xff, BSIZE(n));
+ for (i = 2; i <= n; i++)
+ if (BTEST(primes, i)) {
+ count++;
+ for (j = i + i; j <= n; j += i)
+ if (BTEST(primes, j)) BFLIP(primes, j);
+ }
+ printf("Primes up to %8d %8d\n", n, count);
+ }
+ free(primes);
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/partialsums.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/partialsums.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/partialsums.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/partialsums.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,68 @@
+// The Computer Language Shootout
+// http://shootout.alioth.debian.org/
+// contributed by Greg Buchholz
+//
+// compile with: -O3 -msse2 -lm
+
+#include<math.h>
+#include<stdio.h>
+
+typedef double v2df __attribute__ ((vector_size (16)));
+
+v2df make_vec(double a, double b)
+{
+ v2df v;
+ double *tmp;
+ tmp = (double *)&v; *(tmp) = a; *(tmp+1) = b;
+ return v;
+}
+
+double sum_vec(v2df x)
+{
+ double *tmp = (double *)&x;
+ return *(tmp) + *(tmp+1);
+}
+
+int main(int argc, char* argv[])
+{
+ double twoThrd = 0, sqrts = 0, Flint = 0, Cookson = 0;
+ v2df Harmonic, zeta, poly, alt, Gregory;
+ v2df zero, one, two, init, m_one, kv, av;
+
+ double k, k3, s, c;
+ int n; n = 2500000;
+
+ zero = make_vec( 0.0, 0.0); one = make_vec( 1.0, 1.0);
+ two = make_vec( 2.0, 2.0); m_one = make_vec(-1.0, -1.0);
+ init = make_vec( 1.0, 2.0); av = make_vec( 1.0, -1.0);
+
+ Harmonic = zeta = poly = alt = Gregory = zero;
+
+ for (k=1; k<=n; k++)
+ {
+ twoThrd += pow(2.0/3.0, k-1);
+ sqrts += 1.0/sqrt(k);
+ k3 = k*k*k;
+ s = sin(k); c = cos(k);
+ Flint += 1.0/(k3 * s*s);
+ Cookson += 1.0/(k3 * c*c);
+ }
+
+ for (kv=init; *(double *)(&kv)<=n; kv+=two)
+ {
+ poly += one /(kv*(kv+one));
+ Harmonic+= one / kv;
+ zeta += one /(kv*kv);
+ alt += av / kv;
+ Gregory += av /(two*kv - one);
+ }
+
+#define psum(name,num) printf("%.9f\t%s\n",num,name)
+ psum("(2/3)^k", twoThrd); psum("k^-0.5", sqrts);
+ psum("1/k(k+1)", sum_vec(poly)); psum("Flint Hills", Flint);
+ psum("Cookson Hills", Cookson); psum("Harmonic", sum_vec(Harmonic));
+ psum("Riemann Zeta",sum_vec(zeta)); psum("Alternating Harmonic",sum_vec(alt));
+ psum("Gregory", sum_vec(Gregory));
+
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/recursive.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/recursive.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/recursive.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/recursive.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,55 @@
+/*
+ * The Computer Language Shootout
+ * http://shootout.alioth.debian.org/
+
+ * contributed by bearophile, Jan 24 2006
+ * modified by wolfjb, Feb 28 2007
+ */
+#include <stdio.h>
+
+int ack(int x, int y) {
+ if (x == 0) {
+ return y + 1;
+ }
+
+ return ack(x - 1, ((y | 0) ? ack(x, y - 1) : 1));
+}
+
+int fib(int n) {
+ if (n < 2) {
+ return 1;
+ }
+ return fib(n - 2) + fib(n - 1);
+}
+
+double fibFP(double n) {
+ if (n < 2.0) {
+ return 1.0;
+ }
+ return fibFP(n - 2.0) + fibFP(n - 1.0);
+}
+
+int tak(int x, int y, int z) {
+ if (y < x) {
+ return tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y));
+ }
+ return z;
+}
+
+double takFP(double x, double y, double z) {
+ if (y < x)
+ return takFP( takFP(x-1.0, y, z), takFP(y-1.0, z, x), takFP(z-1.0, x, y) );
+ return z;
+}
+
+int main(int argc, char ** argv) {
+ int n = 10;
+
+ printf("Ack(3,%d): %d\n", n + 1, ack(3, n+1));
+ printf("Fib(%.1f): %.1f\n", 28.0 + n, fibFP(28.0+n));
+ printf("Tak(%d,%d,%d): %d\n", 3 * n, 2 * n, n, tak(3*n, 2*n, n));
+ printf("Fib(3): %d\n", fib(3));
+ printf("Tak(3.0,2.0,1.0): %.1f\n", takFP(3.0, 2.0, 1.0));
+
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/spectral-norm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/spectral-norm.c?rev=49249&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/spectral-norm.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/BenchmarkGame/spectral-norm.c Sat Apr 5 00:50:37 2008
@@ -0,0 +1,53 @@
+/* -*- mode: c -*-
+ *
+ * The Great Computer Language Shootout
+ * http://shootout.alioth.debian.org/
+ *
+ * Contributed by Sebastien Loisel
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+double eval_A(int i, int j) { return 1.0/((i+j)*(i+j+1)/2+i+1); }
+
+void eval_A_times_u(int N, const double u[], double Au[])
+{
+ int i,j;
+ for(i=0;i<N;i++)
+ {
+ Au[i]=0;
+ for(j=0;j<N;j++) Au[i]+=eval_A(i,j)*u[j];
+ }
+}
+
+void eval_At_times_u(int N, const double u[], double Au[])
+{
+ int i,j;
+ for(i=0;i<N;i++)
+ {
+ Au[i]=0;
+ for(j=0;j<N;j++) Au[i]+=eval_A(j,i)*u[j];
+ }
+}
+
+void eval_AtA_times_u(int N, const double u[], double AtAu[])
+{ double v[N]; eval_A_times_u(N,u,v); eval_At_times_u(N,v,AtAu); }
+
+int main(int argc, char *argv[])
+{
+ int i;
+ int N = ((argc == 2) ? atoi(argv[1]) : 2000);
+ double u[N],v[N],vBv,vv;
+ for(i=0;i<N;i++) u[i]=1;
+ for(i=0;i<10;i++)
+ {
+ eval_AtA_times_u(N,u,v);
+ eval_AtA_times_u(N,v,u);
+ }
+ vBv=vv=0;
+ for(i=0;i<N;i++) { vBv+=u[i]*v[i]; vv+=v[i]*v[i]; }
+ printf("%0.9f\n",sqrt(vBv/vv));
+ return 0;
+}
\ No newline at end of file
Modified: test-suite/trunk/SingleSource/Benchmarks/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Makefile?rev=49249&r1=49248&r2=49249&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/Makefile (original)
+++ test-suite/trunk/SingleSource/Benchmarks/Makefile Sat Apr 5 00:50:37 2008
@@ -1,6 +1,6 @@
LEVEL = ../..
PARALLEL_DIRS=Dhrystone CoyoteBench Shootout Shootout-C++ Stanford McGill \
- Misc Misc-C++
+ Misc Misc-C++ BenchmarkGame
# Misc-C++-EH - someday when EH is supported in llvm-gcc we should
# re-enable this test. It always fails and its very slow
# (100MB Bytecode) so we disable it for now.
More information about the llvm-commits
mailing list