@stdlib/blas-base-wasm-sdsdot 0.1.0
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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +417 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +362 -0
- package/lib/binary.browser.js +33 -0
- package/lib/binary.js +34 -0
- package/lib/index.js +101 -0
- package/lib/main.js +65 -0
- package/lib/module.js +220 -0
- package/lib/routine.js +180 -0
- package/manifest.json +36 -0
- package/package.json +92 -0
- package/src/exports.json +4 -0
- package/src/main.wasm +0 -0
- package/src/main.wat +239 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/binary.js", "../lib/module.js", "../lib/routine.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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 resolve = require( 'path' ).resolve;\nvar readWASM = require( '@stdlib/fs-read-wasm' ).sync;\n\n\n// MAIN //\n\nvar wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );\n\n\n// EXPORTS //\n\nmodule.exports = wasm;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isWebAssemblyMemory = require( '@stdlib/assert-is-wasm-memory' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar WasmModule = require( '@stdlib/wasm-module-wrapper' );\nvar format = require( '@stdlib/string-format' );\nvar wasmBinary = require( './binary.js' );\n\n\n// MAIN //\n\n/**\n* BLAS routine WebAssembly module wrapper constructor.\n*\n* @constructor\n* @param {Object} memory - WebAssembly memory instance\n* @throws {TypeError} must provide a WebAssembly memory instance\n* @returns {Module} module instance\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var sdsdot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* sdsdot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float32';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* sdsdot.write( xptr, oneTo( N, dtype ) );\n* sdsdot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var dot = sdsdot.main( N, 0.0, xptr, 1, yptr, 1 );\n* // returns 15.0\n*/\nfunction Module( memory ) {\n\tif ( !( this instanceof Module ) ) {\n\t\treturn new Module( memory );\n\t}\n\tif ( !isWebAssemblyMemory( memory ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a WebAssembly memory instance. Value: `%s`.', memory ) );\n\t}\n\t// Call the parent constructor:\n\tWasmModule.call( this, wasmBinary, memory, {\n\t\t'env': {\n\t\t\t'memory': memory\n\t\t}\n\t});\n\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Module, WasmModule );\n\n/**\n* Computes the dot product of two single-precision floating-point vectors with extended accumulation.\n*\n* @name main\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} scalar - scalar constant to add to dot product\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @returns {number} dot product\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var sdsdot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* sdsdot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float32';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* sdsdot.write( xptr, oneTo( N, dtype ) );\n* sdsdot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var dot = sdsdot.main( N, 0.0, xptr, 1, yptr, 1 );\n* // returns 15.0\n*/\nsetReadOnly( Module.prototype, 'main', function sdsdot( N, scalar, xptr, strideX, yptr, strideY ) {\n\treturn this._instance.exports.c_sdsdot( N, scalar, xptr, strideX, yptr, strideY );\n});\n\n/**\n* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} scalar - scalar constant to add to dot product\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {number} dot product\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var sdsdot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* sdsdot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float32';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* sdsdot.write( xptr, oneTo( N, dtype ) );\n* sdsdot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var sdsdot = sdsdot.ndarray( N, 0.0, xptr, 1, 0, yptr, 1, 0 );\n* // returns 15.0\n*/\nsetReadOnly( Module.prototype, 'ndarray', function sdsdot( N, scalar, xptr, strideX, offsetX, yptr, strideY, offsetY ) {\n\treturn this._instance.exports.c_sdsdot_ndarray( N, scalar, xptr, strideX, offsetX, yptr, strideY, offsetY ); // eslint-disable-line max-len\n});\n\n\n// EXPORTS //\n\nmodule.exports = Module;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar Memory = require( '@stdlib/wasm-memory' );\nvar arrays2ptrs = require( '@stdlib/wasm-base-arrays2ptrs' );\nvar strided2object = require( '@stdlib/wasm-base-strided2object' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* Routine constructor.\n*\n* @private\n* @constructor\n* @returns {Routine} routine instance\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Create a new routine:\n* var sdsdot = new Routine();\n*\n* // Initialize the module:\n* sdsdot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Create a new routine:\n* var sdsdot = new Routine();\n*\n* // Initialize the module:\n* sdsdot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*/\nfunction Routine() {\n\tif ( !( this instanceof Routine ) ) {\n\t\treturn new Routine();\n\t}\n\tModule.call( this, new Memory({\n\t\t'initial': 0\n\t}));\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Routine, Module );\n\n/**\n* Computes the dot product of two single-precision floating-point vectors with extended accumulation.\n*\n* @name main\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} scalar - scalar constant to add to dot product\n* @param {Float32Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Float32Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @returns {number} dot product\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Create a new routine:\n* var sdsdot = new Routine();\n*\n* // Initialize the module:\n* sdsdot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );\n* // returns 15.0\n*/\nsetReadOnly( Routine.prototype, 'main', function sdsdot( N, scalar, x, strideX, y, strideY ) {\n\treturn this.ndarray( N, scalar, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len\n});\n\n/**\n* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} scalar - scalar constant to add to dot product\n* @param {Float32Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float32Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {number} dot product\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Create a new routine:\n* var sdsdot = new Routine();\n*\n* // Initialize the module:\n* sdsdot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*/\nsetReadOnly( Routine.prototype, 'ndarray', function sdsdot( N, scalar, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar ptrs;\n\tvar p0;\n\tvar p1;\n\n\t// Convert the input arrays to \"pointers\" in the module's memory:\n\tptrs = arrays2ptrs( this, [\n\t\tstrided2object( N, x, strideX, offsetX ),\n\t\tstrided2object( N, y, strideY, offsetY )\n\t]);\n\tp0 = ptrs[ 0 ];\n\tp1 = ptrs[ 1 ];\n\n\t// Perform computation by calling the corresponding parent method:\n\treturn Module.prototype.ndarray.call( this, N, scalar, p0.ptr, p0.stride, p0.offset, p1.ptr, p1.stride, p1.offset ); // eslint-disable-line max-len\n});\n\n\n// EXPORTS //\n\nmodule.exports = Routine;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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 setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar Routine = require( './routine.js' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* WebAssembly module to compute the dot product of two single-precision floating-point vectors with extended accumulation.\n*\n* @name sdsdot\n* @type {Routine}\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*/\nvar sdsdot = new Routine();\nsdsdot.initializeSync(); // eslint-disable-line node/no-sync\nsetReadOnly( sdsdot, 'Module', Module.bind( null ) );\n\n\n// EXPORTS //\n\nmodule.exports = sdsdot;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* WebAssembly routine to compute the dot product of two single-precision floating-point vectors with extended accumulation.\n*\n* @module @stdlib/blas-base-wasm-sdsdot\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );\n*\n* // Define strided arrays:\n* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var mod = new sdsdot.Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* mod.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float32';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* mod.write( xptr, oneTo( N, dtype ) );\n* mod.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var dot = mod.main( N, 0.0, xptr, 1, yptr, 1 );\n*\n* console.log( dot );\n* // returns 15.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"Module\": \"main.Module\" }\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,MAAO,EAAE,QAC5BC,EAAW,QAAS,sBAAuB,EAAE,KAK7CC,EAAOD,EAAUD,EAAS,UAAW,KAAM,MAAO,WAAY,CAAE,EAKpED,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAsB,QAAS,+BAAgC,EAC/DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,QAAS,uBAAwB,EAC5CC,EAAa,QAAS,6BAA8B,EACpDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAa,IAmDjB,SAASC,EAAQC,EAAS,CACzB,GAAK,EAAG,gBAAgBD,GACvB,OAAO,IAAIA,EAAQC,CAAO,EAE3B,GAAK,CAACP,EAAqBO,CAAO,EACjC,MAAM,IAAI,UAAWH,EAAQ,6EAA8EG,CAAO,CAAE,EAGrH,OAAAJ,EAAW,KAAM,KAAME,EAAYE,EAAQ,CAC1C,IAAO,CACN,OAAUA,CACX,CACD,CAAC,EAEM,IACR,CAGAL,EAAUI,EAAQH,CAAW,EAuD7BF,EAAaK,EAAO,UAAW,OAAQ,SAAiBE,EAAGC,EAAQC,EAAMC,EAASC,EAAMC,EAAU,CACjG,OAAO,KAAK,UAAU,QAAQ,SAAUL,EAAGC,EAAQC,EAAMC,EAASC,EAAMC,CAAQ,CACjF,CAAC,EAyDDZ,EAAaK,EAAO,UAAW,UAAW,SAAiBE,EAAGC,EAAQC,EAAMC,EAASG,EAASF,EAAMC,EAASE,EAAU,CACtH,OAAO,KAAK,UAAU,QAAQ,iBAAkBP,EAAGC,EAAQC,EAAMC,EAASG,EAASF,EAAMC,EAASE,CAAQ,CAC3G,CAAC,EAKDhB,EAAO,QAAUO,IC3NjB,IAAAU,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,QAAS,uBAAwB,EAC5CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAS,QAAS,qBAAsB,EACxCC,EAAc,QAAS,+BAAgC,EACvDC,EAAiB,QAAS,kCAAmC,EAC7DC,EAAS,IA8Cb,SAASC,GAAU,CAClB,OAAQ,gBAAgBA,GAGxBD,EAAO,KAAM,KAAM,IAAIH,EAAO,CAC7B,QAAW,CACZ,CAAC,CAAC,EACK,MALC,IAAII,CAMb,CAGAN,EAAUM,EAASD,CAAO,EAkC1BN,EAAaO,EAAQ,UAAW,OAAQ,SAAiBC,EAAGC,EAAQC,EAAGC,EAASC,EAAGC,EAAU,CAC5F,OAAO,KAAK,QAASL,EAAGC,EAAQC,EAAGC,EAAST,EAAeM,EAAGG,CAAQ,EAAGC,EAAGC,EAASX,EAAeM,EAAGK,CAAQ,CAAE,CAClH,CAAC,EAoCDb,EAAaO,EAAQ,UAAW,UAAW,SAAiBC,EAAGC,EAAQC,EAAGC,EAASG,EAASF,EAAGC,EAASE,EAAU,CACjH,IAAIC,EACAC,EACAC,EAGJ,OAAAF,EAAOZ,EAAa,KAAM,CACzBC,EAAgBG,EAAGE,EAAGC,EAASG,CAAQ,EACvCT,EAAgBG,EAAGI,EAAGC,EAASE,CAAQ,CACxC,CAAC,EACDE,EAAKD,EAAM,CAAE,EACbE,EAAKF,EAAM,CAAE,EAGNV,EAAO,UAAU,QAAQ,KAAM,KAAME,EAAGC,EAAQQ,EAAG,IAAKA,EAAG,OAAQA,EAAG,OAAQC,EAAG,IAAKA,EAAG,OAAQA,EAAG,MAAO,CACnH,CAAC,EAKDnB,EAAO,QAAUQ,ICnLjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAU,IACVC,EAAS,IAiCTC,EAAS,IAAIF,EACjBE,EAAO,eAAe,EACtBH,EAAaG,EAAQ,SAAUD,EAAO,KAAM,IAAK,CAAE,EAKnDH,EAAO,QAAUI,IC6BjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_binary", "__commonJSMin", "exports", "module", "resolve", "readWASM", "wasm", "require_module", "__commonJSMin", "exports", "module", "isWebAssemblyMemory", "setReadOnly", "inherits", "WasmModule", "format", "wasmBinary", "Module", "memory", "N", "scalar", "xptr", "strideX", "yptr", "strideY", "offsetX", "offsetY", "require_routine", "__commonJSMin", "exports", "module", "setReadOnly", "inherits", "stride2offset", "Memory", "arrays2ptrs", "strided2object", "Module", "Routine", "N", "scalar", "x", "strideX", "y", "strideY", "offsetX", "offsetY", "ptrs", "p0", "p1", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "Routine", "Module", "sdsdot", "main"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/// <reference types="@stdlib/types"/>
|
|
22
|
+
|
|
23
|
+
import { ModuleWrapper, Memory } from '@stdlib/types/wasm';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Interface defining a module constructor which is both "newable" and "callable".
|
|
27
|
+
*/
|
|
28
|
+
interface ModuleConstructor {
|
|
29
|
+
/**
|
|
30
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
31
|
+
*
|
|
32
|
+
* @param mem - WebAssembly memory instance
|
|
33
|
+
* @returns module wrapper instance
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
37
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
38
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
39
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
40
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
41
|
+
*
|
|
42
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
43
|
+
* var mem = new Memory({
|
|
44
|
+
* 'initial': 10,
|
|
45
|
+
* 'maximum': 100
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Create a BLAS routine:
|
|
49
|
+
* var mod = new sdsdot.Module( mem );
|
|
50
|
+
* // returns <Module>
|
|
51
|
+
*
|
|
52
|
+
* // Initialize the routine:
|
|
53
|
+
* mod.initializeSync();
|
|
54
|
+
*
|
|
55
|
+
* // Define a vector data type:
|
|
56
|
+
* var dtype = 'float32';
|
|
57
|
+
*
|
|
58
|
+
* // Specify a vector length:
|
|
59
|
+
* var N = 5;
|
|
60
|
+
*
|
|
61
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
62
|
+
* var xptr = 0;
|
|
63
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
64
|
+
*
|
|
65
|
+
* // Write vector values to module memory:
|
|
66
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
67
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
68
|
+
*
|
|
69
|
+
* // Perform computation:
|
|
70
|
+
* var dot = mod.main( N, 0.0, xptr, 1, yptr, 1 );
|
|
71
|
+
* // returns 15.0
|
|
72
|
+
*/
|
|
73
|
+
new( mem: Memory ): Module; // newable
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
77
|
+
*
|
|
78
|
+
* @param mem - WebAssembly memory instance
|
|
79
|
+
* @returns module wrapper instance
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
83
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
84
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
85
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
86
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
87
|
+
*
|
|
88
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
89
|
+
* var mem = new Memory({
|
|
90
|
+
* 'initial': 10,
|
|
91
|
+
* 'maximum': 100
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Create a BLAS routine:
|
|
95
|
+
* var mod = sdsdot.Module( mem );
|
|
96
|
+
* // returns <Module>
|
|
97
|
+
*
|
|
98
|
+
* // Initialize the routine:
|
|
99
|
+
* mod.initializeSync();
|
|
100
|
+
*
|
|
101
|
+
* // Define a vector data type:
|
|
102
|
+
* var dtype = 'float32';
|
|
103
|
+
*
|
|
104
|
+
* // Specify a vector length:
|
|
105
|
+
* var N = 5;
|
|
106
|
+
*
|
|
107
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
108
|
+
* var xptr = 0;
|
|
109
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
110
|
+
*
|
|
111
|
+
* // Write vector values to module memory:
|
|
112
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
113
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
114
|
+
*
|
|
115
|
+
* // Perform computation:
|
|
116
|
+
* var dot = mod.main( N, 0.0, xptr, 1, yptr, 1 );
|
|
117
|
+
* // returns 15.0
|
|
118
|
+
*/
|
|
119
|
+
( mem: Memory ): Module; // callable
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Interface describing a `sdsdot` WebAssembly module.
|
|
124
|
+
*/
|
|
125
|
+
interface Module extends ModuleWrapper {
|
|
126
|
+
/**
|
|
127
|
+
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
|
|
128
|
+
*
|
|
129
|
+
* @param N - number of indexed elements
|
|
130
|
+
* @param scalar - scalar constant to add to dot product
|
|
131
|
+
* @param xptr - first input array pointer (i.e., byte offset)
|
|
132
|
+
* @param strideX - `x` stride length
|
|
133
|
+
* @param yptr - second input array pointer (i.e., byte offset)
|
|
134
|
+
* @param strideY - `y` stride length
|
|
135
|
+
* @returns dot product
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
139
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
140
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
141
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
142
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
143
|
+
*
|
|
144
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
145
|
+
* var mem = new Memory({
|
|
146
|
+
* 'initial': 10,
|
|
147
|
+
* 'maximum': 100
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* // Create a BLAS routine:
|
|
151
|
+
* var mod = new sdsdot.Module( mem );
|
|
152
|
+
* // returns <Module>
|
|
153
|
+
*
|
|
154
|
+
* // Initialize the routine:
|
|
155
|
+
* mod.initializeSync();
|
|
156
|
+
*
|
|
157
|
+
* // Define a vector data type:
|
|
158
|
+
* var dtype = 'float32';
|
|
159
|
+
*
|
|
160
|
+
* // Specify a vector length:
|
|
161
|
+
* var N = 5;
|
|
162
|
+
*
|
|
163
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
164
|
+
* var xptr = 0;
|
|
165
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
166
|
+
*
|
|
167
|
+
* // Write vector values to module memory:
|
|
168
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
169
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
170
|
+
*
|
|
171
|
+
* // Perform computation:
|
|
172
|
+
* var dot = mod.main( N, 5.0, xptr, 1, yptr, 1 );
|
|
173
|
+
* // returns 15.0
|
|
174
|
+
*/
|
|
175
|
+
main( N: number, scalar: number, xptr: number, strideX: number, yptr: number, strideY: number ): number;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
|
|
179
|
+
*
|
|
180
|
+
* @param N - number of indexed elements
|
|
181
|
+
* @param scalar - scalar constant to add to dot product
|
|
182
|
+
* @param xptr - first input array pointer (i.e., byte offset)
|
|
183
|
+
* @param strideX - `x` stride length
|
|
184
|
+
* @param offsetX - starting index for `x`
|
|
185
|
+
* @param yptr - second input array pointer (i.e., byte offset)
|
|
186
|
+
* @param strideY - `y` stride length
|
|
187
|
+
* @param offsetY - starting index for `y`
|
|
188
|
+
* @returns dot product
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
192
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
193
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
194
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
195
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
196
|
+
*
|
|
197
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
198
|
+
* var mem = new Memory({
|
|
199
|
+
* 'initial': 10,
|
|
200
|
+
* 'maximum': 100
|
|
201
|
+
* });
|
|
202
|
+
*
|
|
203
|
+
* // Create a BLAS routine:
|
|
204
|
+
* var mod = new sdsdot.Module( mem );
|
|
205
|
+
* // returns <Module>
|
|
206
|
+
*
|
|
207
|
+
* // Initialize the routine:
|
|
208
|
+
* mod.initializeSync();
|
|
209
|
+
*
|
|
210
|
+
* // Define a vector data type:
|
|
211
|
+
* var dtype = 'float32';
|
|
212
|
+
*
|
|
213
|
+
* // Specify a vector length:
|
|
214
|
+
* var N = 5;
|
|
215
|
+
*
|
|
216
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
217
|
+
* var xptr = 0;
|
|
218
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
219
|
+
*
|
|
220
|
+
* // Write vector values to module memory:
|
|
221
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
222
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
223
|
+
*
|
|
224
|
+
* // Perform computation:
|
|
225
|
+
* var dot = mod.ndarray( N, 5.0, xptr, 1, 0, yptr, 1, 0 );
|
|
226
|
+
* // returns 15.0
|
|
227
|
+
*/
|
|
228
|
+
ndarray( N: number, scalar: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number ): number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Interface describing `sdsdot`.
|
|
233
|
+
*/
|
|
234
|
+
interface Routine extends ModuleWrapper {
|
|
235
|
+
/**
|
|
236
|
+
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
|
|
237
|
+
*
|
|
238
|
+
* @param N - number of indexed elements
|
|
239
|
+
* @param scalar - scalar constant to add to dot product
|
|
240
|
+
* @param x - first input array
|
|
241
|
+
* @param strideX - `x` stride length
|
|
242
|
+
* @param y - second input array
|
|
243
|
+
* @param strideY - `y` stride length
|
|
244
|
+
* @returns dot product
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
248
|
+
*
|
|
249
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
250
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
251
|
+
*
|
|
252
|
+
* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );
|
|
253
|
+
* // returns 15.0
|
|
254
|
+
*/
|
|
255
|
+
main( N: number, scalar: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number ): number;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
|
|
259
|
+
*
|
|
260
|
+
* @param N - number of indexed elements
|
|
261
|
+
* @param scalar - scalar constant to add to dot product
|
|
262
|
+
* @param x - first input array
|
|
263
|
+
* @param strideX - `x` stride length
|
|
264
|
+
* @param offsetX - starting index for `x`
|
|
265
|
+
* @param y - second input array
|
|
266
|
+
* @param strideY - `y` stride length
|
|
267
|
+
* @param offsetY - starting index for `y`
|
|
268
|
+
* @returns dot product
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
272
|
+
*
|
|
273
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
274
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
275
|
+
*
|
|
276
|
+
* sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );
|
|
277
|
+
* // returns 15.0
|
|
278
|
+
*/
|
|
279
|
+
ndarray( N: number, scalar: number, x: Float32Array, strideX: number, offsetX: number, y: Float32Array, strideY: number, offsetY: number ): number;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
283
|
+
*
|
|
284
|
+
* @param mem - WebAssembly memory instance
|
|
285
|
+
* @returns module wrapper instance
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
289
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
290
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
291
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
292
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
293
|
+
*
|
|
294
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
295
|
+
* var mem = new Memory({
|
|
296
|
+
* 'initial': 10,
|
|
297
|
+
* 'maximum': 100
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Create a BLAS routine:
|
|
301
|
+
* var mod = new sdsdot.Module( mem );
|
|
302
|
+
* // returns <Module>
|
|
303
|
+
*
|
|
304
|
+
* // Initialize the routine:
|
|
305
|
+
* mod.initializeSync();
|
|
306
|
+
*
|
|
307
|
+
* // Define a vector data type:
|
|
308
|
+
* var dtype = 'float32';
|
|
309
|
+
*
|
|
310
|
+
* // Specify a vector length:
|
|
311
|
+
* var N = 5;
|
|
312
|
+
*
|
|
313
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
314
|
+
* var xptr = 0;
|
|
315
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
316
|
+
*
|
|
317
|
+
* // Write vector values to module memory:
|
|
318
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
319
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
320
|
+
*
|
|
321
|
+
* // Perform computation:
|
|
322
|
+
* var dot = mod.main( N, 0.0, xptr, 1, yptr, 1 );
|
|
323
|
+
* // returns 15.0
|
|
324
|
+
*/
|
|
325
|
+
Module: ModuleConstructor;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
|
|
330
|
+
*
|
|
331
|
+
* @param N - number of indexed elements
|
|
332
|
+
* @param scalar - scalar constant to add to dot product
|
|
333
|
+
* @param x - first input array
|
|
334
|
+
* @param strideX - `x` stride length
|
|
335
|
+
* @param y - second input array
|
|
336
|
+
* @param strideY - `y` stride length
|
|
337
|
+
* @returns dot product
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
341
|
+
*
|
|
342
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
343
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
344
|
+
*
|
|
345
|
+
* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );
|
|
346
|
+
* // returns 15.0
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
350
|
+
*
|
|
351
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
352
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
353
|
+
*
|
|
354
|
+
* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );
|
|
355
|
+
* // returns 15.0
|
|
356
|
+
*/
|
|
357
|
+
declare var sdsdot: Routine;
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
// EXPORTS //
|
|
361
|
+
|
|
362
|
+
export = sdsdot;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var base64ToUint8Array = require( '@stdlib/string-base-base64-to-uint8array' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEaA2AAAGAGf31/f39/AX1gCH99f39/f39/AX0CDwEDZW52Bm1lbW9yeQIAAAMEAwABAgczAxFfX3dhc21fY2FsbF9jdG9ycwAACGNfc2RzZG90AAEQY19zZHNkb3RfbmRhcnJheQACCvICAwMAAQsvACAAIAEgAiADQQEgAGsiACADbEEAIANBAEwbIAQgBSAAIAVsQQAgBUEATBsQAgu7AgIBfwF8IABBAEoEfSABuyEJAkAgA0EBRyAGQQFHckUEQAJAIABBBXAiBkUNAANAIAYgCEYNASACIARBAnRqKgIAuyAFIAdBAnRqKgIAu6IgCaAhCSAIQQFqIQggB0EBaiEHIARBAWohBAwACwALIABBBEwNAQNAIAAgBkwNAiAJIAIgBEECdGoiAyoCELsgBSAHQQJ0aiIIKgIQu6IgAyoCDLsgCCoCDLuiIAMqAgi7IAgqAgi7oiADKgIAuyAIKgIAu6IgAyoCBLsgCCoCBLuioKCgoKAhCSAGQQVqIQYgB0EFaiEHIARBBWohBAwACwALA0AgACAIRg0BIAIgBEECdGoqAgC7IAUgB0ECdGoqAgC7oiAJoCEJIAhBAWohCCAGIAdqIQcgAyAEaiEEDAALAAsgCbYFIAELCw==' );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// EXPORTS //
|
|
32
|
+
|
|
33
|
+
module.exports = wasm;
|
package/lib/binary.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var resolve = require( 'path' ).resolve;
|
|
24
|
+
var readWASM = require( '@stdlib/fs-read-wasm' ).sync;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// MAIN //
|
|
28
|
+
|
|
29
|
+
var wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// EXPORTS //
|
|
33
|
+
|
|
34
|
+
module.exports = wasm;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
/**
|
|
22
|
+
* WebAssembly routine to compute the dot product of two single-precision floating-point vectors with extended accumulation.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/blas-base-wasm-sdsdot
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
28
|
+
* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );
|
|
29
|
+
*
|
|
30
|
+
* // Define strided arrays:
|
|
31
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
32
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
33
|
+
*
|
|
34
|
+
* // Perform operation:
|
|
35
|
+
* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );
|
|
36
|
+
* // returns 15.0
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
+
* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );
|
|
41
|
+
*
|
|
42
|
+
* // Define strided arrays:
|
|
43
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
44
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
45
|
+
*
|
|
46
|
+
* // Perform operation:
|
|
47
|
+
* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );
|
|
48
|
+
* // returns 15.0
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
52
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
53
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
54
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
55
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
56
|
+
* var sdsdot = require( '@stdlib/blas-base-wasm-sdsdot' );
|
|
57
|
+
*
|
|
58
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
59
|
+
* var mem = new Memory({
|
|
60
|
+
* 'initial': 10,
|
|
61
|
+
* 'maximum': 100
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Create a BLAS routine:
|
|
65
|
+
* var mod = new sdsdot.Module( mem );
|
|
66
|
+
* // returns <Module>
|
|
67
|
+
*
|
|
68
|
+
* // Initialize the routine:
|
|
69
|
+
* mod.initializeSync();
|
|
70
|
+
*
|
|
71
|
+
* // Define a vector data type:
|
|
72
|
+
* var dtype = 'float32';
|
|
73
|
+
*
|
|
74
|
+
* // Specify a vector length:
|
|
75
|
+
* var N = 5;
|
|
76
|
+
*
|
|
77
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
78
|
+
* var xptr = 0;
|
|
79
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
80
|
+
*
|
|
81
|
+
* // Write vector values to module memory:
|
|
82
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
83
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
84
|
+
*
|
|
85
|
+
* // Perform computation:
|
|
86
|
+
* var dot = mod.main( N, 0.0, xptr, 1, yptr, 1 );
|
|
87
|
+
*
|
|
88
|
+
* console.log( dot );
|
|
89
|
+
* // returns 15.0
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
// MODULES //
|
|
93
|
+
|
|
94
|
+
var main = require( './main.js' );
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// EXPORTS //
|
|
98
|
+
|
|
99
|
+
module.exports = main;
|
|
100
|
+
|
|
101
|
+
// exports: { "Module": "main.Module" }
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
|
+
var Routine = require( './routine.js' );
|
|
25
|
+
var Module = require( './module.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* WebAssembly module to compute the dot product of two single-precision floating-point vectors with extended accumulation.
|
|
32
|
+
*
|
|
33
|
+
* @name sdsdot
|
|
34
|
+
* @type {Routine}
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
38
|
+
*
|
|
39
|
+
* // Define strided arrays:
|
|
40
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
41
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
42
|
+
*
|
|
43
|
+
* // Perform operation:
|
|
44
|
+
* var dot = sdsdot.main( x.length, 0.0, x, 1, y, 1 );
|
|
45
|
+
* // returns 15.0
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
49
|
+
*
|
|
50
|
+
* // Define strided arrays:
|
|
51
|
+
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
52
|
+
* var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
53
|
+
*
|
|
54
|
+
* // Perform operation:
|
|
55
|
+
* var dot = sdsdot.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );
|
|
56
|
+
* // returns 15.0
|
|
57
|
+
*/
|
|
58
|
+
var sdsdot = new Routine();
|
|
59
|
+
sdsdot.initializeSync(); // eslint-disable-line node/no-sync
|
|
60
|
+
setReadOnly( sdsdot, 'Module', Module.bind( null ) );
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// EXPORTS //
|
|
64
|
+
|
|
65
|
+
module.exports = sdsdot;
|