Skip to content

Latest commit

 

History

History
134 lines (83 loc) · 3.67 KB

File metadata and controls

134 lines (83 loc) · 3.67 KB

quaternaryBlockSize

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

Usage

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

quaternaryBlockSize( dtypeX, dtypeY, dtypeZ, dtypeW, dtypeU )

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

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

The function supports the following arguments:

  • dtypeX: first input array data type.
  • dtypeY: second input array data type.
  • dtypeZ: third input array data type.
  • dtypeW: fourth input array data type.
  • dtypeU: output array data type.

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 quaternaryBlockSize = require( '@stdlib/ndarray/base/quaternary-tiling-block-size' );

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

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