@stdlib/ndarray-base-nullary-tiling-block-size 0.2.1 → 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
@@ -98,19 +98,15 @@ var bsize = nullaryBlockSize( 'float64' );
98
98
 
99
99
  ```javascript
100
100
  var dtypes = require( '@stdlib/ndarray-dtypes' );
101
+ var logEachMap = require( '@stdlib/console-log-each-map' );
101
102
  var nullaryBlockSize = require( '@stdlib/ndarray-base-nullary-tiling-block-size' );
102
103
 
103
104
  // Get the list of ndarray dtypes:
104
105
  var dt = dtypes();
105
106
 
106
- // Resolve the block size for each dtype...
107
- var b;
108
- var i;
109
- console.log( 'block_size, xdtype' );
110
- for ( i = 0; i < dt.length; i++ ) {
111
- b = nullaryBlockSize( dt[ i ] );
112
- console.log( '%d, %s', b, dt[ i ] );
113
- }
107
+ // Resolve the block size for each dtype:
108
+ console.log( 'xdtype, block_size' );
109
+ logEachMap( '%s, %d', dt, nullaryBlockSize );
114
110
  ```
115
111
 
116
112
  </section>
@@ -159,7 +155,7 @@ See [LICENSE][stdlib-license].
159
155
 
160
156
  ## Copyright
161
157
 
162
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
158
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
163
159
 
164
160
  </section>
165
161
 
@@ -172,8 +168,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
172
168
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-nullary-tiling-block-size.svg
173
169
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-nullary-tiling-block-size
174
170
 
175
- [test-image]: https://github.com/stdlib-js/ndarray-base-nullary-tiling-block-size/actions/workflows/test.yml/badge.svg?branch=v0.2.1
176
- [test-url]: https://github.com/stdlib-js/ndarray-base-nullary-tiling-block-size/actions/workflows/test.yml?query=branch:v0.2.1
171
+ [test-image]: https://github.com/stdlib-js/ndarray-base-nullary-tiling-block-size/actions/workflows/test.yml/badge.svg?branch=v0.2.3
172
+ [test-url]: https://github.com/stdlib-js/ndarray-base-nullary-tiling-block-size/actions/workflows/test.yml?query=branch:v0.2.3
177
173
 
178
174
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-nullary-tiling-block-size/main.svg
179
175
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-nullary-tiling-block-size?branch=main
@@ -185,8 +181,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
185
181
 
186
182
  -->
187
183
 
188
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
189
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
184
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
185
+ [chat-url]: https://stdlib.zulipchat.com
190
186
 
191
187
  [stdlib]: https://github.com/stdlib-js/stdlib
192
188
 
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
- "use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var E=t(function(B,u){
2
- var a={BLOCK_SIZE_IN_BYTES:64,BLOCK_SIZE_IN_ELEMENTS:8};u.exports=a
3
- });var i=t(function(L,_){
4
- var n=require('@stdlib/ndarray-base-bytes-per-element/dist'),s=E();function S(e){var r=n(e);return r===null?s.BLOCK_SIZE_IN_ELEMENTS:s.BLOCK_SIZE_IN_BYTES/r|0}_.exports=S
5
- });var l=i();module.exports=l;
1
+ "use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=u(function(a,i){
2
+ var s=require('@stdlib/ndarray-base-tiling-block-size/dist');function c(e){return s([e])}i.exports=c
3
+ });var n=t();module.exports=n;
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 - array data type\n* @returns {integer} block size (in units of elements)\n*\n* @example\n* var bsize = nullaryBlockSize( 'float64' );\n* // returns <number>\n*/\nfunction nullaryBlockSize( dtypeX ) {\n\tvar nbx = bytesPerElement( dtypeX );\n\tif ( nbx === null ) { // e.g., \"generic\" arrays\n\t\treturn defaults.BLOCK_SIZE_IN_ELEMENTS;\n\t}\n\treturn ( defaults.BLOCK_SIZE_IN_BYTES/nbx )|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nmodule.exports = nullaryBlockSize;\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-nullary-tiling-block-size\n*\n* @example\n* var nullaryBlockSize = require( '@stdlib/ndarray-base-nullary-tiling-block-size' );\n*\n* var bsize = nullaryBlockSize( '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,IAef,SAASC,EAAkBC,EAAS,CACnC,IAAIC,EAAMJ,EAAiBG,CAAO,EAClC,OAAKC,IAAQ,KACLH,EAAS,uBAERA,EAAS,oBAAoBG,EAAM,CAC7C,CAKAL,EAAO,QAAUG,ICfjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_defaults", "__commonJSMin", "exports", "module", "defaults", "require_main", "__commonJSMin", "exports", "module", "bytesPerElement", "defaults", "nullaryBlockSize", "dtypeX", "nbx", "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 - array data type\n* @returns {integer} block size (in units of elements)\n*\n* @example\n* var bsize = nullaryBlockSize( 'float64' );\n* // returns <number>\n*/\nfunction nullaryBlockSize( dtypeX ) {\n\treturn blockSize( [ dtypeX ] );\n}\n\n\n// EXPORTS //\n\nmodule.exports = nullaryBlockSize;\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-nullary-tiling-block-size\n*\n* @example\n* var nullaryBlockSize = require( '@stdlib/ndarray-base-nullary-tiling-block-size' );\n*\n* var bsize = nullaryBlockSize( '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,EAelE,SAASC,EAAkBC,EAAS,CACnC,OAAOF,EAAW,CAAEE,CAAO,CAAE,CAC9B,CAKAH,EAAO,QAAUE,ICVjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "blockSize", "nullaryBlockSize", "dtypeX", "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
  *
@@ -28,7 +32,7 @@
28
32
  * var bsize = nullaryBlockSize( 'float64' );
29
33
  * // returns <number>
30
34
  */
31
- declare function nullaryBlockSize( dtypeX: string ): number;
35
+ declare function nullaryBlockSize( dtypeX: DataType ): number;
32
36
 
33
37
 
34
38
  // 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,7 +28,7 @@ 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 - array data type
31
+ * @param {*} dtypeX - array data type
33
32
  * @returns {integer} block size (in units of elements)
34
33
  *
35
34
  * @example
@@ -37,11 +36,7 @@ var defaults = require( './defaults.js' );
37
36
  * // returns <number>
38
37
  */
39
38
  function nullaryBlockSize( dtypeX ) {
40
- var nbx = bytesPerElement( dtypeX );
41
- if ( nbx === null ) { // e.g., "generic" arrays
42
- return defaults.BLOCK_SIZE_IN_ELEMENTS;
43
- }
44
- return ( defaults.BLOCK_SIZE_IN_BYTES/nbx )|0; // asm type annotation
39
+ return blockSize( [ dtypeX ] );
45
40
  }
46
41
 
47
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-nullary-tiling-block-size",
3
- "version": "0.2.1",
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;