model: sets: !F; V: vSize, vRead, vWrite,vStart, vDcost; U: uSize, uRead, uWrite; !F2V(F,V); !F2U(F,U): fInU; V2U(V,U): x, cost; V2V(V, V): iltj; endsets data: M = 20000; DRead = 104.4; DWrite = 104.4; U, uRead, uWrite, uSize = @file('E:/qali/memory.txt'); V = @file('E:/qali/spm/basicmath.opt1.variable'); vRead=@file(E:/qali/spm/basicmath.opt1.variable); vWrite=@file(E:/qali/spm/basicmath.opt1.variable); vSize=@file(E:/qali/spm/basicmath.opt1.variable); V2V=@file('E:/qali/spm/basicmath.opt.ig.out'); !Inter=@file(E:/Mibench_spm/basicmath.opt.gIG); @text(E:/qali/lingo.log)='Size of Memory units:\n' uSize; enddata Calc: @for(U(ui): @for(V(vi): cost(vi,ui) = (uRead(ui) * vRead(vi) + uWrite(ui) * vWrite(vi) ) ); ); @for(V(vi): vDcost(vi) = (DRead * vRead(vi) + DWrite * vWrite(vi) ) * vSize(vi) ); nNumber = @size(V); nSize = @sum(V(I): vSize(I) ); @write('Total functions: ', @size(F), @newline(1)); @write('Total variable number: ', nNumber, @newline(1)); @write('Total variable size: ', nSize, @newline(1)); @write('Total interfere: ', @size(V2V), @newline(1)); endcalc min = @sum(V2U: x * cost) + @sum(V(vi): (1-@sum(U(ui): x(vi,ui)))*vDcost); !u2f: size of function fi in memory ui; @for(U(ui): @sum(F2U(fi,ui):fInU(fi,ui)) <= uSize(ui) ); !@for(U2F(ui,fi): @bnd(0, fInU(ui,fi), uSize(ui)) ); !@for(F2U: @gin(fInU) ); !x(vi,ui): assuming variable vi is allocated into memory ui; @for(V(vi): @sum(V2U(vi,ui): x(vi,ui)) <= 1 ); @for(V2U: @bin(x) ); !start(vi): start point of location of variable; !@for(F2V(fi,vi): @for(U(ui): vStart(vi) >= @sum(F2U(f1,ui)| fID(f1) #lt# fID(fi): fInU(f1,ui) ) + (x(vi,ui)-1)*M) ); !@for(F2V(fi,vi): @for(U(ui): vStart(vi) <= @sum(F2U(f1,ui)| fID(f1) #le# fID(fi): fInU(f1,ui) ) - vSize(vi) + (1-x(vi,ui))*M) ); !@for(V(vi): @gin(vStart) ); !@for(F2V(fi,vi): @for(U(ui): vStart(vi)+vSize(vi) < fInU(fi,ui) + (1- x(vi,ui)) * M ) ); !@for(V(vi):@gin(vStart) ); !iltj: assuming i is less than j, for the interference graph; @for(V2V: @bin(iltj) ); @for(V2V(v1,v2): @for(U(ui): vStart(v1) + 1<= vStart(v2) + (1-iltj(v1,v2))*M + (2-x(v1,ui)-x(v2,ui))*M ) ); @for(V2V(v1,v2): @for(U(ui): vStart(v2) + 1<= vStart(v1) + iltj(v1,v2)*M + (2-x(v1,ui)-x(v2,ui))*M) );