@@ -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