SRP fails for divisors greater than 2
The below program has different behaviours for -dosrp
and -nosrp
(both with -maxwlmp 3
)
use Array: all;
use Math: all;
use StdIO: all;
noinline
int[.] test ()
{
return {[i] -> mod(i + 2, 3) | [i] < [10]};
}
int main()
{
print(test());
return 0;
}
>>> sac2c_p -maxwlmp 5 test.sac -dosrp && ./a.out
Dimension: 1
Shape : < 25>
< 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 2 3 0 0 0 >
>>> sac2c_p -maxwlmp 5 test.sac -nosrp && ./a.out
Dimension: 1
Shape : < 25>
< 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 >
This behaviour is caused by SRPlowerBoundRec
in wl_modulo_partitioning.c
. It's supposed to recursively compute the new bounds, but instead it computes the base case + a single recursive step. As a consequence, all partitions after the second are equal to the second, and nothing is computed for the values meant to be covered by the other partitions.