Skip to content

Latest commit

 

History

History
126 lines (77 loc) · 3.34 KB

File metadata and controls

126 lines (77 loc) · 3.34 KB

ternaryBlockSize

Resolve a loop block size for multi-dimensional array tiled loops.

Usage

var ternaryBlockSize = require( '@stdlib/ndarray/base/ternary-tiling-block-size' );

ternaryBlockSize( dtypeW, dtypeX, dtypeY, dtypeZ )

Resolves a loop block size according to provided ndarray dtypes for multi-dimensional array tiled loops applying a ternary function.

var bsize = ternaryBlockSize( 'float64', 'float64', 'float64', 'float64' );
// returns <number>

Notes

  • The returned loop tiling block size is in units of elements.

Examples

var dtypes = require( '@stdlib/ndarray/dtypes' );
var cartesianPower = require( '@stdlib/array/base/cartesian-power' );
var promotionRules = require( '@stdlib/ndarray/promotion-rules' );
var ternaryBlockSize = require( '@stdlib/ndarray/base/ternary-tiling-block-size' );

// Generate a list of input ndarray dtype triplets:
var dt = cartesianPower( dtypes(), 3 );

// Resolve the block size for each dtype triplet and its promoted dtype...
var t;
var b;
var i;
console.log( 'block_size, wdtype, xdtype, ydtype, zdtype' );
for ( i = 0; i < dt.length; i++ ) {
    t = promotionRules.apply( null, dt[ i ] );
    dt[ i ].push( ( t === -1 ) ? 'generic' : t );
    b = ternaryBlockSize.apply( null, dt[ i ] );
    console.log( '%d, %s, %s, %s, %s', b, dt[i][0], dt[i][1], dt[i][2], dt[i][3] );
}