Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# quinaryBlockSize

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

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var quinaryBlockSize = require( '@stdlib/ndarray/base/quinary-tiling-block-size' );
```

#### quinaryBlockSize( dtypeX, dtypeY, dtypeZ, dtypeW, dtypeU, dtypeV )

Resolves a loop block size according to provided ndarray [dtypes][@stdlib/ndarray/dtypes] for multi-dimensional array tiled loops applying a quinary function.

```javascript
var bsize = quinaryBlockSize( 'float64', '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**: fifth input array data type.
- **dtypeV**: output array data type.

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

## Notes

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

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

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

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

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

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var blockSize = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var dx;
var dy;
var dz;
var dw;
var du;
var dv;
var s;
var i;

dx = [
'float64',
'float32',
'int8',
'uint8',
'uint8c',
'int16',
'uint16',
'int32',
'uint32',
'binary',
'generic',
'foobar'
];
dy = [
'float64',
'float32',
'int8',
'uint8',
'uint8c',
'int16',
'uint16',
'int32',
'uint32',
'binary',
'generic',
'foobar'
];
dz = [
'float64',
'float32',
'int8',
'uint8',
'uint8c',
'int16',
'uint16',
'int32',
'uint32',
'binary',
'generic',
'foobar'
];
dw = [
'float64',
'float32',
'int8',
'uint8',
'uint8c',
'int16',
'uint16',
'int32',
'uint32',
'binary',
'generic',
'foobar'
];
du = [
'float64',
'float32',
'int8',
'uint8',
'uint8c',
'int16',
'uint16',
'int32',
'uint32',
'binary',
'generic',
'foobar'
];
dv = [
'float64',
'generic',
'int32',
'int16',
'int8'
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
s = blockSize( dx[ i%dx.length ], dy[ i%dy.length ], dz[ i%dz.length ], dw[ i%dw.length ], du[ i%du.length ], dv[ i%dv.length ] ); // eslint-disable-line max-len
if ( typeof s !== 'number' ) {
b.fail( 'should return a number' );
}
}
b.toc();
if ( !isPositiveInteger( s ) ) {
b.fail( 'should return a positive integer' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

{{alias}}( dtypeX, dtypeY, dtypeZ, dtypeW, dtypeU, dtypeV )
Returns a loop block size for multi-dimensional array tiled loops.

Parameters
----------
dtypeX: string|DataType
First input array data type.

dtypeY: string|DataType
Second input array data type.

dtypeZ: string|DataType
Third input array data type.

dtypeW: string|DataType
Fourth input array data type.

dtypeU: string|DataType
Fifth input array data type.

dtypeV: string|DataType
Output array data type.

Returns
-------
out: integer
Block size.

Examples
--------
> out = {{alias}}( 'float64', 'int32', 'uint8', 'int8', 'int16', 'float64' )
<number>

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/// <reference types="@stdlib/types"/>

import { DataType } from '@stdlib/types/ndarray';

/**
* Returns a loop block size for multi-dimensional array tiled loops.
*
* @param dtypeX - first input array data type
* @param dtypeY - second input array data type
* @param dtypeZ - third input array data type
* @param dtypeW - fourth input array data type
* @param dtypeU - fifth input array data type
* @param dtypeV - output array data type
* @returns block size (in units of elements)
*
* @example
* var bsize = quinaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64', 'float64' );
* // returns <number>
*/
declare function quinaryBlockSize( dtypeX: DataType, dtypeY: DataType, dtypeZ: DataType, dtypeW: DataType, dtypeU: DataType, dtypeV: DataType ): number;


// EXPORTS //

export = quinaryBlockSize;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import quinaryBlockSize = require( './index' );


// TESTS //

// The function returns a number...
{
quinaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64', 'float64' ); // $ExpectType number
quinaryBlockSize( 'float32', 'int8', 'uint16', 'int32', 'uint8', 'complex128' ); // $ExpectType number
quinaryBlockSize( 'generic', 'generic', 'generic', 'generic', 'generic', 'generic' ); // $ExpectType number
}

// The compiler throws an error if the function is provided insufficient arguments...
{
quinaryBlockSize(); // $ExpectError
quinaryBlockSize( 'float64' ); // $ExpectError
quinaryBlockSize( 'float64', 'float64' ); // $ExpectError
quinaryBlockSize( 'float64', 'float64', 'float64' ); // $ExpectError
quinaryBlockSize( 'float64', 'float64', 'float64', 'float64' ); // $ExpectError
quinaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64' ); // $ExpectError
}

// The compiler throws an error if the function is provided too many arguments...
{
quinaryBlockSize( 'float64', 'float64', 'float64', 'float64', 'float64', 'float64', {} ); // $ExpectError
}
Loading