binaryBlockSize
Resolve a loop block size for multi-dimensional array tiled loops.
Usage
var binaryBlockSize = require( '@stdlib/ndarray/base/binary-tiling-block-size' );
binaryBlockSize( dtypeX, dtypeY, dtypeZ )
Resolves a loop block size according to provided ndarray dtypes for multi-dimensional array tiled loops applying a binary function.
var bsize = binaryBlockSize( '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 cartesianSquare = require( '@stdlib/array/base/cartesian-square' );
var promotionRules = require( '@stdlib/ndarray/promotion-rules' );
var binaryBlockSize = require( '@stdlib/ndarray/base/binary-tiling-block-size' );
// Generate a list of input ndarray dtype pairs:
var dt = cartesianSquare( dtypes() );
// Resolve the block size for each dtype pair and its promoted dtype...
var t;
var b;
var i;
console.log( 'block_size, xdtype, ydtype, zdtype' );
for ( i = 0; i < dt.length; i++ ) {
t = promotionRules.apply( null, dt[ i ] );
dt[ i ].push( ( t === -1 ) ? 'generic' : t );
b = binaryBlockSize.apply( null, dt[ i ] );
console.log( '%d, %s, %s, %s', b, dt[i][0], dt[i][1], dt[i][2] );
}