-
Notifications
You must be signed in to change notification settings - Fork 12
/
CCBGProblem.lng
97 lines (85 loc) · 3.52 KB
/
CCBGProblem.lng
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
MODEL:
! 将Cascade Bipartite Graph的任务分配问题用一个minmax的目标进行优化;
! 使得任务分配对计算和通信节点的时间开销最大值最小化;
! 变量主要为频率omega和任务分配矩阵Xp;
! Cascade Bipartite Graph;
SETS:
cu /1..8/;
lk /1..14/;
f /1..42/;
p /1..42/;
e /1..14/;
! Make all the vectors, column vectors;
lxcxc( lk, cu, cu): TENSOR;
fxf(f, f): OMEGA,WORKLOAD,DELAYCONSTRAINT,FLUXFORFUNCPAIR;
lv(lk): BANDWIDTH, DELAY,lkload;
cuv(cu): SPEED,cuload;
fv(f): FREQUENCY;
ev(e): evDemo;
cuxcu(cu, cu): DELAYFORCU;
! objective function;
cuxf(cu, f): Xp; ! Function Task assignment matrix;
! Not adopted;
exf(e, f): OBJECTCONSTRAINT;
ENDSETS
DATA:
TENSOR = @POINTER( 1); ! "Topology" for different Compute Units with Transport nodes;
FLUXFORFUNCPAIR = @POINTER( 2); ! "Data Load" of states;
FREQUENCY = @POINTER( 3); ! "Freqency" of f diag([freqency,freqency,...,freqency]);
WORKLOAD = @POINTER( 4); ! "Workload" of f diag([workload,workload,...,workload]);
BANDWIDTH = @POINTER( 5); ! "Bandwidth" of Transport nodes;
SPEED = @POINTER( 6); ! "Speed" of Compute Units;
DELAY = @POINTER( 7); ! "Delay" of Transport nodes;
DELAYCONSTRAINT = @POINTER( 8); ! "Delay" constraint for pair(fi,fj);
OBJECTCONSTRAINT = @POINTER( 9); ! Bool flag for "Object" constraint for pair(fi,fj);
ENDDATA
procedure TensorProduct1:
! Frobenius inner product x1;
@FOR(cuxcu(i,j):DELAYFORCU(i,j)=
@SUM(lv(k):
TENSOR(k,i,j)*DELAY(k))) ;
endprocedure
CALC:
! Default options;
@SET( 'DEFAULT');
! Suppress default output;
! @SET( 'TERSEO', 2);
@SET('MTMODE',1);!Set the mode of multithreading;
@SET('NTHRDS',16);!Set the number of threads;
@SET('ITRLIM',72000);!Set the time limit of the model;
@SET('MXMEMB',1024);!Set Maximum Memory for model;
! @MAX/MIN makes model nonlinear.Global solver will linearize @MAX/MIN;
@SET( 'GLOBAL', 1);
! 2. 计算函数对间的通信时间 DELAYFORCU = TENSOR x1 DELAY;
TensorProduct1;
!@TABLE(FLUXFORFUNCPAIR);
!@WRITE( AQL);!Deal with var;
@TEXT() = ' Debug Output Showing Input:';
!@TABLE( OBJECTCONSTRAINT,2); !Deal with set and attri;
ENDCALC
[OBJ] MIN = MaxRatio;
! Entity Task assignment Mode: Xp Determined by Xe;
! Not adopted;
! Workload of each Transport node >=0;
! Frobenius inner product x2,3;
! Not adopted;
!@FOR(lv(k):MaxRatio >=
@SUM(cuxcu(i,j):
TENSOR(k,i,j)*@SUM(fxf(fi,fj):Xp(i,fi)*FREQUENCY(fi)*FLUXFORFUNCPAIR(fi,fj)*Xp(j,fj)))/BANDWIDTH(k)) ; !update workload of each Transport node;
! Worklad of each Compute Unit >= 0;
@FOR(cuv(cui):MaxRatio >=@SUM(fv(lfj):Xp(cui,lfj)*WORKLOAD(lfj,lfj))/SPEED(cui));
!@FOR(cuv(cui):MaxRatio >=
@SUM(fv(lfj):Xp(cui,lfj)*WORKLOAD(lfj,lfj))/SPEED(cui));
! The delay of each pair of functions should be less than the constraint;
@FOR(fxf(dfi,dfj):DELAYCONSTRAINT(dfi,dfj)>=
@SUM(cuxcu(dcui,dcuj):Xp(dcui,dfi)*Xp(dcuj,dfj)*@SUM(lv(k):TENSOR(k,dcui,dcuj)/BANDWIDTH(k)))+
@SUM(cuxcu(dcui,dcuj):Xp(dcui,dfi)*DELAYFORCU(dcui,dcuj)*Xp(dcuj,dfj)));
! Function assignment matrix Xp should be binary(bool) and satisfy the constraint that only assigned to one Compute Unit;
@FOR(fv(k):@SUM(cuv(ci):Xp(ci,k))=1); ! Function Task assignment matrix;
@FOR(cuxf(i,j):@BIN(Xp(i,j))); ! Function Task assignment matrix;
DATA:
@POINTER( 10) = Xp; ! Function Task assignment matrix(Both);
@POINTER( 11) = MaxRatio; ! "Occupy Ratio of computation or communication;
@POINTER( 12) = @STATUS();
ENDDATA
END