|
16 | 16 | * - COMB_BLOCKS is the number of blocks the input is split into. Each
|
17 | 17 | * has a corresponding table.
|
18 | 18 | * - COMB_TEETH is the number of bits simultaneously covered by one table.
|
| 19 | + * - COMB_RANGE is the number of bits in supported scalars. For production |
| 20 | + * purposes, only 256 is reasonable, but smaller numbers are supported for |
| 21 | + * exhaustive test mode. |
19 | 22 | *
|
20 | 23 | * The comb's spacing (COMB_SPACING), or the distance between the teeth,
|
21 |
| - * is defined as ceil(256 / (COMB_BLOCKS * COMB_TEETH)). Each block covers |
| 24 | + * is defined as ceil(COMB_RANGE / (COMB_BLOCKS * COMB_TEETH)). Each block covers |
22 | 25 | * COMB_SPACING * COMB_TEETH consecutive bits in the input.
|
23 | 26 | *
|
24 | 27 | * The size of the precomputed table is COMB_BLOCKS * (1 << (COMB_TEETH - 1))
|
|
36 | 39 | * doesn't support infinities) */
|
37 | 40 | # undef COMB_BLOCKS
|
38 | 41 | # undef COMB_TEETH
|
39 |
| -# if EXHAUSTIVE_TEST_ORDER > 32 |
40 |
| -# define COMB_BLOCKS 52 |
41 |
| -# define COMB_TEETH 5 |
42 |
| -# elif EXHAUSTIVE_TEST_ORDER > 16 |
43 |
| -# define COMB_BLOCKS 64 |
44 |
| -# define COMB_TEETH 4 |
45 |
| -# elif EXHAUSTIVE_TEST_ORDER > 8 |
46 |
| -# define COMB_BLOCKS 86 |
47 |
| -# define COMB_TEETH 3 |
48 |
| -# elif EXHAUSTIVE_TEST_ORDER > 4 |
49 |
| -# define COMB_BLOCKS 128 |
| 42 | +# if EXHAUSTIVE_TEST_ORDER == 7 |
| 43 | +# define COMB_RANGE 3 |
| 44 | +# define COMB_BLOCKS 1 |
| 45 | +# define COMB_TEETH 2 |
| 46 | +# elif EXHAUSTIVE_TEST_ORDER == 13 |
| 47 | +# define COMB_RANGE 4 |
| 48 | +# define COMB_BLOCKS 1 |
50 | 49 | # define COMB_TEETH 2
|
| 50 | +# elif EXHAUSTIVE_TEST_ORDER == 199 |
| 51 | +# define COMB_RANGE 8 |
| 52 | +# define COMB_BLOCKS 2 |
| 53 | +# define COMB_TEETH 3 |
51 | 54 | # else
|
52 |
| -# define COMB_BLOCKS 256 |
53 |
| -# define COMB_TEETH 1 |
| 55 | +# error "Unknown exhaustive test order" |
| 56 | +# endif |
| 57 | +# if (COMB_RANGE >= 32) || ((EXHAUSTIVE_TEST_ORDER >> (COMB_RANGE - 1)) != 1) |
| 58 | +# error "COMB_RANGE != ceil(log2(EXHAUSTIVE_TEST_ORDER+1))" |
54 | 59 | # endif
|
55 | 60 | #else /* !defined(EXHAUSTIVE_TEST_ORDER) */
|
| 61 | +# define COMB_RANGE 256 |
| 62 | +#endif /* defined(EXHAUSTIVE_TEST_ORDER) */ |
| 63 | + |
56 | 64 | /* Use (11, 6) as default configuration, which results in a 22 kB table. */
|
57 |
| -# ifndef COMB_BLOCKS |
58 |
| -# define COMB_BLOCKS 11 |
59 |
| -# ifdef DEBUG_CONFIG |
60 |
| -# pragma message DEBUG_CONFIG_MSG("COMB_BLOCKS undefined, assuming default value") |
61 |
| -# endif |
| 65 | +#ifndef COMB_BLOCKS |
| 66 | +# define COMB_BLOCKS 11 |
| 67 | +# ifdef DEBUG_CONFIG |
| 68 | +# pragma message DEBUG_CONFIG_MSG("COMB_BLOCKS undefined, assuming default value") |
62 | 69 | # endif
|
63 |
| -# ifndef COMB_TEETH |
64 |
| -# define COMB_TEETH 6 |
65 |
| -# ifdef DEBUG_CONFIG |
66 |
| -# pragma message DEBUG_CONFIG_MSG("COMB_TEETH undefined, assuming default value") |
67 |
| -# endif |
| 70 | +#endif |
| 71 | +#ifndef COMB_TEETH |
| 72 | +# define COMB_TEETH 6 |
| 73 | +# ifdef DEBUG_CONFIG |
| 74 | +# pragma message DEBUG_CONFIG_MSG("COMB_TEETH undefined, assuming default value") |
68 | 75 | # endif
|
69 |
| -#endif /* defined(EXHAUSTIVE_TEST_ORDER) */ |
| 76 | +#endif |
| 77 | +/* Use ceil(COMB_RANGE / (COMB_BLOCKS * COMB_TEETH)) as COMB_SPACING. */ |
| 78 | +#define COMB_SPACING CEIL_DIV(COMB_RANGE, COMB_BLOCKS * COMB_TEETH) |
70 | 79 |
|
71 | 80 | /* Range checks on the parameters. */
|
| 81 | + |
| 82 | +/* The remaining COMB_* parameters are derived values, don't modify these. */ |
| 83 | +/* - The number of bits covered by all the blocks; must be at least COMB_RANGE. */ |
| 84 | +#define COMB_BITS (COMB_BLOCKS * COMB_TEETH * COMB_SPACING) |
| 85 | +/* - The number of entries per table. */ |
| 86 | +#define COMB_POINTS (1 << (COMB_TEETH - 1)) |
| 87 | + |
| 88 | +/* Sanity checks. */ |
72 | 89 | #if !(1 <= COMB_BLOCKS && COMB_BLOCKS <= 256)
|
73 | 90 | # error "COMB_BLOCKS must be in the range [1, 256]"
|
74 | 91 | #endif
|
75 | 92 | #if !(1 <= COMB_TEETH && COMB_TEETH <= 8)
|
76 | 93 | # error "COMB_TEETH must be in the range [1, 8]"
|
77 | 94 | #endif
|
| 95 | +#if COMB_BITS < COMB_RANGE |
| 96 | +# error "COMB_BLOCKS * COMB_TEETH * COMB_SPACING is too low" |
| 97 | +#endif |
78 | 98 |
|
79 |
| -/* The remaining COMB_* parameters are derived values, don't modify these. */ |
80 |
| -/* - The distance between the teeth of each comb. */ |
81 |
| -#define COMB_SPACING CEIL_DIV(256, COMB_BLOCKS * COMB_TEETH) |
82 |
| -/* - The number of bits covered by all the blocks; must be at least 256. */ |
83 |
| -#define COMB_BITS (COMB_BLOCKS * COMB_TEETH * COMB_SPACING) |
84 |
| -/* - The number of entries per table. */ |
85 |
| -#define COMB_POINTS (1 << (COMB_TEETH - 1)) |
86 |
| - |
87 |
| -/* Additional sanity checks. */ |
| 99 | +/* These last 2 checks are not strictly required, but prevent gratuitously inefficient |
| 100 | + * configurations. Note that they compare with 256 rather than COMB_RANGE, so they do |
| 101 | + * permit somewhat excessive values for the exhaustive test case, where testing with |
| 102 | + * suboptimal parameters may be desirable. */ |
88 | 103 | #if (COMB_BLOCKS - 1) * COMB_TEETH * COMB_SPACING >= 256
|
89 | 104 | # error "COMB_BLOCKS can be reduced"
|
90 | 105 | #endif
|
|
93 | 108 | #endif
|
94 | 109 |
|
95 | 110 | #ifdef DEBUG_CONFIG
|
| 111 | +# pragma message DEBUG_CONFIG_DEF(COMB_RANGE) |
96 | 112 | # pragma message DEBUG_CONFIG_DEF(COMB_BLOCKS)
|
97 | 113 | # pragma message DEBUG_CONFIG_DEF(COMB_TEETH)
|
| 114 | +# pragma message DEBUG_CONFIG_DEF(COMB_SPACING) |
98 | 115 | #endif
|
99 | 116 |
|
100 | 117 | typedef struct {
|
|
0 commit comments