Skip to content

Commit 90baf51

Browse files
feat: added wasm implementation for dapxsum
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 6dbff24 commit 90baf51

File tree

13 files changed

+1096
-1
lines changed

13 files changed

+1096
-1
lines changed

lib/node_modules/@stdlib/blas/ext/base/dapxsum/manifest.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"options": {
3-
"task": "build"
3+
"task": "build",
4+
"wasm": false
45
},
56
"fields": [
67
{
@@ -27,6 +28,7 @@
2728
"confs": [
2829
{
2930
"task": "build",
31+
"wasm": false,
3032
"src": [
3133
"./src/main.c"
3234
],
@@ -48,6 +50,7 @@
4850
},
4951
{
5052
"task": "benchmark",
53+
"wasm": false,
5154
"src": [
5255
"./src/main.c"
5356
],
@@ -64,6 +67,24 @@
6467
},
6568
{
6669
"task": "examples",
70+
"wasm": false,
71+
"src": [
72+
"./src/main.c"
73+
],
74+
"include": [
75+
"./include"
76+
],
77+
"libraries": [],
78+
"libpath": [],
79+
"dependencies": [
80+
"@stdlib/math/base/special/abs",
81+
"@stdlib/blas/base/shared",
82+
"@stdlib/strided/base/stride2offset"
83+
]
84+
},
85+
{
86+
"task": "build",
87+
"wasm": true,
6788
"src": [
6889
"./src/main.c"
6990
],
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEVA2AFf3x/f38BfGAAAGAEf3x/fwF8Ag8BA2VudgZtZW1vcnkCAAADBQQBAgAAB08DEV9fd2FzbV9jYWxsX2N0b3JzAAAWc3RkbGliX3N0cmlkZWRfZGFweHN1bQABHnN0ZGxpYl9zdHJpZGVkX2RhcHhzdW1fbmRhcnJheQADCrgBBAMAAQscACAAIAEgAiADQQEgAGsgA2xBACADQQBMGxACC4UBAgN8AX8gAEEATARARAAAAAAAAAAADwsgAwRAA0AgACAIRkUEQCAFIAEgAiAEQQN0aisDAKAiBSAGIAYgBaAiB6GgIAYgBSAHoaAgBpkgBZlmG6AhBSAIQQFqIQggAyAEaiEEIAchBgwBCwsgBiAFoA8LIAEgAiAEQQN0aisDAKAgALiiCw4AIAAgASACIAMgBBACCw==' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = wasm;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 add a scalar constant to each double-precision floating-point strided array element and compute the sum.
23+
*
24+
* @module @stdlib/blas/ext/base/wasm/dapxsum
25+
*
26+
* @example
27+
* var Float64Array = require( '@stdlib/array/float64' );
28+
* var dapxsum = require( '@stdlib/blas/ext/base/wasm/dapxsum' );
29+
*
30+
* // Define a strided array:
31+
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
32+
*
33+
* // Perform operation:
34+
* var v = dapxsum.main( 3, 5.0, x, 1 );
35+
* // returns 16.0
36+
*
37+
* @example
38+
* var Float64Array = require( '@stdlib/array/float64' );
39+
* var dapxsum = require( '@stdlib/blas/ext/base/wasm/dapxsum' );
40+
*
41+
* // Define a strided array:
42+
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
43+
*
44+
* // Perform operation:
45+
* var v = dapxsum.ndarray( 4, 5.0, x, 2, 1 );
46+
* // returns 25.0
47+
*
48+
* @example
49+
* var Memory = require( '@stdlib/wasm/memory' );
50+
* var oneTo = require( '@stdlib/array/one-to' );
51+
* var zeros = require( '@stdlib/array/zeros' );
52+
* var dapxsum = require( '@stdlib/blas/ext/base/wasm/dapxsum' );
53+
*
54+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
55+
* var mem = new Memory({
56+
* 'initial': 10,
57+
* 'maximum': 100
58+
* });
59+
*
60+
* // Create a BLAS routine:
61+
* var mod = new dapxsum.Module( mem );
62+
* // returns <Module>
63+
*
64+
* // Initialize the routine:
65+
* mod.initializeSync();
66+
*
67+
* // Define a vector data type:
68+
* var dtype = 'float64';
69+
*
70+
* // Specify a vector length:
71+
* var N = 3;
72+
*
73+
* // Define a pointer (i.e., byte offset) for storing the input vector:
74+
* var xptr = 0;
75+
*
76+
* // Write vector values to module memory:
77+
* mod.write( xptr, oneTo( N, dtype ) );
78+
*
79+
* // Perform computation:
80+
* var sum = mod.main( N, 5.0, xptr, 1 );
81+
* // returns 21.0
82+
*/
83+
84+
// MODULES //
85+
86+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
87+
var main = require( './main.js' );
88+
var Module = require( './module.js' );
89+
90+
91+
// MAIN //
92+
93+
setReadOnly( main, 'Module', Module );
94+
95+
96+
// EXPORTS //
97+
98+
module.exports = main;
99+
100+
// exports: { "Module": "main.Module" }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 Routine = require( './routine.js' );
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* WebAssembly routine to add a scalar constant to each double-precision floating-point strided array element and compute the sum.
30+
*
31+
* @name dapxsum
32+
* @type {Routine}
33+
*
34+
* @module @stdlib/blas/ext/base/wasm/dapxsum
35+
*
36+
* @example
37+
* var Float64Array = require( '@stdlib/array/float64' );
38+
*
39+
* // Define a strided array:
40+
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
41+
*
42+
* // Perform operation:
43+
* var v = dapxsum.main( 3, 5.0, x, 1 );
44+
* // returns 16.0
45+
*
46+
* @example
47+
* var Float64Array = require( '@stdlib/array/float64' );
48+
*
49+
* // Define a strided array:
50+
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
51+
*
52+
* // Perform operation:
53+
* var v = dapxsum.ndarray( 4, 5.0, x, 2, 1 );
54+
* // returns 25.0
55+
*/
56+
var dapxsum = new Routine();
57+
dapxsum.initializeSync(); // eslint-disable-line node/no-sync
58+
59+
60+
// EXPORTS //
61+
62+
module.exports = dapxsum;

0 commit comments

Comments
 (0)