I'm sketching scheduling of bank swizzles in r600g driver (it's inefficient ATM, I'm figuring out the constraints):
enum CHANS = {x,y,z,w};
enum REGS = {R1, R2, R3, R4}; % for starters
% args
enum OPERANDS = {src1, src2, src3, src4};
array[OPERANDS] of REGS: Regs = [R1, R2, R1, R3];
array[OPERANDS] of CHANS: Chans = [x, x, y, x];
array[OPERANDS] of 1..4: Inst = [1,1,2,2];
array[OPERANDS] of 1..3: Port = [1,2,1,2];
% the rest
array[OPERANDS] of var 1..3: PortOut;
constraint sum(i in PortOut where i = 1)(1) <= 3;
constraint sum(i in PortOut where i = 2)(1) <= 3;
constraint sum(i in PortOut where i = 3)(1) <= 3;
output [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 1]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 2]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 3];
solve satisfy;
It works with the 3 "output" lines commented out, but otherwise it fails with:
λ minizinc test.mzn
test.mzn:17:
MiniZinc: type error: invalid type in output item, expected `array[int] opt string'
Any ideas?
When you are using decision variables in the output
section you (might) have to use fix
to use the value of the variable. Here the PortOut[op]
need to be fix
'ed:
output [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 1]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 2]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 3];