Skip to content

Commit e77482d

Browse files
author
lxx.mbp2015
committed
fix: 为录屏演示调优
1 parent d92b668 commit e77482d

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

dist/index.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<link rel="stylesheet" href="https://unpkg.com/vue-material/dist/vue-material.min.css">
1212
<link rel="stylesheet" href="https://unpkg.com/vue-material/dist/theme/default.css">
1313
<link rel="stylesheet" type="text/css" href="./main.css">
14-
<title>COStreamJS-v0.10.3</title>
14+
<title>COStreamJS-v0.10.4</title>
1515
<style> .md-snackbar{ max-height: none!important;} </style>
1616
</head>
1717

@@ -166,7 +166,7 @@ <h1 class="md-title">FlatNodes</h1>
166166
})
167167
}
168168
if (!window.str) {
169-
LoadFileAsync('DCT')
169+
LoadFileAsync('mnist')
170170
} else {
171171
showCode(str);
172172
}
@@ -193,12 +193,12 @@ <h1 class="md-title">FlatNodes</h1>
193193
el: '#app',
194194
data() {
195195
return {
196-
flats: [],
196+
flats: [], /** 成员有: {name,workEstimate,steadyCount,coreNum,stageNum>} */
197197
isDOT: false,
198198
showSnackbar: false,
199199
snackBarMessage: '',
200200
symbol_table: {},
201-
file: "DCT", // 默认的示例文件名,
201+
file: "mnist", // 默认的示例文件名,
202202
core: 4, // 默认的划分核数
203203
status: 0 // 0: 未编译, 1: 已打印语法树 2:已生成ssg 3: 已完成工作量估计 4: 已完成调度 5: 已划分 6: 已阶段赋值且代码生成,处于源码状态 7:查看目标代码状态
204204
}
@@ -209,10 +209,10 @@ <h1 class="md-title">FlatNodes</h1>
209209
old_code = str;
210210
try {
211211
window.COStreamJS.main(str, { platform: 'WEB', coreNum:this.core || 4 })
212-
this.flats = COStreamJS.ssg.flatNodes
213-
this.flats.forEach(flat => {
214-
Vue.set(flat, 'workEstimate', COStreamJS.ssg.mapSteadyWork2FlatNode.get(flat))
215-
Vue.set(flat, 'coreNum', COStreamJS.mp.FlatNode2PartitionNum.get(flat))
212+
this.flats = COStreamJS.ssg.flatNodes.map(({name,steadyCount,stageNum})=>({name,steadyCount,stageNum}))
213+
COStreamJS.ssg.flatNodes.forEach((flat,idx) => {
214+
this.flats[idx].workEstimate = COStreamJS.ssg.mapSteadyWork2FlatNode.get(flat)
215+
this.flats[idx].coreNum = COStreamJS.mp.FlatNode2PartitionNum.get(flat)
216216
})
217217
this.status = 6
218218
} catch (err) {
@@ -234,6 +234,9 @@ <h1 class="md-title">FlatNodes</h1>
234234
await window.renderDot(dotStr)
235235
},
236236
coreNum2Color(num) {
237+
if(num === undefined){
238+
return 'undefined'
239+
}
237240
const colors = ["aliceblue", "antiquewhite", "yellowgreen", "aquamarine","azure", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid"]
238241
return colors[num]
239242
},
@@ -266,24 +269,25 @@ <h1 class="md-title">FlatNodes</h1>
266269
COStreamJS.gMainComposite = COStreamJS.SemCheck.findMainComposite(COStreamJS.ast);
267270
// 4. 语法树转数据流图
268271
COStreamJS.ssg = COStreamJS.AST2FlatStaticStreamGraph(COStreamJS.gMainComposite, COStreamJS.unfold, COStreamJS.S);
269-
this.flats = COStreamJS.ssg.flatNodes
272+
this.flats = COStreamJS.ssg.flatNodes.map(flat=>({name: flat.name}))
270273
break;
271274
}
272275
case 2:
273276
// 5. 工作量估计
274277
COStreamJS.WorkEstimate(COStreamJS.ssg);
275-
this.flats.forEach(flat => Vue.set(flat, 'workEstimate', COStreamJS.ssg.mapSteadyWork2FlatNode.get(flat)));
278+
COStreamJS.ssg.flatNodes.forEach((flat,idx) => this.flats[idx].workEstimate = COStreamJS.ssg.mapSteadyWork2FlatNode.get(flat));
276279
break;
277280
case 3:
278281
COStreamJS.ShedulingSSG(COStreamJS.ssg); // 6. 调度
282+
COStreamJS.ssg.flatNodes.forEach((flat,idx) => this.flats[idx].steadyCount = flat.steadyCount);
279283
break;
280284
case 4:{
281285
// 7. 划分
282286
COStreamJS.mp = new COStreamJS.GreedyPartition(COStreamJS.ssg);
283287
COStreamJS.mp.setCpuCoreNum(this.core);
284288
COStreamJS.mp.SssgPartition(COStreamJS.ssg);
285289
COStreamJS.mp.computeCommunication();
286-
this.flats.forEach(flat => Vue.set(flat, 'coreNum', COStreamJS.mp.FlatNode2PartitionNum.get(flat)))
290+
COStreamJS.ssg.flatNodes.forEach((flat,idx) => this.flats[idx].coreNum = COStreamJS.mp.FlatNode2PartitionNum.get(flat))
287291
// 8. 输出统计信息
288292
let SI = COStreamJS.GetSpeedUpInfo(COStreamJS.ssg,COStreamJS.mp);
289293
debug(COStreamJS.PrintSpeedUpInfo(SI));
@@ -292,6 +296,7 @@ <h1 class="md-title">FlatNodes</h1>
292296
case 5:{
293297
// 9. 阶段赋值
294298
COStreamJS.MaxStageNum = COStreamJS.StageAssignment(COStreamJS.ssg,COStreamJS.mp);
299+
COStreamJS.ssg.flatNodes.forEach((flat,idx) => this.flats[idx].stageNum = flat.stageNum);
295300
// 10.目标代码生成
296301
COStreamJS.files = {};
297302
COStreamJS.codeGeneration(COStreamJS.mp.finalParts,COStreamJS.ssg,COStreamJS.mp);
@@ -346,6 +351,7 @@ <h1 class="md-title">FlatNodes</h1>
346351
this.status = 0
347352
},
348353
core: function (newCore){
354+
if(this.status == 7) this.onToggleTargetCode()
349355
this.status = 0
350356
}
351357
},

src/FrontEnd/FlatNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export class FlatNode {
4141
/** init调度次数 */
4242
this.initCount = 0
4343
/** 稳态调度次数 */
44-
this.steadyCount = undefined
44+
this.steadyCount = 0
4545
/** 阶段号 */
46-
this.stageNum = undefined
46+
this.stageNum = 0
4747
}
4848

4949
AddOutEdges(/*FlatNode */ dest) {

src/FrontEnd/checkShape.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function checkBinopShape(/** @type {binopNode} */stmt){
4040
}else if(stmt.op === '*'){
4141
return checkMultiShape(stmt)
4242
}
43-
return lshape
43+
return [1,1]
4444
}
4545
function checkMultiShape(/** @type {binopNode} */stmt){
4646
const lshape = checkShape(stmt.left), rshape = checkShape(stmt.right)

src/LifeCycle/DumpStreamGraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function MyVisitNode(node,ssg,mp){
4242
str = str.replace(/PPP/,ppp)
4343

4444
if(mp){
45-
let id = mp.findPartitionNumForFlatNode(node)
45+
let id = mp.findPartitionNumForFlatNode(node) || 0
4646
str = str.replace(/azure/,colors[id])
4747
}
4848

0 commit comments

Comments
 (0)