Type inference phase does not terminate
Phase 6 "Running type inference system ..." does not terminate, or takes at least 45 minutes. When removing either the print(ia) statement or specializations, the compiler does terminate, (and uses 10GB of RAM).
Run with 1.3.3-MijasCosta-1059-ge32fa.
#define M1B 200
#define K1B 40
#define N1B 1250
#define M2B 10
#define K2B 1
#define N2B 1
#define M3B 5
#define K3B 250
#define N3B 8
use Array:all;
use StdIO:all;
inline
int[.] even (int[.] a)
{
return { [i] -> a[i*2] | [i] < (shape(a)+1)/2 };
}
inline
int[.] odd (int[.] b)
{
return { [i] -> b[i*2 + 1] | [i] < (shape(b)+1)/2 };
}
inline
int[.] merge (int[.] a, int[.] b)
{
return { [i] -> a[i/2] | [0] <= [i] < shape(a)*2 step [2];
[i] -> b[i/2] | [1] <= [i] < shape(b)*2 step [2]};
}
#define ASZS M1B, K1B, M2B, K2B, M3B, K3B
#define BSZS K1B, N1B, K2B, N2B, K3B, N3B
#define CSZS M1B, N1B, M2B, N2B, M3B, N3B
specialize double[.,.,.,.,.,.]
mmy(double[ASZS] a, int[0] ia, int[6] sha,
double[BSZS] b, int[0] ib, int[6] shb,
double[CSZS] c, int[0] ic, int[6] shc);
specialize double[.,.,.,.]
mmy(double[ASZS] a, int[2] ia, int[4] sha,
double[BSZS] b, int[2] ib, int[4] shb,
double[CSZS] c, int[2] ic, int[4] shc);
specialize double[.,.]
mmy(double[ASZS] a, int[4] ia, int[2] sha,
double[BSZS] b, int[4] ib, int[2] shb,
double[CSZS] c, int[4] ic, int[2] shc);
inline double[*]
mmy (double[ASZS] a, int[.] ia, int[.] sha,
double[BSZS] b, int[.] ib, int[.] shb,
double[CSZS] c, int[.] ic, int[.] shc)
{
return {[i,j] -> with {
([0] <= [l] < [sha[1]]): mmy (a, (ia ++ [i,l]), drop([2], sha),
b, (ib ++ [l,j]), drop([2], shb),
c, (ic ++ [i,j]), drop([2], shc));
}: fold(+, genarray(merge(even(drop([2], sha)),
odd(drop([2], shb))),
0d))
| [i,j] < [sha[0], shb[1]]};
}
inline double[.,.]
mmy (double[ASZS] a, int[.] ia, int[2] sha,
double[BSZS] b, int[.] ib, int[2] shb,
double[CSZS] c, int[.] ic, int[2] shc)
{
print(ia);
return genarray(shc, 0d);
}
int main()
{
a = reshape([M1B, M2B, M3B, K1B, K2B, K3B], tod(iota(M1B * M2B * M3B * K1B * K2B * K3B)));
b = reshape([K1B, K2B, K3B, N1B, N2B, N3B], tod(iota(K1B * K2B * K3B * N1B * N2B * N3B)));
c = reshape([M1B, M2B, M3B, N1B, N2B, N3B], tod(iota(M1B * M2B * M3B * N1B * N2B * N3B)));
c = mmy(a, [], shape(a), b, [], shape(b), c, [], shape(c));
return toi(sum(c));
}