[llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/MIRROR.txt Makefile SOLUTION.txt mason.c ref.in test.in
Chris Lattner
lattner at cs.uiuc.edu
Sat Oct 11 16:20:51 PDT 2003
Changes in directory llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason:
MIRROR.txt added (r1.1)
Makefile added (r1.1)
SOLUTION.txt added (r1.1)
mason.c added (r1.1)
ref.in added (r1.1)
test.in added (r1.1)
---
Log message:
Initial checkin of the FreeBench benchmark suite
---
Diffs of the changes: (+643 -0)
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/MIRROR.txt
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/MIRROR.txt:1.1
*** /dev/null Sat Oct 11 16:18:57 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/MIRROR.txt Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1,2 ----
+ sol <-> mirror
+ 0 121 201 210 210 201 020 210 102 120 212 101
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile:1.1
*** /dev/null Sat Oct 11 16:18:57 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/Makefile Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1,12 ----
+ LEVEL = ../../../../../..
+
+ PROG = mason
+ CPPFLAGS = -DVERSION='"1.00"' -DCOMPDATE="\"today\"" -DCFLAGS='""' -DHOSTNAME="\"thishost\""
+ #LDFLAGS = -lm
+ ifdef LARGE_PROBLEM_SIZE
+ RUN_OPTIONS = ref.in
+ else
+ RUN_OPTIONS = test.in
+ endif
+ include $(LEVEL)/test/Programs/MultiSource/Makefile.multisrc
+
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/SOLUTION.txt
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/SOLUTION.txt:1.1
*** /dev/null Sat Oct 11 16:18:57 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/SOLUTION.txt Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1,242 ----
+ Solving the Binary Arts(tm) Tripple Cross puzzle, by T.
+
+
+ There are two possible ways to move in the puzzle:
+ The horizontal shuttle with 3 possible positions (from left to right: 0,1,2)
+ The flip with 2 positions (left-up och left-down)
+ First move the shuttle to 1 and flip to left-down so that the shape of
+ the puzzle looks like this:
+
+ X X
+ X X X X X X X
+ X X X X X X X
+ X X
+
+ There are 9 squares that are marked, we will call them:
+ A - top left part of what should become a ball
+ B - top right part of ball
+ C - bottom left part of ball
+ D - bottom right part of ball
+ bi - the text "binary"
+ ar - the text "arts(tm)"
+ y - there are 3 yellow blobs, all the same. I just call them blobs.
+
+ The correct solution to the puzzle looks like:
+
+ - -
+ y y y - - A B
+ - - - - - C D
+ bi ar
+
+ We will number the positions in the puzzle (with left-down flip) :
+
+ 16 17
+ 0 1 2 3 4 5 6
+ 7 8 9 10 11 12 13
+ 14 15
+
+ How to move:
+ Move sequences are written in compact form.
+ Starting position is assumed to be with flip left-down.
+ Each single digit means position the shuttle:
+ 0: leftmost, 1: middle, 2: rightmost
+ After each positioning of the shuttle, a toggle of the flip is assumed.
+
+ We will solve the puzzle by doing a sequence of moves to for each of the
+ named squares to put it into the correct position. We will start with A.
+ Locate A and find the corresponding number of where it is in the
+ above chart. Then look up that number in the table below to
+ find a sequence. NOTE: move sequences are written backwards. Read them
+ right to left.
+ If A is already at the correct position (5) no moves are needed.
+ If A is at 3 you should do the move sequence 1202 (It's backwards, remember?)
+
+ A
+ 0 2021 0102
+ 1 20 2102
+ 2 20 2101
+ 3 2021
+ 4 2010
+ 5 No moves needed
+ 6 2101
+ 7 20 2010 1020
+ 8 2020 1020
+ 9 2021 0120
+ 10 2020
+ 11 0201
+ 12 02
+ 13 0210
+ 14 2020 1010
+ 15 20 2010
+ 16 20
+ 17 21
+
+ "A" should now be at 5 (which also means B can't be at 5).
+ Continue with position of B, same way...
+
+ B
+ 0 20 1021 0102
+ 1 1021 2102
+ 2 10 2121 0210
+ 3 12 1010 2012
+ 4 10 1010
+ 5 -
+ 6 No moves needed
+ 7 1021 2010 1020
+ 8 20 1020 1020
+ 9 1210 2121 0120
+ 10 21 2010 2121
+ 11 01 0101
+ 12 0101
+ 13 01
+ 14 20 1020 1021
+ 15 21 2010 2120
+ 16 1010
+ 17 10
+
+
+ C
+ 0 21 2021 0102
+ 1 2120 2010 2010
+ 2 2101 2021 0210
+ 3 20 1012 0212
+ 4 02 0121 2101
+ 5 -
+ 6 -
+ 7 1212 0120 2121
+ 8 02 1021 0120
+ 9 2012 0210 1210
+ 10 1021 2020 1020
+ 11 1201 2120
+ 12 No moves needed
+ 13 2102 1012
+ 14 02 1012 0120
+ 15 0212 0210 1020
+ 16 1210 1201 2101
+ 17 2121 0210
+
+
+ D
+ 0 01 0201 2020 2012
+ 1 0102 0120 2101 2010
+ 2 1201 2020 2101 0121
+ 3 2121 2020 1202 0212
+ 4 20 1212 1202 0202
+ 5 -
+ 6 -
+ 7 0210 2102 0210 1020
+ 8 1201 0201 0201
+ 9 2121 2020 1020 1012
+ 10 2020 1210 2020
+ 11 12 0120 1010 1201
+ 12 -
+ 13 No moves needed
+ 14 1020 1020 1021
+ 15 2102 0101 2010
+ 16 2101 0120 1012 1010
+ 17 12 0121 0202 0201
+
+
+ bi
+ 0 0210 1010 2020 1020
+ 1 2101 2010 1212 1010
+ 2 0201 0202 0101 0120
+ 3 2020 2020 1020 2020 2010
+ 4 0101 2020 1210 2020 1010
+ 5 -
+ 6 -
+ 7 12 0101 0120 2021
+ 8 21 2021 0201 2102 0120
+ 9 2010 1210 2020 2012 1010
+ 10 0101 2121 0102 1012
+ 11 12 0202 1010 1021
+ 12 -
+ 13 -
+ 14 No moves needed
+ 15 20 2012 0101 2012 0201
+ 16 21 2101 0102 0201 0212
+ 17 1201 0202 0101 0121
+
+
+ ar
+ 0 2010 1212 1010 2101
+ 1 1012 1020 1202 1202 1021
+ 2 10 2010 2021 0202 0201
+ 3 0121 2102 1021 0210 1210
+ 4 12 1021 0210 2101
+ 5 -
+ 6 -
+ 7 12 1010 1202 1010 1201
+ 8 0210 1020 2020 2021 0120
+ 9 0121 0121 0121 0121
+ 10 2102 1021 0210
+ 11 1210 1210 1210 1210
+ 12 -
+ 13 -
+ 14 -
+ 15 No moves needed
+ 16 12 1021 0201 2121 0102
+ 17 1012 0101 2121 0102
+
+
+ 1st blob (you may chose the blob that gives the shortest sequence here)
+ 0 No moves needed
+ 1 01 2021 2101 2101 2101 2102 0210
+ 2 01 0201 2021 0202 1010 2010
+ 3 02 0201 2020 1202 0120 2010
+ 4 01 2010 2101 0120 2101 0121 0210
+ 5 -
+ 6 -
+ 7 20 1010 1202 0202 0101 0120 2020
+ 8 21 0201 0201 0202 1020 2102 1201
+ 9 1201 0101 2021 0202 0101 0121
+ 10 01 0201 0120 2012 0210 2010
+ 11 01 2012 1010 1202 1010 1201 0210
+ 12 -
+ 13 -
+ 14 -
+ 15 -
+ 16 2121 2102 1010 2012 0210 1202
+ 17 10 1020 1210 2121 0121 2012 1020
+
+
+ 2nd blob
+ 0 -
+ 1 No moves needed
+ 2 10 1210 2102 1021 0101
+ 3 20 1201 2121 0121 0121 0101
+ 4 2121 0210 2102 1012
+ 5 -
+ 6 -
+ 7 21 0202 1210 1212 1021 2020 2101
+ 8 20 2101 0202 0202 0210 1202
+ 9 1010 1210 1210 1210 1201
+ 10 21 2102 1021 0101 2101 2101
+ 11 1212 1021 0201 0212 0210 1010 2120
+ 12 -
+ 13 -
+ 14 -
+ 15 -
+ 16 2012 0120 1201
+ 17 21 2101 2101 2101 2102
+
+
+ Last blob
+ 0 -
+ 1 -
+ 2 No moves needed
+ 3 02 0201 2020 1202 0120 2010
+ 4 2012 0121 2101 0120 1201 2121 0101
+ 5 -
+ 6 -
+ 7 2101 2120 1212 1012 1020 2020 1020
+ 8 2102 1210 1201 0202 0202 1201 2120
+ 9 1012 1012 1012 1012
+ 10 10 2102 1012 1012 1012 1010 1201
+ 11 0102 1020 2012 0120 1201 0201 2010
+ 12 -
+ 13 -
+ 14 -
+ 15 -
+ 16 2101 2101 2101 2101
+ 17 21 2101 2101 2101 2102
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/mason.c
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/mason.c:1.1
*** /dev/null Sat Oct 11 16:18:57 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/mason.c Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1,385 ----
+ /* Copyright (c) 2000 Tord Hansson */
+
+ #define BENCHMARK
+
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ typedef struct { int a,b,c,d,bi,ar,g1,g2,g3; } p_type;
+
+ static p_type m0u(p_type p) {
+ int m[]={0,
+ 8,
+ 1,
+ 2,
+ 16,
+ 5,
+ 13,
+ 7,
+ 14,
+ 9,
+ 3,
+ 4,
+ 11,
+ 12,
+ 15,
+ 10,
+ 17,
+ 6};
+ p_type pu;
+
+ pu.a = m[p.a];
+ pu.b = m[p.b];
+ pu.c = m[p.c];
+ pu.d = m[p.d];
+ pu.bi = m[p.bi];
+ pu.ar = m[p.ar];
+ pu.g1 = m[p.g1];
+ pu.g2 = m[p.g2];
+ pu.g3 = m[p.g3];
+ return pu;
+ }
+
+ static p_type m1u(p_type p) {
+ return p;
+ }
+
+ static p_type m2u(p_type p) {
+ int m[]={1,
+ 2,
+ 9,
+ 10,
+ 4,
+ 17,
+ 6,
+ 0,
+ 8,
+ 15,
+ 11,
+ 12,
+ 5,
+ 13,
+ 7,
+ 14,
+ 3,
+ 16};
+ p_type pu;
+
+ pu.a = m[p.a];
+ pu.b = m[p.b];
+ pu.c = m[p.c];
+ pu.d = m[p.d];
+ pu.bi = m[p.bi];
+ pu.ar = m[p.ar];
+ pu.g1 = m[p.g1];
+ pu.g2 = m[p.g2];
+ pu.g3 = m[p.g3];
+ return pu;
+
+ }
+
+ static p_type m0d(p_type p) {
+ int m[]={0,
+ 2,
+ 3,
+ 10,
+ 11,
+ 5,
+ 17,
+ 7,
+ 1,
+ 9,
+ 15,
+ 12,
+ 13,
+ 6,
+ 8,
+ 14,
+ 4,
+ 16};
+ p_type pu;
+
+ pu.a = m[p.a];
+ pu.b = m[p.b];
+ pu.c = m[p.c];
+ pu.d = m[p.d];
+ pu.bi = m[p.bi];
+ pu.ar = m[p.ar];
+ pu.g1 = m[p.g1];
+ pu.g2 = m[p.g2];
+ pu.g3 = m[p.g3];
+ return pu;
+
+ }
+
+ static p_type m1d(p_type p) {
+ return p;
+ }
+
+ static p_type m2d(p_type p) {
+ int m[]={7,
+ 0,
+ 1,
+ 16,
+ 4,
+ 12,
+ 6,
+ 14,
+ 8,
+ 2,
+ 3,
+ 10,
+ 11,
+ 13,
+ 15,
+ 9,
+ 17,
+ 5};
+ p_type pu;
+
+ pu.a = m[p.a];
+ pu.b = m[p.b];
+ pu.c = m[p.c];
+ pu.d = m[p.d];
+ pu.bi = m[p.bi];
+ pu.ar = m[p.ar];
+ pu.g1 = m[p.g1];
+ pu.g2 = m[p.g2];
+ pu.g3 = m[p.g3];
+ return pu;
+ }
+
+ #define A 0x1
+ #define B 0x2
+ #define C 0x4
+ #define D 0x8
+ #define BI 0x10
+ #define AR 0x20
+ #define G 0x40
+
+ static int md(p_type p,int maxdep,int dep,int last);
+ static int mu(p_type p,int maxdep,int dep,int last) {
+ static int near[] = {0x50,0x70,0x70,0x75,0xf,0xf,0xf,0x70,0x70,0x70,0x7d,0x2b,0x2f,0xf,0x50,0x64,0x67,0xf};
+ #define KKK 4
+ /* 2 : {0x40,0x40,0x40,0x60,0x0,0x5,0xa,0x50,0x70,0x70,0x24,0xc,0x9,0xe,0x20,0x10,0x1,0x3}; */
+ /* {0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,1};*/
+
+ int win;
+ if( dep == maxdep - KKK ) {
+ if(( B & near[p.b]) == 0) return 0;
+ if(( D & near[p.d]) == 0) return 0;
+ if(( BI & near[p.bi]) == 0) return 0;
+ if(( AR & near[p.ar]) == 0) return 0;
+ if(( A & near[p.a]) == 0) return 0;
+ if(( C & near[p.c]) == 0) return 0;
+ if(( G & near[p.g1]) == 0) return 0;
+ if(( G & near[p.g2]) == 0) return 0;
+ if(( G & near[p.g3]) == 0) return 0;
+ }
+ if((p.a == 5) && (p.b == 6) && (p.c == 12) && (p.d == 13) && (p.bi == 14) && (p.ar == 15) && ((p.g1+p.g2+p.g3) == 3) ) {
+ printf("Gul: %d %d %d\n",p.g1,p.g2,p.g3);
+ printf("bin+art: %d %d\n",p.bi,p.ar);
+ return 1;
+ } else {
+ if(maxdep <= dep) return 0;
+
+ win = (last == 0 ? 0 : md(m0u(p),maxdep,dep+1,0));
+ if(win == 1) {
+ putchar('0');
+ if((dep % 4) == 0)putchar(' ');
+ return win;
+ } else {
+ win = (last == 1 ? 0 : md(m1u(p),maxdep,dep+1,1));
+ if(win == 1) {
+ putchar('1');
+ if((dep % 4) == 0)putchar(' ');
+ return win;
+ } else {
+ win = (last == 2 ? 0 : md(m2u(p),maxdep,dep+1,2));
+ if(win == 1) {
+ putchar('2');
+ if((dep % 4) == 0)putchar(' ');
+ }
+ return win;
+ }
+ }
+ }
+ }
+
+
+ static int md(p_type p,int maxdep,int dep,int last) {
+ int win;
+
+ if(maxdep <= dep) return 0;
+
+ win = (last == 0 ? 0 : mu(m0d(p),maxdep,dep+1,0));
+ if(win == 1) {
+ putchar('0');
+ if((dep % 4) == 0)putchar(' ');
+ return win;
+ } else {
+ win = (last == 1 ? 0 : mu(m1d(p),maxdep,dep+1,1));
+ if(win == 1) {
+ putchar('1');
+ if((dep % 4) == 0)putchar(' ');
+ return win;
+ } else {
+ win = (last == 2 ? 0 : mu(m2d(p),maxdep,dep+1,2));
+ if(win == 1) {
+ putchar('2');
+ if((dep % 4) == 0)putchar(' ');
+ }
+ return win;
+ }
+ }
+ }
+
+ #ifndef BENCHMARK
+ static void prnear(int k);
+ #endif
+
+ int main(int argc,char *argv[]) {
+ int k;
+ p_type p;
+ #ifdef BENCHMARK
+ FILE *fp;
+ #endif
+
+ fprintf(stderr,"Compile date: %s\n", COMPDATE);
+ fprintf(stderr,"Compiler switches: %s\n", CFLAGS);
+
+ #ifndef BENCHMARK
+ if(argc < 10) {
+ if(argc == 2) {
+ prnear(atoi(argv[1]));
+ } else {
+ printf(" 16 17\n");
+ printf("0 1 2 3 4 5 6\n");
+ printf("7 8 9 10 11 12 13\n");
+ printf(" 14 15\n\nEnter A B C D e f G G G :\n");
+ printf("G G G A B\n");
+ printf("e f C D\n");
+ }
+ } else {
+ p.a = atoi(argv[1]);
+ p.b = atoi(argv[2]);
+ p.c = atoi(argv[3]);
+ p.d = atoi(argv[4]);
+ p.bi = atoi(argv[5]);
+ p.ar = atoi(argv[6]);
+ p.g1 = atoi(argv[7]);
+ p.g2 = atoi(argv[8]);
+ p.g3 = atoi(argv[9]);
+
+ for(k=2;;k+=2) {
+ printf("Trying %d\n",k);
+ if(mu(p,k,0,-1) == 1) {
+ putchar('\n');
+ exit(0);
+ }
+ }
+ }
+ #else /* Run it as a benchmark */
+ fp=fopen(argv[1],"r");
+ if (fp==NULL) {
+ fprintf(stderr,"ERROR in %s: Could not open datafile %s\n",argv[0],argv[1]);
+ exit(1);
+ }
+
+ fscanf(fp,"%d %d %d %d %d %d %d %d %d",
+ &p.a, &p.b, &p.c, &p.d, &p.bi, &p.ar, &p.g1, &p.g2, &p.g3);
+
+ for(k=2;;k+=2) {
+ printf("Trying %d\n",k);
+ if(mu(p,k,0,-1) == 1) {
+ putchar('\n');
+ break;
+ }
+ }
+ #endif
+
+ return 0;
+ }
+
+ static int neard(p_type p,int maxdep,int dep,int last,int near[]);
+ static int nearu(p_type p,int maxdep,int dep,int last,int near[]) {
+ if(maxdep == dep) {
+ near[p.a] |= A;
+ near[p.b] |= B;
+ near[p.c] |= C;
+ near[p.d] |= D;
+ near[p.bi] |= BI;
+ near[p.ar] |= AR;
+ near[p.g1] |= G;
+ near[p.g2] |= G;
+ near[p.g3] |= G;
+ return 0;
+ }
+
+ if(last != 0 ) neard(m0u(p),maxdep,dep+1,0,near);
+ if(last != 1 ) neard(m1u(p),maxdep,dep+1,1,near);
+ if(last != 2 ) neard(m2u(p),maxdep,dep+1,2,near);
+
+ return 0; /* To quiet the compiler... */
+ }
+
+ static int neard(p_type p,int maxdep,int dep,int last,int near[]) {
+ if(last != 0 ) nearu(m0d(p),maxdep,dep+1,0,near);
+ if(last != 1 ) nearu(m1d(p),maxdep,dep+1,1,near);
+ if(last != 2 ) nearu(m2d(p),maxdep,dep+1,2,near);
+ return 0;
+ }
+
+ #ifndef BENCHMARK
+ static void prnear(int k) {
+ int i;
+ int near[18];
+ p_type correct = {5,6,12,13,14,15,0,1,2};
+
+ for(i=0;i<18;i++) near[i] = 0;
+ nearu(correct,k,0,-1,near);
+ printf("{0x%x",near[0]);
+ for(i=1;i<18;i++) printf(",0x%x",near[i]);
+ printf("}\n");
+ }
+ #endif
+
+ /*
+ normalläge : skidan i mitten + vänsterflepp nedåt
+ numrering : börja på 0; skidan först radvis, sedan vflepp + hflepp
+
+ 16 17
+ 00 01 02 03 04 05 06
+ 07 08 09 10 11 12 13
+ 14 15
+
+
+ Vinst :
+ G G G A B
+ E F C D
+
+ Vinster:
+ 0 1 7 8
+ 1 2 8 9
+ 2 3 9 10
+ 3 4 10 11
+ 4 5 11 12
+ 5 6 12 13
+
+ 01 02
+ 00 08 09 03 16 17 06
+ 07 14 15 10 04 05 13
+ 11 12
+
+ Vinster:
+ 0 8 7 14
+ 8 9 14 15
+ 9 3 15 10
+ 3 16 10 4
+ 16 17 4 5
+ 17 6 5 13
+
+ */
+
+
+
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/ref.in
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/ref.in:1.1
*** /dev/null Sat Oct 11 16:18:58 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/ref.in Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1 ----
+ 0 1 2 3 4 5 6 7 8
Index: llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in
diff -c /dev/null llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in:1.1
*** /dev/null Sat Oct 11 16:18:58 2003
--- llvm/test/Programs/MultiSource/Benchmarks/FreeBench/mason/test.in Sat Oct 11 16:18:47 2003
***************
*** 0 ****
--- 1 ----
+ 6 5 12 13 14 15 0 1 2
More information about the llvm-commits
mailing list