diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | src/cube.c | 30 | ||||
| -rw-r--r-- | src/cube.h | 4 | ||||
| -rw-r--r-- | test/012_io_AVX_write/01_solved.in | 1 | ||||
| -rw-r--r-- | test/012_io_AVX_write/01_solved.out | 4 | ||||
| -rw-r--r-- | test/012_io_AVX_write/02_scrambled.in | 1 | ||||
| -rw-r--r-- | test/012_io_AVX_write/02_scrambled.out | 4 | ||||
| -rw-r--r-- | test/012_io_AVX_write/io_AVX_tests.c | 28 |
8 files changed, 70 insertions, 3 deletions
| @@ -15,7 +15,6 @@ $ make test | |||
| 15 | 15 | ||
| 16 | ### Make AVX2 work | 16 | ### Make AVX2 work |
| 17 | 17 | ||
| 18 | * writecube to AVX2-src format (+ tests) | ||
| 19 | * generate moves and transformations with scripts in utils/ | 18 | * generate moves and transformations with scripts in utils/ |
| 20 | * fix base get_ and set_ macros (constant arguments?) | 19 | * fix base get_ and set_ macros (constant arguments?) |
| 21 | * optimize things that use get_ and set_ | 20 | * optimize things that use get_ and set_ |
| @@ -276,6 +276,7 @@ static uint8_t readep(char *); | |||
| 276 | static uint8_t readmove(char); | 276 | static uint8_t readmove(char); |
| 277 | static uint8_t readmodifier(char); | 277 | static uint8_t readmodifier(char); |
| 278 | static cube_t readcube_H48(char *); | 278 | static cube_t readcube_H48(char *); |
| 279 | static void writecube_AVX(cube_t, char *); | ||
| 279 | static void writecube_H48(cube_t, char *); | 280 | static void writecube_H48(cube_t, char *); |
| 280 | static int writepiece_SRC(uint8_t, char *); | 281 | static int writepiece_SRC(uint8_t, char *); |
| 281 | static void writecube_SRC(cube_t, char *); | 282 | static void writecube_SRC(cube_t, char *); |
| @@ -420,6 +421,32 @@ readcube(format_t format, char *buf) | |||
| 420 | } | 421 | } |
| 421 | 422 | ||
| 422 | static void | 423 | static void |
| 424 | writecube_AVX(cube_t cube, char *buf) | ||
| 425 | { | ||
| 426 | int i, ptr; | ||
| 427 | uint8_t piece; | ||
| 428 | |||
| 429 | memcpy(buf, "_mm256_set_epi8(\n\t0, 0, 0, 0, ", 30); | ||
| 430 | ptr = 30; | ||
| 431 | |||
| 432 | for (i = 11; i >= 0; i--) { | ||
| 433 | piece = get_edge(cube, i); | ||
| 434 | ptr += writepiece_SRC(piece, buf + ptr); | ||
| 435 | } | ||
| 436 | |||
| 437 | memcpy(buf+ptr-2, ",\n\t0, 0, 0, 0, 0, 0, 0, 0, ", 27); | ||
| 438 | ptr += 25; | ||
| 439 | |||
| 440 | for (i = 7; i >= 0; i--) { | ||
| 441 | piece = get_corner(cube, i); | ||
| 442 | ptr += writepiece_SRC(piece, buf + ptr); | ||
| 443 | } | ||
| 444 | |||
| 445 | memcpy(buf+ptr-2, "\n)\0", 3); | ||
| 446 | } | ||
| 447 | |||
| 448 | |||
| 449 | static void | ||
| 423 | writecube_H48(cube_t cube, char *buf) | 450 | writecube_H48(cube_t cube, char *buf) |
| 424 | { | 451 | { |
| 425 | uint8_t piece, perm, orient; | 452 | uint8_t piece, perm, orient; |
| @@ -508,6 +535,9 @@ writecube(format_t format, cube_t cube, char *buf) | |||
| 508 | } | 535 | } |
| 509 | 536 | ||
| 510 | switch (format) { | 537 | switch (format) { |
| 538 | case AVX: | ||
| 539 | writecube_AVX(cube, buf); | ||
| 540 | break; | ||
| 511 | case H48: | 541 | case H48: |
| 512 | writecube_H48(cube, buf); | 542 | writecube_H48(cube, buf); |
| 513 | break; | 543 | break; |
| @@ -16,9 +16,9 @@ void writemoves(move_t *, int, char *); | |||
| 16 | trans_t readtrans(char *); | 16 | trans_t readtrans(char *); |
| 17 | void writetrans(trans_t, char *); | 17 | void writetrans(trans_t, char *); |
| 18 | 18 | ||
| 19 | typedef enum {H48, SRC} format_t; | 19 | typedef enum {AVX, H48, SRC} format_t; |
| 20 | cube_t readcube(format_t, char *); /* Supports: H48 */ | 20 | cube_t readcube(format_t, char *); /* Supports: H48 */ |
| 21 | void writecube(format_t, cube_t, char *); /* Supports: H48, SRC */ | 21 | void writecube(format_t, cube_t, char *); /* Supports: AVX, H48, SRC */ |
| 22 | 22 | ||
| 23 | cube_t solvedcube(void); | 23 | cube_t solvedcube(void); |
| 24 | cube_t zerocube(void); | 24 | cube_t zerocube(void); |
diff --git a/test/012_io_AVX_write/01_solved.in b/test/012_io_AVX_write/01_solved.in new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/012_io_AVX_write/01_solved.in | |||
| @@ -0,0 +1 @@ | |||
| UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | |||
diff --git a/test/012_io_AVX_write/01_solved.out b/test/012_io_AVX_write/01_solved.out new file mode 100644 index 0000000..9bc7c29 --- /dev/null +++ b/test/012_io_AVX_write/01_solved.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | _mm256_set_epi8( | ||
| 2 | 0, 0, 0, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, | ||
| 3 | 0, 0, 0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2, 1, 0 | ||
| 4 | ) | ||
diff --git a/test/012_io_AVX_write/02_scrambled.in b/test/012_io_AVX_write/02_scrambled.in new file mode 100644 index 0000000..6a05bbc --- /dev/null +++ b/test/012_io_AVX_write/02_scrambled.in | |||
| @@ -0,0 +1 @@ | |||
| FL0 DB0 UB1 FR0 UR0 DF0 UF0 BR1 UL1 BL1 DL0 DR0 DFR1 UFR1 UBR1 UFL2 DBR2 DFL0 DBL2 UBL0 | |||
diff --git a/test/012_io_AVX_write/02_scrambled.out b/test/012_io_AVX_write/02_scrambled.out new file mode 100644 index 0000000..7d406a2 --- /dev/null +++ b/test/012_io_AVX_write/02_scrambled.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | _mm256_set_epi8( | ||
| 2 | 0, 0, 0, 0, 7, 6, 26, 21, 27, 0, 3, 4, 8, 17, 2, 9, | ||
| 3 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 71, 2, 67, 68, 37, 32, 38 | ||
| 4 | ) | ||
diff --git a/test/012_io_AVX_write/io_AVX_tests.c b/test/012_io_AVX_write/io_AVX_tests.c new file mode 100644 index 0000000..2815cab --- /dev/null +++ b/test/012_io_AVX_write/io_AVX_tests.c | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #include "../../src/cube.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 10000 | ||
| 8 | |||
| 9 | int main() { | ||
| 10 | char *c, str[STRLENMAX]; | ||
| 11 | cube_t cube; | ||
| 12 | |||
| 13 | for (c = str; (*c = getchar()) != EOF; c++) ; | ||
| 14 | *c = '\0'; | ||
| 15 | |||
| 16 | cube = readcube(H48, str); | ||
| 17 | |||
| 18 | if (iserror(cube)) { | ||
| 19 | printf("Error reading cube\n"); | ||
| 20 | } else if (!issolvable(cube)) { | ||
| 21 | printf("Cube is not solvable\n"); | ||
| 22 | } else { | ||
| 23 | writecube(AVX, cube, str); | ||
| 24 | printf("%s\n", str); | ||
| 25 | } | ||
| 26 | |||
| 27 | return 0; | ||
| 28 | } | ||
