aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore3
-rw-r--r--Makefile17
-rw-r--r--benchmark/bench.c11
-rwxr-xr-xbenchmark/bench.sh12
-rwxr-xr-xh48_to_srcbin35272 -> 0 bytes
-rw-r--r--src/cube.c67
-rwxr-xr-xtest/test.sh5
7 files changed, 64 insertions, 51 deletions
diff --git a/.gitignore b/.gitignore
index 5f06d9a..1d96c4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
1benchmark/results.txt
2benchmark/run
1test/*/runtest 3test/*/runtest
2test/run 4test/run
3test/last.* 5test/last.*
4test/*.o
5*.o 6*.o
diff --git a/Makefile b/Makefile
index 9ae2a4f..a0136f0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2 2
3CFLAGS = -std=c99 -pthread -pedantic -Wall -Wextra \ 3CFLAGS = -std=c99 -pthread -pedantic -Wall -Wextra \
4 -Wno-unused-parameter -O3 4 -Wno-unused-parameter -O3
5DBGFLAGS = -std=c99 -pthread -pedantic -Wall -Wextra \ 5DBGFLAGS = -DDEBUG -std=c99 -pthread -pedantic -Wall -Wextra \
6 -Wno-unused-parameter -Wno-unused-function -g3 \ 6 -Wno-unused-parameter -Wno-unused-function -g3 \
7 -fsanitize=address -fsanitize=undefined 7 -fsanitize=address -fsanitize=undefined
8 8
@@ -10,16 +10,19 @@ CC = cc
10 10
11all: solve 11all: solve
12 12
13solve: clean 13cube.o: clean
14 ${CC} ${CFLAGS} -o solve src/*.c 14 ${CC} ${CFLAGS} -c -o cube.o src/*.c
15 15
16debug: 16debugcube.o:
17 ${CC} ${DBGFLAGS} -o solve src/*.c 17 ${CC} ${DBGFLAGS} -c -o debugcube.o src/*.c
18 18
19clean: 19clean:
20 rm -rf solve 20 rm -rf solve
21 21
22test: 22test: debugcube.o
23 ./test/test.sh 23 ./test/test.sh
24 24
25.PHONY: all debug clean test 25benchmark: cube.o
26 ./benchmark/bench.sh
27
28.PHONY: all clean test benchmark
diff --git a/benchmark/bench.c b/benchmark/bench.c
new file mode 100644
index 0000000..046e965
--- /dev/null
+++ b/benchmark/bench.c
@@ -0,0 +1,11 @@
1#include <stdbool.h>
2#include <stdint.h>
3#include <stdio.h>
4
5#include "../src/cube.h"
6
7int main() {
8 printf("Benchmarks not yet set up\n");
9
10 return 0;
11}
diff --git a/benchmark/bench.sh b/benchmark/bench.sh
new file mode 100755
index 0000000..288db05
--- /dev/null
+++ b/benchmark/bench.sh
@@ -0,0 +1,12 @@
1#!/bin/sh
2
3BENCHBIN="benchmark/run"
4BENCHOUT="benchmark/results.txt"
5CUBEOBJ="cube.o"
6
7cc -std=c99 -pthread -O3 -o $BENCHBIN benchmark/bench.c $CUBEOBJ || exit 1;
8
9$BENCHBIN | tee $BENCHOUT
10echo "Results saved to $BENCHOUT"
11
12rm -rf $BENCHBIN $CUBEOBJ
diff --git a/h48_to_src b/h48_to_src
deleted file mode 100755
index 8cf38e3..0000000
--- a/h48_to_src
+++ /dev/null
Binary files differ
diff --git a/src/cube.c b/src/cube.c
index b853b06..48bc2f5 100644
--- a/src/cube.c
+++ b/src/cube.c
@@ -605,8 +605,10 @@ issolvable(cube_t cube)
605 int8_t i, eo, co; 605 int8_t i, eo, co;
606 606
607#ifdef DEBUG 607#ifdef DEBUG
608 if (!isconsistent(cube)) 608 if (!isconsistent(cube)) {
609 goto issolvable_inconsistent; 609 fprintf(stderr, "issolvable: cube is inconsistent\n");
610 return false;
611 }
610#endif 612#endif
611 613
612 if (permsign(cube.e, 12) != permsign(cube.c, 8)) 614 if (permsign(cube.e, 12) != permsign(cube.c, 8))
@@ -626,11 +628,6 @@ issolvable(cube_t cube)
626 628
627 return true; 629 return true;
628 630
629issolvable_inconsistent:
630#ifdef DEBUG
631 fprintf(stderr, "issolvable: cube is inconsistent\n");
632#endif
633 return false;
634issolvable_parity: 631issolvable_parity:
635#ifdef DEBUG 632#ifdef DEBUG
636 fprintf(stderr, "EP and CP parities are different\n"); 633 fprintf(stderr, "EP and CP parities are different\n");
@@ -683,8 +680,10 @@ move(cube_t c, move_t m)
683 uint8_t aux, auy, auz; 680 uint8_t aux, auy, auz;
684 681
685#ifdef DEBUG 682#ifdef DEBUG
686 if (!isconsistent(c)) 683 if (!isconsistent(c)) {
687 goto move_inconsistent; 684 fprintf(stderr, "move error, inconsistent cube\n");
685 goto move_error;
686 }
688#endif 687#endif
689 688
690#define PERM4(r, i, j, k, l) \ 689#define PERM4(r, i, j, k, l) \
@@ -830,15 +829,12 @@ move(cube_t c, move_t m)
830 829
831 return ret; 830 return ret;
832 default: 831 default:
833 goto move_unknown; 832#ifdef DEBUG
833 fprintf(stderr, "mover error, unknown move\n");
834#endif
835 goto move_error;
834 } 836 }
835 837
836move_inconsistent:
837 fprintf(stderr, "move error, inconsistent cube\n");
838 goto move_error;
839move_unknown:
840 fprintf(stderr, "mover error, unknown move\n");
841 goto move_error;
842move_error: 838move_error:
843 return errorcube; 839 return errorcube;
844} 840}
@@ -850,8 +846,10 @@ inverse(cube_t c)
850 cube_t ret = {0}; 846 cube_t ret = {0};
851 847
852#ifdef DEBUG 848#ifdef DEBUG
853 if (!isconsistent(c)) 849 if (!isconsistent(c)) {
854 goto inverse_inconsistent; 850 fprintf(stderr, "inverse error, inconsistent cube\n");
851 return errorcube;
852 }
855#endif 853#endif
856 854
857 for (i = 0; i < 12; i++) { 855 for (i = 0; i < 12; i++) {
@@ -867,10 +865,6 @@ inverse(cube_t c)
867 } 865 }
868 866
869 return ret; 867 return ret;
870
871inverse_inconsistent:
872 fprintf(stderr, "inverse error, inconsistent cube\n");
873 return errorcube;
874} 868}
875 869
876cube_t 870cube_t
@@ -880,8 +874,10 @@ compose(cube_t c1, cube_t c2)
880 cube_t ret = {0}; 874 cube_t ret = {0};
881 875
882#ifdef DEBUG 876#ifdef DEBUG
883 if (!isconsistent(c1) || !isconsistent(c2)) 877 if (!isconsistent(c1) || !isconsistent(c2)) {
884 goto compose_inconsistent; 878 fprintf(stderr, "compose error, inconsistent cube\n");
879 return errorcube;
880 }
885#endif 881#endif
886 882
887 for (i = 0; i < 12; i++) { 883 for (i = 0; i < 12; i++) {
@@ -899,10 +895,6 @@ compose(cube_t c1, cube_t c2)
899 } 895 }
900 896
901 return ret; 897 return ret;
902
903compose_inconsistent:
904 fprintf(stderr, "compose error, inconsistent cube\n");
905 return errorcube;
906} 898}
907 899
908static cube_t 900static cube_t
@@ -1122,10 +1114,14 @@ transform(cube_t c, trans_t t)
1122 cube_t ret; 1114 cube_t ret;
1123 1115
1124#ifdef DEBUG 1116#ifdef DEBUG
1125 if (!isconsistent(c)) 1117 if (!isconsistent(c)) {
1126 goto transform_inconsistent; 1118 fprintf(stderr, "transform error, inconsistent cube\n");
1127 if (t >= 48) 1119 return errorcube;
1128 goto transform_errortrans; 1120 }
1121 if (t >= 48) {
1122 fprintf(stderr, "transform error, unknown transformation\n");
1123 return errorcube;
1124 }
1129#endif 1125#endif
1130 1126
1131 ret = compose(solvedcube, trans_move_cube[t]); 1127 ret = compose(solvedcube, trans_move_cube[t]);
@@ -1138,11 +1134,4 @@ transform(cube_t c, trans_t t)
1138 ret = flipallcorners(ret); 1134 ret = flipallcorners(ret);
1139 1135
1140 return ret; 1136 return ret;
1141
1142transform_inconsistent:
1143 fprintf(stderr, "transform error, inconsistent cube\n");
1144 return errorcube;
1145transform_errortrans:
1146 fprintf(stderr, "transform error, unknown transformation\n");
1147 return errorcube;
1148} 1137}
diff --git a/test/test.sh b/test/test.sh
index 00dd5ce..9e064b2 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -5,13 +5,10 @@ CC="cc -DDEBUG -std=c99 -pthread -pedantic -Wall -Wextra \
5if [ $(uname) != "OpenBSD" ]; then 5if [ $(uname) != "OpenBSD" ]; then
6 CC="$CC -fsanitize=address -fsanitize=undefined" 6 CC="$CC -fsanitize=address -fsanitize=undefined"
7fi 7fi
8SRC="src/cube.c"
9TESTBIN="test/run" 8TESTBIN="test/run"
10TESTOUT="test/last.out" 9TESTOUT="test/last.out"
11TESTERR="test/last.err" 10TESTERR="test/last.err"
12CUBEOBJ="test/cube.o" 11CUBEOBJ="debugcube.o"
13
14$CC -c $SRC -o $CUBEOBJ || exit 1
15 12
16for t in test/*; do 13for t in test/*; do
17 if [ ! -d $t ]; then continue; fi 14 if [ ! -d $t ]; then continue; fi

Generated with cgit - Back to sebastiano.tronto.net