Skip to content

Commit 3367642

Browse files
committed
Lots of comments to satisfy linting
1 parent aa37e32 commit 3367642

File tree

2 files changed

+129
-133
lines changed

2 files changed

+129
-133
lines changed

src/webgpu/shader/execution/reconvergence/reconvergence.spec.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
55
import { iterRange, unreachable } from '../../../../common/util/util.js';
66
import { GPUTest } from '../../../gpu_test.js';
77

8-
import { hex, Style, OpType, Program, generateSeeds } from './util.js';
8+
import { /*hex, */ Style, OpType, Program, generateSeeds } from './util.js';
99

1010
export const g = makeTestGroup(GPUTest);
1111

@@ -63,28 +63,28 @@ function checkSubgroupSizeConsistency(
6363
return undefined;
6464
}
6565

66-
function dumpBallots(
67-
ballots: Uint32Array,
68-
totalInvocations: number,
69-
invocations: number,
70-
locations: number
71-
) {
72-
let dump = `Ballots\n`;
73-
for (let id = 0; id < invocations; id++) {
74-
dump += `id[${id}]\n`;
75-
for (let loc = 0; loc < locations; loc++) {
76-
const idx = 4 * (totalInvocations * loc + id);
77-
const w = ballots[idx + 3];
78-
const z = ballots[idx + 2];
79-
const y = ballots[idx + 1];
80-
const x = ballots[idx + 0];
81-
dump += ` loc[${loc}] = (0x${hex(w)},0x${hex(z)},0x${hex(y)},0x${hex(
82-
x
83-
)}), (${w},${z},${y},${x})\n`;
84-
}
85-
}
86-
console.log(dump);
87-
}
66+
//function dumpBallots(
67+
// ballots: Uint32Array,
68+
// totalInvocations: number,
69+
// invocations: number,
70+
// locations: number
71+
//) {
72+
// let dump = `Ballots\n`;
73+
// for (let id = 0; id < invocations; id++) {
74+
// dump += `id[${id}]\n`;
75+
// for (let loc = 0; loc < locations; loc++) {
76+
// const idx = 4 * (totalInvocations * loc + id);
77+
// const w = ballots[idx + 3];
78+
// const z = ballots[idx + 2];
79+
// const y = ballots[idx + 1];
80+
// const x = ballots[idx + 0];
81+
// dump += ` loc[${loc}] = (0x${hex(w)},0x${hex(z)},0x${hex(y)},0x${hex(
82+
// x
83+
// )}), (${w},${z},${y},${x})\n`;
84+
// }
85+
// }
86+
// console.log(dump);
87+
//}
8888

8989
/**
9090
* Checks the mapping of subgroup_invocation_id to local_invocation_index
@@ -117,17 +117,17 @@ const kDebugLevel = 0x0;
117117

118118
async function testProgram(t: GPUTest, program: Program) {
119119
const wgsl = program.genCode();
120-
if (kDebugLevel & 0x1) {
121-
console.log(wgsl);
122-
}
120+
//if (kDebugLevel & 0x1) {
121+
// console.log(wgsl);
122+
//}
123123
if (kDebugLevel & 0x2) {
124124
program.dumpStats(true);
125125
}
126126
if (kDebugLevel & 0x4) {
127127
return;
128128
}
129129

130-
// TODO: Query the limits when they are wired up.
130+
// Query the limits when they are wired up.
131131
const minSubgroupSize = 4;
132132
const maxSubgroupSize = 128;
133133

@@ -289,14 +289,14 @@ async function testProgram(t: GPUTest, program: Program) {
289289
const ballotData = ballotReadback.data;
290290

291291
// Only dump a single subgroup
292-
if (kDebugLevel & 0x10) {
293-
console.log(`${new Date()}: Reference data`);
294-
dumpBallots(program.refData, program.invocations, actualSize, num);
295-
}
296-
if (kDebugLevel & 0x20) {
297-
console.log(`${new Date()}: GPU data`);
298-
dumpBallots(ballotData, program.invocations, actualSize, num);
299-
}
292+
//if (kDebugLevel & 0x10) {
293+
// console.log(`${new Date()}: Reference data`);
294+
// dumpBallots(program.refData, program.invocations, actualSize, num);
295+
//}
296+
//if (kDebugLevel & 0x20) {
297+
// console.log(`${new Date()}: GPU data`);
298+
// dumpBallots(ballotData, program.invocations, actualSize, num);
299+
//}
300300

301301
t.expectOK(program.checkResults(ballotData, /*locationData,*/ actualSize, num));
302302
}

src/webgpu/shader/execution/reconvergence/util.ts

Lines changed: 94 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,9 @@ export class Program {
344344
this.ops = [];
345345
this.style = style;
346346
this.minCount = 30;
347-
//this.maxCount = 50000; // TODO: what is a reasonable limit?
348-
this.maxCount = 20000; // TODO: what is a reasonable limit?
349-
// TODO: https://crbug.com/tint/2011
347+
this.maxCount = 20000; // what is a reasonable limit?
348+
// https://crbug.com/tint/2011
350349
// Tint is double counting depth
351-
//this.maxNesting = this.getRandomUint(70) + 30; // [30,100)
352-
//this.maxNesting = this.getRandomUint(40) + 20;
353350
this.maxNesting = this.getRandomUint(20) + 20;
354351
// Loops significantly affect runtime and memory performance
355352
this.maxLoopNesting = 3; //4;
@@ -1408,81 +1405,80 @@ ${this.functions[i]}`;
14081405
*
14091406
* @param detailed If true, dumps more detailed stats
14101407
*/
1411-
public dumpStats(detailed: boolean = true) {
1412-
let stats = `Total instructions: ${this.ops.length}\n`;
1413-
let nesting = 0;
1414-
let stores = 0;
1415-
let totalStores = 0;
1416-
let totalLoops = 0;
1417-
const loopsAtNesting = new Array(this.maxLoopNesting);
1418-
loopsAtNesting.fill(0);
1419-
const storesAtNesting = new Array(this.maxLoopNesting + 1);
1420-
storesAtNesting.fill(0);
1421-
for (let i = 0; i < this.ops.length; i++) {
1422-
const op = this.ops[i];
1423-
switch (op.type) {
1424-
case OpType.Store:
1425-
case OpType.Ballot: {
1426-
stores++;
1427-
storesAtNesting[nesting]++;
1428-
break;
1429-
}
1430-
case OpType.ForUniform:
1431-
case OpType.LoopUniform:
1432-
case OpType.ForVar:
1433-
case OpType.ForInf:
1434-
case OpType.LoopInf: {
1435-
totalLoops++;
1436-
loopsAtNesting[nesting]++;
1437-
if (detailed) {
1438-
stats += ' '.repeat(nesting) + `${stores} stores\n`;
1439-
}
1440-
totalStores += stores;
1441-
stores = 0;
1442-
1443-
if (detailed) {
1444-
let iters = `subgroup size`;
1445-
if (op.type === OpType.ForUniform || op.type === OpType.LoopUniform) {
1446-
iters = `${op.value}`;
1447-
}
1448-
stats += ' '.repeat(nesting) + serializeOpType(op.type) + `: ${iters} iterations\n`;
1449-
}
1450-
nesting++;
1451-
break;
1452-
}
1453-
case OpType.EndForUniform:
1454-
case OpType.EndForInf:
1455-
case OpType.EndForVar:
1456-
case OpType.EndLoopUniform:
1457-
case OpType.EndLoopInf: {
1458-
if (detailed) {
1459-
stats += ' '.repeat(nesting) + `${stores} stores\n`;
1460-
}
1461-
totalStores += stores;
1462-
stores = 0;
1463-
1464-
nesting--;
1465-
if (detailed) {
1466-
stats += ' '.repeat(nesting) + serializeOpType(op.type) + '\n';
1467-
}
1468-
break;
1469-
}
1470-
default:
1471-
break;
1472-
}
1473-
}
1474-
totalStores += stores;
1475-
stats += `\n`;
1476-
stats += `${totalLoops} loops\n`;
1477-
for (let i = 0; i < loopsAtNesting.length; i++) {
1478-
stats += ` ${loopsAtNesting[i]} at nesting ${i}\n`;
1479-
}
1480-
stats += `${totalStores} stores\n`;
1481-
for (let i = 0; i < storesAtNesting.length; i++) {
1482-
stats += ` ${storesAtNesting[i]} at nesting ${i}\n`;
1483-
}
1484-
console.log(stats);
1485-
}
1408+
//public dumpStats(detailed: boolean = true) {
1409+
// let stats = `Total instructions: ${this.ops.length}\n`;
1410+
// let nesting = 0;
1411+
// let stores = 0;
1412+
// let totalStores = 0;
1413+
// let totalLoops = 0;
1414+
// const loopsAtNesting = new Array(this.maxLoopNesting);
1415+
// loopsAtNesting.fill(0);
1416+
// const storesAtNesting = new Array(this.maxLoopNesting + 1);
1417+
// storesAtNesting.fill(0);
1418+
// for (const op of this.ops) {
1419+
// switch (op.type) {
1420+
// case OpType.Store:
1421+
// case OpType.Ballot: {
1422+
// stores++;
1423+
// storesAtNesting[nesting]++;
1424+
// break;
1425+
// }
1426+
// case OpType.ForUniform:
1427+
// case OpType.LoopUniform:
1428+
// case OpType.ForVar:
1429+
// case OpType.ForInf:
1430+
// case OpType.LoopInf: {
1431+
// totalLoops++;
1432+
// loopsAtNesting[nesting]++;
1433+
// if (detailed) {
1434+
// stats += ' '.repeat(nesting) + `${stores} stores\n`;
1435+
// }
1436+
// totalStores += stores;
1437+
// stores = 0;
1438+
1439+
// if (detailed) {
1440+
// let iters = `subgroup size`;
1441+
// if (op.type === OpType.ForUniform || op.type === OpType.LoopUniform) {
1442+
// iters = `${op.value}`;
1443+
// }
1444+
// stats += ' '.repeat(nesting) + serializeOpType(op.type) + `: ${iters} iterations\n`;
1445+
// }
1446+
// nesting++;
1447+
// break;
1448+
// }
1449+
// case OpType.EndForUniform:
1450+
// case OpType.EndForInf:
1451+
// case OpType.EndForVar:
1452+
// case OpType.EndLoopUniform:
1453+
// case OpType.EndLoopInf: {
1454+
// if (detailed) {
1455+
// stats += ' '.repeat(nesting) + `${stores} stores\n`;
1456+
// }
1457+
// totalStores += stores;
1458+
// stores = 0;
1459+
1460+
// nesting--;
1461+
// if (detailed) {
1462+
// stats += ' '.repeat(nesting) + serializeOpType(op.type) + '\n';
1463+
// }
1464+
// break;
1465+
// }
1466+
// default:
1467+
// break;
1468+
// }
1469+
// }
1470+
// totalStores += stores;
1471+
// stats += `\n`;
1472+
// stats += `${totalLoops} loops\n`;
1473+
// for (let i = 0; i < loopsAtNesting.length; i++) {
1474+
// stats += ` ${loopsAtNesting[i]} at nesting ${i}\n`;
1475+
// }
1476+
// stats += `${totalStores} stores\n`;
1477+
// for (let i = 0; i < storesAtNesting.length; i++) {
1478+
// stats += ` ${storesAtNesting[i]} at nesting ${i}\n`;
1479+
// }
1480+
// console.log(stats);
1481+
//}
14861482

14871483
/**
14881484
* Sizes the simulation buffer.
@@ -1533,7 +1529,7 @@ ${this.functions[i]}`;
15331529
* @param subgroupSize The subgroup size to simulate
15341530
*
15351531
* BigInt is not the fastest value to manipulate. Care should be taken to optimize it's use.
1536-
* TODO: would it be better to roll my own 128 bitvector?
1532+
* Would it be better to roll my own 128 bitvector?
15371533
*
15381534
*/
15391535
public simulate(countOnly: boolean, subgroupSize: number, debug: boolean = false): number {
@@ -1578,8 +1574,8 @@ ${this.functions[i]}`;
15781574
this.isNonUniform = prev.isNonUniform;
15791575
}
15801576
}
1581-
for (let idx = 0; idx < this.ops.length; idx++) {
1582-
this.ops[idx].uniform = true;
1577+
for (const op of this.ops) {
1578+
op.uniform = true;
15831579
}
15841580

15851581
// Allocate the stack based on the maximum nesting in the program.
@@ -1606,16 +1602,16 @@ ${this.functions[i]}`;
16061602
}) at ops[${i}] = ${serializeOpType(op.type)}`
16071603
);
16081604
}
1609-
if (debug) {
1610-
console.log(
1611-
`ops[${i}] = ${serializeOpType(
1612-
op.type
1613-
)}, nesting = ${nesting}, loopNesting = ${loopNesting}, value = ${
1614-
op.value
1615-
}, nonuniform = ${stack[nesting].isNonUniform}`
1616-
);
1617-
console.log(` mask = ${stack[nesting].activeMask.toString(16)}`);
1618-
}
1605+
//if (debug) {
1606+
// console.log(
1607+
// `ops[${i}] = ${serializeOpType(
1608+
// op.type
1609+
// )}, nesting = ${nesting}, loopNesting = ${loopNesting}, value = ${
1610+
// op.value
1611+
// }, nonuniform = ${stack[nesting].isNonUniform}`
1612+
// );
1613+
// console.log(` mask = ${stack[nesting].activeMask.toString(16)}`);
1614+
//}
16191615

16201616
// Early outs if no invocations are active.
16211617
// Don't skip ops that change nesting.
@@ -2120,11 +2116,11 @@ ${this.functions[i]}`;
21202116

21212117
/** @returns a randomized program */
21222118
public generate() {
2123-
let i = 0;
2119+
//let i = 0;
21242120
do {
2125-
if (i !== 0) {
2126-
console.log(`Warning regenerating UCF testcase`);
2127-
}
2121+
//if (i !== 0) {
2122+
// console.log(`Warning regenerating UCF testcase`);
2123+
//}
21282124
this.ops = [];
21292125
while (this.ops.length < this.minCount) {
21302126
this.pickOp(1);
@@ -2136,7 +2132,7 @@ ${this.functions[i]}`;
21362132
if (this.style !== Style.Maximal) {
21372133
this.simulate(true, 64);
21382134
}
2139-
i++;
2135+
//i++;
21402136
} while (this.style !== Style.Maximal && !this.ucf);
21412137
}
21422138

0 commit comments

Comments
 (0)