@stdlib/blas-base-wasm-ddot 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 +415 -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 +357 -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 +218 -0
- package/lib/routine.js +178 -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 +220 -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) 2024 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) 2024 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 ddot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* ddot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\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* ddot.write( xptr, oneTo( N, dtype ) );\n* ddot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var dot = ddot.main( N, 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 `x` and `y`.\n*\n* @name main\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\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 ddot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* ddot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\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* ddot.write( xptr, oneTo( N, dtype ) );\n* ddot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var dot = ddot.main( N, xptr, 1, yptr, 1 );\n* // returns 15.0\n*/\nsetReadOnly( Module.prototype, 'main', function ddot( N, xptr, strideX, yptr, strideY ) {\n\treturn this._instance.exports.c_ddot( N, xptr, strideX, yptr, strideY );\n});\n\n/**\n* Computes the dot product of `x` and `y` 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 {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 ddot = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* ddot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\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* ddot.write( xptr, oneTo( N, dtype ) );\n* ddot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ddot = ddot.ndarray( N, xptr, 1, 0, yptr, 1, 0 );\n* // returns 15.0\n*/\nsetReadOnly( Module.prototype, 'ndarray', function ddot( N, xptr, strideX, offsetX, yptr, strideY, offsetY ) {\n\treturn this._instance.exports.c_ddot_ndarray( N, 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) 2024 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 Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var ddot = new Routine();\n*\n* // Initialize the module:\n* ddot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.main( x.length, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var ddot = new Routine();\n*\n* // Initialize the module:\n* ddot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.ndarray( x.length, 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 `x` and `y`.\n*\n* @name main\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @returns {number} dot product\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var ddot = new Routine();\n*\n* // Initialize the module:\n* ddot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.main( x.length, x, 1, y, 1 );\n* // returns 15.0\n*/\nsetReadOnly( Routine.prototype, 'main', function ddot( N, x, strideX, y, strideY ) {\n\treturn this.ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len\n});\n\n/**\n* Computes the dot product of `x` and `y` 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 {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float64Array} 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 Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var ddot = new Routine();\n*\n* // Initialize the module:\n* ddot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*/\nsetReadOnly( Routine.prototype, 'ndarray', function ddot( N, 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, 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) 2024 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 `x` and `y`.\n*\n* @name ddot\n* @type {Routine}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.main( x.length, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // returns 15.0\n*/\nvar ddot = new Routine();\nddot.initializeSync(); // eslint-disable-line node/no-sync\nsetReadOnly( ddot, 'Module', Module.bind( null ) );\n\n\n// EXPORTS //\n\nmodule.exports = ddot;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 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 `x` and `y`.\n*\n* @module @stdlib/blas-base-wasm-ddot\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ddot = require( '@stdlib/blas-base-wasm-ddot' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.main( x.length, x, 1, y, 1 );\n* // returns 15.0\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ddot = require( '@stdlib/blas-base-wasm-ddot' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* var dot = ddot.ndarray( x.length, 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 ddot = require( '@stdlib/blas-base-wasm-ddot' );\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 ddot.Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* mod.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\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, 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": "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",
|
|
6
|
+
"names": ["require_binary", "__commonJSMin", "exports", "module", "resolve", "readWASM", "wasm", "require_module", "__commonJSMin", "exports", "module", "isWebAssemblyMemory", "setReadOnly", "inherits", "WasmModule", "format", "wasmBinary", "Module", "memory", "N", "xptr", "strideX", "yptr", "strideY", "offsetX", "offsetY", "require_routine", "__commonJSMin", "exports", "module", "setReadOnly", "inherits", "stride2offset", "Memory", "arrays2ptrs", "strided2object", "Module", "Routine", "N", "x", "strideX", "y", "strideY", "offsetX", "offsetY", "ptrs", "p0", "p1", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "Routine", "Module", "ddot", "main"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 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 ddot.Module( mem );
|
|
50
|
+
* // returns <Module>
|
|
51
|
+
*
|
|
52
|
+
* // Initialize the routine:
|
|
53
|
+
* mod.initializeSync();
|
|
54
|
+
*
|
|
55
|
+
* // Define a vector data type:
|
|
56
|
+
* var dtype = 'float64';
|
|
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, 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 = ddot.Module( mem );
|
|
96
|
+
* // returns <Module>
|
|
97
|
+
*
|
|
98
|
+
* // Initialize the routine:
|
|
99
|
+
* mod.initializeSync();
|
|
100
|
+
*
|
|
101
|
+
* // Define a vector data type:
|
|
102
|
+
* var dtype = 'float64';
|
|
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, xptr, 1, yptr, 1 );
|
|
117
|
+
* // returns 15.0
|
|
118
|
+
*/
|
|
119
|
+
( mem: Memory ): Module; // callable
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Interface describing a `ddot` WebAssembly module.
|
|
124
|
+
*/
|
|
125
|
+
interface Module extends ModuleWrapper {
|
|
126
|
+
/**
|
|
127
|
+
* Computes the dot product of `x` and `y`.
|
|
128
|
+
*
|
|
129
|
+
* @param N - number of indexed elements
|
|
130
|
+
* @param xptr - first input array pointer (i.e., byte offset)
|
|
131
|
+
* @param strideX - `x` stride length
|
|
132
|
+
* @param yptr - second input array pointer (i.e., byte offset)
|
|
133
|
+
* @param strideY - `y` stride length
|
|
134
|
+
* @returns dot product
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
138
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
139
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
140
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
141
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
142
|
+
*
|
|
143
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
144
|
+
* var mem = new Memory({
|
|
145
|
+
* 'initial': 10,
|
|
146
|
+
* 'maximum': 100
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Create a BLAS routine:
|
|
150
|
+
* var mod = new ddot.Module( mem );
|
|
151
|
+
* // returns <Module>
|
|
152
|
+
*
|
|
153
|
+
* // Initialize the routine:
|
|
154
|
+
* mod.initializeSync();
|
|
155
|
+
*
|
|
156
|
+
* // Define a vector data type:
|
|
157
|
+
* var dtype = 'float64';
|
|
158
|
+
*
|
|
159
|
+
* // Specify a vector length:
|
|
160
|
+
* var N = 5;
|
|
161
|
+
*
|
|
162
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
163
|
+
* var xptr = 0;
|
|
164
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
165
|
+
*
|
|
166
|
+
* // Write vector values to module memory:
|
|
167
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
168
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
169
|
+
*
|
|
170
|
+
* // Perform computation:
|
|
171
|
+
* var dot = mod.main( N, xptr, 1, yptr, 1 );
|
|
172
|
+
* // returns 15.0
|
|
173
|
+
*/
|
|
174
|
+
main( N: number, xptr: number, strideX: number, yptr: number, strideY: number ): number;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Computes the dot product of `x` and `y` using alternative indexing semantics.
|
|
178
|
+
*
|
|
179
|
+
* @param N - number of indexed elements
|
|
180
|
+
* @param xptr - first input array pointer (i.e., byte offset)
|
|
181
|
+
* @param strideX - `x` stride length
|
|
182
|
+
* @param offsetX - starting index for `x`
|
|
183
|
+
* @param yptr - second input array pointer (i.e., byte offset)
|
|
184
|
+
* @param strideY - `y` stride length
|
|
185
|
+
* @param offsetY - starting index for `y`
|
|
186
|
+
* @returns dot product
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
190
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
191
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
192
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
193
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
194
|
+
*
|
|
195
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
196
|
+
* var mem = new Memory({
|
|
197
|
+
* 'initial': 10,
|
|
198
|
+
* 'maximum': 100
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* // Create a BLAS routine:
|
|
202
|
+
* var mod = new ddot.Module( mem );
|
|
203
|
+
* // returns <Module>
|
|
204
|
+
*
|
|
205
|
+
* // Initialize the routine:
|
|
206
|
+
* mod.initializeSync();
|
|
207
|
+
*
|
|
208
|
+
* // Define a vector data type:
|
|
209
|
+
* var dtype = 'float64';
|
|
210
|
+
*
|
|
211
|
+
* // Specify a vector length:
|
|
212
|
+
* var N = 5;
|
|
213
|
+
*
|
|
214
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
215
|
+
* var xptr = 0;
|
|
216
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
217
|
+
*
|
|
218
|
+
* // Write vector values to module memory:
|
|
219
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
220
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
221
|
+
*
|
|
222
|
+
* // Perform computation:
|
|
223
|
+
* var dot = mod.ndarray( N, xptr, 1, 0, yptr, 1, 0 );
|
|
224
|
+
* // returns 15.0
|
|
225
|
+
*/
|
|
226
|
+
ndarray( N: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number ): number;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Interface describing `ddot`.
|
|
231
|
+
*/
|
|
232
|
+
interface Routine extends ModuleWrapper {
|
|
233
|
+
/**
|
|
234
|
+
* Computes the dot product of `x` and `y`.
|
|
235
|
+
*
|
|
236
|
+
* @param N - number of indexed elements
|
|
237
|
+
* @param x - first input array
|
|
238
|
+
* @param strideX - `x` stride length
|
|
239
|
+
* @param y - second input array
|
|
240
|
+
* @param strideY - `y` stride length
|
|
241
|
+
* @returns dot product
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
245
|
+
*
|
|
246
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
247
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
248
|
+
*
|
|
249
|
+
* var dot = ddot.main( x.length, x, 1, y, 1 );
|
|
250
|
+
* // returns 15.0
|
|
251
|
+
*/
|
|
252
|
+
main( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number ): number;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Computes the dot product of `x` and `y` using alternative indexing semantics.
|
|
256
|
+
*
|
|
257
|
+
* @param N - number of indexed elements
|
|
258
|
+
* @param x - first input array
|
|
259
|
+
* @param strideX - `x` stride length
|
|
260
|
+
* @param offsetX - starting index for `x`
|
|
261
|
+
* @param y - second input array
|
|
262
|
+
* @param strideY - `y` stride length
|
|
263
|
+
* @param offsetY - starting index for `y`
|
|
264
|
+
* @returns dot product
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
268
|
+
*
|
|
269
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
270
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
271
|
+
*
|
|
272
|
+
* var dot = ddot.ndarray( x.length, x, 1, 0, y, 1, 0 );
|
|
273
|
+
* // returns 15.0
|
|
274
|
+
*/
|
|
275
|
+
ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number ): number;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
279
|
+
*
|
|
280
|
+
* @param mem - WebAssembly memory instance
|
|
281
|
+
* @returns module wrapper instance
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
285
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
286
|
+
* var ones = require( '@stdlib/array-ones' );
|
|
287
|
+
* var zeros = require( '@stdlib/array-zeros' );
|
|
288
|
+
* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
|
|
289
|
+
*
|
|
290
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
291
|
+
* var mem = new Memory({
|
|
292
|
+
* 'initial': 10,
|
|
293
|
+
* 'maximum': 100
|
|
294
|
+
* });
|
|
295
|
+
*
|
|
296
|
+
* // Create a BLAS routine:
|
|
297
|
+
* var mod = new ddot.Module( mem );
|
|
298
|
+
* // returns <Module>
|
|
299
|
+
*
|
|
300
|
+
* // Initialize the routine:
|
|
301
|
+
* mod.initializeSync();
|
|
302
|
+
*
|
|
303
|
+
* // Define a vector data type:
|
|
304
|
+
* var dtype = 'float64';
|
|
305
|
+
*
|
|
306
|
+
* // Specify a vector length:
|
|
307
|
+
* var N = 5;
|
|
308
|
+
*
|
|
309
|
+
* // Define pointers (i.e., byte offsets) for storing two vectors:
|
|
310
|
+
* var xptr = 0;
|
|
311
|
+
* var yptr = N * bytesPerElement( dtype );
|
|
312
|
+
*
|
|
313
|
+
* // Write vector values to module memory:
|
|
314
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
315
|
+
* mod.write( yptr, ones( N, dtype ) );
|
|
316
|
+
*
|
|
317
|
+
* // Perform computation:
|
|
318
|
+
* var dot = mod.main( N, xptr, 1, yptr, 1 );
|
|
319
|
+
* // returns 15.0
|
|
320
|
+
*/
|
|
321
|
+
Module: ModuleConstructor;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Computes the dot product of `x` and `y`.
|
|
326
|
+
*
|
|
327
|
+
* @param N - number of indexed elements
|
|
328
|
+
* @param x - first input array
|
|
329
|
+
* @param strideX - `x` stride length
|
|
330
|
+
* @param y - second input array
|
|
331
|
+
* @param strideY - `y` stride length
|
|
332
|
+
* @returns dot product
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
336
|
+
*
|
|
337
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
338
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
339
|
+
*
|
|
340
|
+
* var dot = ddot.main( x.length, x, 1, y, 1 );
|
|
341
|
+
* // returns 15.0
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
345
|
+
*
|
|
346
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
347
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
348
|
+
*
|
|
349
|
+
* var dot = ddot.ndarray( x.length, x, 1, 0, y, 1, 0 );
|
|
350
|
+
* // returns 15.0
|
|
351
|
+
*/
|
|
352
|
+
declare var ddot: Routine;
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
// EXPORTS //
|
|
356
|
+
|
|
357
|
+
export = ddot;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 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( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEYA2AAAGAFf39/f38BfGAHf39/f39/fwF8Ag8BA2VudgZtZW1vcnkCAAADBAMAAQIHSgQRX193YXNtX2NhbGxfY3RvcnMAABhfX3dhc21fYXBwbHlfZGF0YV9yZWxvY3MAAAZjX2Rkb3QAAQ5jX2Rkb3RfbmRhcnJheQACCtsCAwMAAQstACAAIAEgAkEBIABrIgAgAmxBACACQQBMGyADIAQgACAEbEEAIARBAEwbEAILpgICAX8BfAJAIABBAEwEQAwBCyACQQFHIAVBAUdyRQRAAkAgAEEFcCIFRQ0AA0AgBSAHRg0BIAEgA0EDdGorAwAgBCAGQQN0aisDAKIgCKAhCCAHQQFqIQcgBkEBaiEGIANBAWohAwwACwALIABBBUgNAQNAIAAgBUwNAiAIIAEgA0EDdGoiAisDICAEIAZBA3RqIgcrAyCiIAIrAxggBysDGKIgAisDECAHKwMQoiACKwMAIAcrAwCiIAIrAwggBysDCKKgoKCgoCEIIAVBBWohBSAGQQVqIQYgA0EFaiEDDAALAAsDQCAAIAdGDQEgASADQQN0aisDACAEIAZBA3RqKwMAoiAIoCEIIAdBAWohByAFIAZqIQYgAiADaiEDDAALAAsgCAs=' );
|
|
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) 2024 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) 2024 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 `x` and `y`.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/blas-base-wasm-ddot
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
28
|
+
* var ddot = require( '@stdlib/blas-base-wasm-ddot' );
|
|
29
|
+
*
|
|
30
|
+
* // Define strided arrays:
|
|
31
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
32
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
33
|
+
*
|
|
34
|
+
* // Perform operation:
|
|
35
|
+
* var dot = ddot.main( x.length, x, 1, y, 1 );
|
|
36
|
+
* // returns 15.0
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
40
|
+
* var ddot = require( '@stdlib/blas-base-wasm-ddot' );
|
|
41
|
+
*
|
|
42
|
+
* // Define strided arrays:
|
|
43
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
44
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
45
|
+
*
|
|
46
|
+
* // Perform operation:
|
|
47
|
+
* var dot = ddot.ndarray( x.length, 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 ddot = require( '@stdlib/blas-base-wasm-ddot' );
|
|
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 ddot.Module( mem );
|
|
66
|
+
* // returns <Module>
|
|
67
|
+
*
|
|
68
|
+
* // Initialize the routine:
|
|
69
|
+
* mod.initializeSync();
|
|
70
|
+
*
|
|
71
|
+
* // Define a vector data type:
|
|
72
|
+
* var dtype = 'float64';
|
|
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, 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) 2024 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 `x` and `y`.
|
|
32
|
+
*
|
|
33
|
+
* @name ddot
|
|
34
|
+
* @type {Routine}
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
38
|
+
*
|
|
39
|
+
* // Define strided arrays:
|
|
40
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
41
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
42
|
+
*
|
|
43
|
+
* // Perform operation:
|
|
44
|
+
* var dot = ddot.main( x.length, x, 1, y, 1 );
|
|
45
|
+
* // returns 15.0
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
49
|
+
*
|
|
50
|
+
* // Define strided arrays:
|
|
51
|
+
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
52
|
+
* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
|
|
53
|
+
*
|
|
54
|
+
* // Perform operation:
|
|
55
|
+
* var dot = ddot.ndarray( x.length, x, 1, 0, y, 1, 0 );
|
|
56
|
+
* // returns 15.0
|
|
57
|
+
*/
|
|
58
|
+
var ddot = new Routine();
|
|
59
|
+
ddot.initializeSync(); // eslint-disable-line node/no-sync
|
|
60
|
+
setReadOnly( ddot, 'Module', Module.bind( null ) );
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// EXPORTS //
|
|
64
|
+
|
|
65
|
+
module.exports = ddot;
|