@stdlib/ndarray-base-binary-tiling-block-size 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -99,7 +99,7 @@ var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );
99
99
  ```javascript
100
100
  var dtypes = require( '@stdlib/ndarray-dtypes' );
101
101
  var cartesianSquare = require( '@stdlib/array-base-cartesian-square' );
102
- var promotionRules = require( '@stdlib/ndarray-promotion-rules' );
102
+ var promoteDataTypes = require( '@stdlib/ndarray-base-promote-dtypes' );
103
103
  var binaryBlockSize = require( '@stdlib/ndarray-base-binary-tiling-block-size' );
104
104
 
105
105
  // Generate a list of input ndarray dtype pairs:
@@ -111,8 +111,8 @@ var b;
111
111
  var i;
112
112
  console.log( 'block_size, xdtype, ydtype, zdtype' );
113
113
  for ( i = 0; i < dt.length; i++ ) {
114
- t = promotionRules.apply( null, dt[ i ] );
115
- dt[ i ].push( ( t === -1 ) ? 'generic' : t );
114
+ t = promoteDataTypes( dt[ i ] );
115
+ dt[ i ].push( ( t === null ) ? 'generic' : t );
116
116
  b = binaryBlockSize.apply( null, dt[ i ] );
117
117
  console.log( '%d, %s, %s, %s', b, dt[i][0], dt[i][1], dt[i][2] );
118
118
  }
@@ -164,7 +164,7 @@ See [LICENSE][stdlib-license].
164
164
 
165
165
  ## Copyright
166
166
 
167
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
167
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
168
168
 
169
169
  </section>
170
170
 
@@ -177,8 +177,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
177
177
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-binary-tiling-block-size.svg
178
178
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-binary-tiling-block-size
179
179
 
180
- [test-image]: https://github.com/stdlib-js/ndarray-base-binary-tiling-block-size/actions/workflows/test.yml/badge.svg?branch=v0.2.2
181
- [test-url]: https://github.com/stdlib-js/ndarray-base-binary-tiling-block-size/actions/workflows/test.yml?query=branch:v0.2.2
180
+ [test-image]: https://github.com/stdlib-js/ndarray-base-binary-tiling-block-size/actions/workflows/test.yml/badge.svg?branch=v0.2.3
181
+ [test-url]: https://github.com/stdlib-js/ndarray-base-binary-tiling-block-size/actions/workflows/test.yml?query=branch:v0.2.3
182
182
 
183
183
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-binary-tiling-block-size/main.svg
184
184
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-binary-tiling-block-size?branch=main
@@ -190,8 +190,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
190
190
 
191
191
  -->
192
192
 
193
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
194
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
193
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
194
+ [chat-url]: https://stdlib.zulipchat.com
195
195
 
196
196
  [stdlib]: https://github.com/stdlib-js/stdlib
197
197
 
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
- "use strict";var i=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var s=i(function(f,S){
2
- var l={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};S.exports=l
3
- });var a=i(function(C,I){
4
- var n=require('@stdlib/ndarray-base-bytes-per-element/dist'),E=s();function L(u,r,B){var e,t,_;return e=n(u),t=n(r),_=n(B),e===null||t===null||_===null?E.BLOCK_SIZE_IN_ELEMENTS:e>t&&e>_?E.BLOCK_SIZE_IN_BYTES/e|0:t>_?E.BLOCK_SIZE_IN_BYTES/t|0:E.BLOCK_SIZE_IN_BYTES/_|0}I.exports=L
5
- });var N=a();module.exports=N;
1
+ "use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=u(function(b,i){
2
+ var c=require('@stdlib/ndarray-base-tiling-block-size/dist');function n(e,r,s){return c([e,r,s])}i.exports=n
3
+ });var o=t();module.exports=o;
6
4
  /** @license Apache-2.0 */
7
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../lib/defaults.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar defaults = {\n\t// Define a default block size (in bytes):\n\t'BLOCK_SIZE_IN_BYTES': 64|0, // 64b is a common cache line size. How applicable the common cache line size is here is debatable, given that, depending on the associated stride(s), the innermost loop may not iterate over adjacent elements. The primary goal is to have a block size in which all data within a block can always fit in (L1) cache, regardless of cache size (i.e., cache-oblivious). For reference, a common L1 cache size is 32kB per core. For best performance, block sizes should be tuned based on system hardware; however, such tuning is not readily available to us here. Without obvious better alternatives, 64b has some theoretical (and practical) underpinning, and it should be good enough for most inputs, especially for ndarrays with near contiguity.\n\n\t// Define a default block size (in elements):\n\t'BLOCK_SIZE_IN_ELEMENTS': 8|0 // 64 bytes / 8 bytes per element (i.e., default element size is same as a double)\n};\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar defaults = require( './defaults.js' );\n\n\n// MAIN //\n\n/**\n* Returns a loop block size for multi-dimensional array tiled loops.\n*\n* @param {string} dtypeX - first input array data type\n* @param {string} dtypeY - second input array data type\n* @param {string} dtypeZ - output array data type\n* @returns {integer} block size (in units of elements)\n*\n* @example\n* var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );\n* // returns <number>\n*/\nfunction binaryBlockSize( dtypeX, dtypeY, dtypeZ ) {\n\tvar nbx;\n\tvar nby;\n\tvar nbz;\n\n\tnbx = bytesPerElement( dtypeX );\n\tnby = bytesPerElement( dtypeY );\n\tnbz = bytesPerElement( dtypeZ );\n\tif ( nbx === null || nby === null || nbz === null ) { // e.g., \"generic\" arrays\n\t\treturn defaults.BLOCK_SIZE_IN_ELEMENTS;\n\t}\n\tif ( nbx > nby && nbx > nbz ) {\n\t\treturn ( defaults.BLOCK_SIZE_IN_BYTES/nbx )|0; // asm type annotation\n\t}\n\tif ( nby > nbz ) {\n\t\treturn ( defaults.BLOCK_SIZE_IN_BYTES/nby )|0; // asm type annotation\n\t}\n\treturn ( defaults.BLOCK_SIZE_IN_BYTES/nbz )|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nmodule.exports = binaryBlockSize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Resolve a loop block size for multi-dimensional array tiled loops.\n*\n* @module @stdlib/ndarray-base-binary-tiling-block-size\n*\n* @example\n* var binaryBlockSize = require( '@stdlib/ndarray-base-binary-tiling-block-size' );\n*\n* var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );\n* // returns <number>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,CAEd,oBAAuB,GAGvB,uBAA0B,CAC3B,EAKAD,EAAO,QAAUC,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,wCAAyC,EACpEC,EAAW,IAiBf,SAASC,EAAiBC,EAAQC,EAAQC,EAAS,CAClD,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAMN,EAAiBG,CAAO,EAC9BI,EAAMP,EAAiBI,CAAO,EAC9BI,EAAMR,EAAiBK,CAAO,EACzBC,IAAQ,MAAQC,IAAQ,MAAQC,IAAQ,KACrCP,EAAS,uBAEZK,EAAMC,GAAOD,EAAME,EACdP,EAAS,oBAAoBK,EAAM,EAExCC,EAAMC,EACDP,EAAS,oBAAoBM,EAAM,EAEpCN,EAAS,oBAAoBO,EAAM,CAC7C,CAKAT,EAAO,QAAUG,IC7BjB,IAAIO,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_defaults", "__commonJSMin", "exports", "module", "defaults", "require_main", "__commonJSMin", "exports", "module", "bytesPerElement", "defaults", "binaryBlockSize", "dtypeX", "dtypeY", "dtypeZ", "nbx", "nby", "nbz", "main"]
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar blockSize = require( '@stdlib/ndarray-base-tiling-block-size' );\n\n\n// MAIN //\n\n/**\n* Returns a loop block size for multi-dimensional array tiled loops.\n*\n* @param {*} dtypeX - first input array data type\n* @param {*} dtypeY - second input array data type\n* @param {*} dtypeZ - output array data type\n* @returns {integer} block size (in units of elements)\n*\n* @example\n* var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );\n* // returns <number>\n*/\nfunction binaryBlockSize( dtypeX, dtypeY, dtypeZ ) {\n\treturn blockSize( [ dtypeX, dtypeY, dtypeZ ] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = binaryBlockSize;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Resolve a loop block size for multi-dimensional array tiled loops.\n*\n* @module @stdlib/ndarray-base-binary-tiling-block-size\n*\n* @example\n* var binaryBlockSize = require( '@stdlib/ndarray-base-binary-tiling-block-size' );\n*\n* var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );\n* // returns <number>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,wCAAyC,EAiBlE,SAASC,EAAiBC,EAAQC,EAAQC,EAAS,CAClD,OAAOJ,EAAW,CAAEE,EAAQC,EAAQC,CAAO,CAAE,CAC9C,CAKAL,EAAO,QAAUE,ICZjB,IAAII,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "blockSize", "binaryBlockSize", "dtypeX", "dtypeY", "dtypeZ", "main"]
7
7
  }
@@ -18,6 +18,10 @@
18
18
 
19
19
  // TypeScript Version: 4.1
20
20
 
21
+ /// <reference types="@stdlib/types"/>
22
+
23
+ import { DataType } from '@stdlib/types/ndarray';
24
+
21
25
  /**
22
26
  * Returns a loop block size for multi-dimensional array tiled loops.
23
27
  *
@@ -30,7 +34,7 @@
30
34
  * var bsize = binaryBlockSize( 'float64', 'float64', 'float64' );
31
35
  * // returns <number>
32
36
  */
33
- declare function binaryBlockSize( dtypeX: string, dtypeY: string, dtypeZ: string ): number;
37
+ declare function binaryBlockSize( dtypeX: DataType, dtypeY: DataType, dtypeZ: DataType ): number;
34
38
 
35
39
 
36
40
  // EXPORTS //
package/lib/main.js CHANGED
@@ -20,8 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
24
- var defaults = require( './defaults.js' );
23
+ var blockSize = require( '@stdlib/ndarray-base-tiling-block-size' );
25
24
 
26
25
 
27
26
  // MAIN //
@@ -29,9 +28,9 @@ var defaults = require( './defaults.js' );
29
28
  /**
30
29
  * Returns a loop block size for multi-dimensional array tiled loops.
31
30
  *
32
- * @param {string} dtypeX - first input array data type
33
- * @param {string} dtypeY - second input array data type
34
- * @param {string} dtypeZ - output array data type
31
+ * @param {*} dtypeX - first input array data type
32
+ * @param {*} dtypeY - second input array data type
33
+ * @param {*} dtypeZ - output array data type
35
34
  * @returns {integer} block size (in units of elements)
36
35
  *
37
36
  * @example
@@ -39,23 +38,7 @@ var defaults = require( './defaults.js' );
39
38
  * // returns <number>
40
39
  */
41
40
  function binaryBlockSize( dtypeX, dtypeY, dtypeZ ) {
42
- var nbx;
43
- var nby;
44
- var nbz;
45
-
46
- nbx = bytesPerElement( dtypeX );
47
- nby = bytesPerElement( dtypeY );
48
- nbz = bytesPerElement( dtypeZ );
49
- if ( nbx === null || nby === null || nbz === null ) { // e.g., "generic" arrays
50
- return defaults.BLOCK_SIZE_IN_ELEMENTS;
51
- }
52
- if ( nbx > nby && nbx > nbz ) {
53
- return ( defaults.BLOCK_SIZE_IN_BYTES/nbx )|0; // asm type annotation
54
- }
55
- if ( nby > nbz ) {
56
- return ( defaults.BLOCK_SIZE_IN_BYTES/nby )|0; // asm type annotation
57
- }
58
- return ( defaults.BLOCK_SIZE_IN_BYTES/nbz )|0; // asm type annotation
41
+ return blockSize( [ dtypeX, dtypeY, dtypeZ ] );
59
42
  }
60
43
 
61
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-binary-tiling-block-size",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Resolve a loop block size for multi-dimensional array tiled loops.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/ndarray-base-bytes-per-element": "^0.2.1"
33
+ "@stdlib/ndarray-base-tiling-block-size": "^0.1.0"
34
34
  },
35
35
  "devDependencies": {},
36
36
  "engines": {
@@ -65,7 +65,6 @@
65
65
  "utils",
66
66
  "util"
67
67
  ],
68
- "__stdlib__": {},
69
68
  "funding": {
70
69
  "type": "opencollective",
71
70
  "url": "https://opencollective.com/stdlib"
package/lib/defaults.js DELETED
@@ -1,34 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2023 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- 'use strict';
20
-
21
- // MAIN //
22
-
23
- var defaults = {
24
- // Define a default block size (in bytes):
25
- 'BLOCK_SIZE_IN_BYTES': 64|0, // 64b is a common cache line size. How applicable the common cache line size is here is debatable, given that, depending on the associated stride(s), the innermost loop may not iterate over adjacent elements. The primary goal is to have a block size in which all data within a block can always fit in (L1) cache, regardless of cache size (i.e., cache-oblivious). For reference, a common L1 cache size is 32kB per core. For best performance, block sizes should be tuned based on system hardware; however, such tuning is not readily available to us here. Without obvious better alternatives, 64b has some theoretical (and practical) underpinning, and it should be good enough for most inputs, especially for ndarrays with near contiguity.
26
-
27
- // Define a default block size (in elements):
28
- 'BLOCK_SIZE_IN_ELEMENTS': 8|0 // 64 bytes / 8 bytes per element (i.e., default element size is same as a double)
29
- };
30
-
31
-
32
- // EXPORTS //
33
-
34
- module.exports = defaults;