model "Multiprocessor-Compression" uses "mmxprs" declarations PROCESSORS = 4 BLOCKS = 12 STEPS = 6 !Sizes ONCHIP_SIZE : real DATABLOCK_SIZE : integer COMPRESSION_RATIO : real !Costs ONCHIP_COST : integer REMOTE_COST : integer OFFCHIP_COST : integer MOVEONCHIP_COST : integer MOVEOFFCHIP_COST : integer COMPRESSION_COST : integer DECOMPRESSION_COST : integer !Accesses ACCESSES: array(1..PROCESSORS, 1..STEPS) of integer !(b,p,s): Indicates whether block b at step s is compressed in processpor p. compressed: array(1..BLOCKS, 1..PROCESSORS, 1..STEPS) of mpvar !(b,p,s): Indicates whether block b at step s is uncompressed in processpor p. uncompressed: array(1..BLOCKS, 1..PROCESSORS, 1..STEPS) of mpvar !(b,s): Indicates whether block b at step s is in the off-chip memory (uncompressed). offchip: array(1..BLOCKS, 1..STEPS) of mpvar !(b,s): Indicates a data block is moved from/to off-chip memory to/from on-chip memory. move_offchip: array(1..BLOCKS, 1..STEPS) of mpvar !(b,s): Indicates a data block is moved within the on-chip memory. move_onchip: array(1..BLOCKS, 1..STEPS) of mpvar !(b,s): Indicates a data block is compressed. compress: array(1..BLOCKS, 1..STEPS) of mpvar !(b,s): Indicates a data block is decompressed. decompress: array(1..BLOCKS, 1..STEPS) of mpvar end-declarations initializations from 'compression-input.dat' ONCHIP_SIZE DATABLOCK_SIZE COMPRESSION_RATIO ONCHIP_COST REMOTE_COST OFFCHIP_COST MOVEONCHIP_COST MOVEOFFCHIP_COST COMPRESSION_COST DECOMPRESSION_COST ACCESSES end-initializations !---------------------------------------------------- !No compression !forall(s in 1..STEPS, b in 1..BLOCKS) sum(p in 1..PROCESSORS) compressed(b,p,s) = 0 !---------------------------------------------------- !forall(s in 1..STEPS) uncompressed(5,1,s)+compressed(5,1,s)= 1 !forall(s in 1..STEPS) uncompressed(9,1,s)+compressed(9,1,s)= 1 !forall(s in 1..STEPS) uncompressed(6,2,s)+compressed(6,2,s)= 1 !forall(s in 1..STEPS) uncompressed(10,2,s)+compressed(10,2,s)= 1 !forall(s in 1..STEPS) uncompressed(7,3,s)+compressed(7,3,s)= 1 !forall(s in 1..STEPS) uncompressed(11,3,s)+compressed(11,3,s)= 1 !forall(s in 1..STEPS) uncompressed(8,4,s)+compressed(8,4,s)= 1 !forall(s in 1..STEPS) uncompressed(12,4,s)+compressed(12,4,s)= 1 ! A data block has a single location at every step. forall(s in 1..STEPS, b in 1..BLOCKS) sum(p in 1..PROCESSORS)( compressed(b,p,s) + uncompressed(b,p,s)) + offchip(b,s) = 1 ! If a data block is being accessed it cannot be in compressed form. forall(s in 1..STEPS, b in 1..BLOCKS, p1,p2 in 1..PROCESSORS | b=ACCESSES(p1,s)) compressed(b,p2,s) = 0 ! SPMs have size constraint forall(p in 1..PROCESSORS, s in 1..STEPS) sum(b in 1..BLOCKS)((compressed(b,p,s)/COMPRESSION_RATIO + uncompressed(b,p,s))* DATABLOCK_SIZE) <= ONCHIP_SIZE ! Off-chip movement can be captured by forall(b in 1..BLOCKS, s in 2..STEPS) move_offchip(b,s)>=(offchip(b,s)-offchip(b,s-1)) forall(b in 1..BLOCKS, s in 2..STEPS) move_offchip(b,s)>=(offchip(b,s-1)-offchip(b,s)) ! On-chip movement can be captured by forall(b in 1..BLOCKS, p1,p2 in 1..PROCESSORS, s in 2..STEPS | p1<>p2) move_onchip(b,s)>=(compressed(b,p1,s)+uncompressed(b,p1,s))+(compressed(b,p2,s-1)+uncompressed(b,p2,s-1))-1 ! Compression can be captured by forall(b in 1..BLOCKS, p1,p2 in 1..PROCESSORS, s in 2..STEPS) compress(b,s) >= compressed(b,p1,s)+uncompressed(b,p2,s-1)-1 ! DeCompression can be captured by forall(b in 1..BLOCKS, p1,p2 in 1..PROCESSORS, s in 2..STEPS) decompress(b,s) >= uncompressed(b,p1,s)+compressed(b,p2,s-1)-1 ! Binary definitions. forall(b in 1..BLOCKS, p in 1..PROCESSORS, s in 1..STEPS) compressed(b,p,s) is_binary forall(b in 1..BLOCKS, p in 1..PROCESSORS, s in 1..STEPS) uncompressed(b,p,s) is_binary forall(b in 1..BLOCKS, s in 1..STEPS) offchip(b,s) is_binary forall(b in 1..BLOCKS, s in 1..STEPS) move_offchip(b,s) is_binary forall(b in 1..BLOCKS, s in 1..STEPS) move_onchip(b,s) is_binary forall(b in 1..BLOCKS, s in 1..STEPS) compress(b,s) is_binary forall(b in 1..BLOCKS, s in 1..STEPS) decompress(b,s) is_binary local_access_cost:=sum( b in 1..BLOCKS, p in 1..PROCESSORS, s in 1..STEPS | b=ACCESSES(p,s)) uncompressed(b,p,s)*ONCHIP_COST remote_access_cost:=sum( b in 1..BLOCKS, p1,p2 in 1..PROCESSORS, s in 1..STEPS | b=ACCESSES(p1,s) and p1<>p2) uncompressed(b,p2,s)*REMOTE_COST offchip_access_cost:=sum(b in 1..BLOCKS, p in 1..PROCESSORS, s in 1..STEPS | b=ACCESSES(p,s)) offchip(b,s)*OFFCHIP_COST access_cost:=local_access_cost+remote_access_cost+offchip_access_cost move_offchip_cost:=sum(b in 1..BLOCKS, s in 1..STEPS) move_offchip(b,s)*MOVEOFFCHIP_COST move_onchip_cost:=sum(b in 1..BLOCKS, s in 1..STEPS) move_onchip(b,s)*MOVEONCHIP_COST move_cost:=move_offchip_cost + move_onchip_cost compress_cost:=sum(b in 1..BLOCKS, s in 1..STEPS) compress(b,s)*COMPRESSION_COST decompress_cost:=sum(b in 1..BLOCKS, s in 1..STEPS) decompress(b,s)*DECOMPRESSION_COST compression_cost:=compress_cost + decompress_cost total_cost:=access_cost+move_cost+compression_cost minimize(total_cost) writeln("Total cost: \t", getobjval) writeln("Access cost: \t", getsol(access_cost)) writeln(" \tLocal:", getsol(local_access_cost)) writeln(" \tRemote:", getsol(remote_access_cost)) writeln(" \tOffchip:", getsol(offchip_access_cost)) writeln("Move cost: \t", getsol(move_cost)) writeln(" \tOffchip:", getsol(move_offchip_cost)) writeln(" \tOnchip:", getsol(move_onchip_cost)) writeln("Compress: \t", getsol(compress_cost)) writeln("Decompress: \t", getsol(decompress_cost)) writeln(""); forall(b in 1..BLOCKS) do write(b,"--> ") forall(s in 1..STEPS) do forall(p in 1..PROCESSORS) do if(getsol(compressed(b,p,s))>0) then write(" C",p); end-if if(getsol(uncompressed(b,p,s))>0) then write(" U",p); end-if end-do if(getsol(offchip(b,s))>0) then write(" O "); end-if end-do writeln(""); end-do end-model