wgblas 2.0.0 → 2.2.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/README.md +20 -18
- package/dist/wgblas.browser.js +2172 -1174
- package/index.d.mts +49 -44
- package/index.mjs +11 -0
- package/package.json +133 -63
- package/src/classes/Complex32.d.mts +43 -0
- package/src/classes/Complex32.mjs +82 -0
- package/src/classes/Complex64.d.mts +44 -0
- package/src/classes/Complex64.mjs +76 -0
- package/src/classes/GpuMatrix.d.mts +41 -41
- package/src/classes/GpuMatrix.mjs +126 -17
- package/src/classes/GpuVector.d.mts +36 -40
- package/src/classes/GpuVector.mjs +66 -11
- package/src/cscal/cscal.d.mts +47 -0
- package/src/cscal/cscal.mjs +98 -0
- package/src/dasum/dasum.d.mts +4 -4
- package/src/dasum/dasum.mjs +38 -20
- package/src/daxpy/daxpy.d.mts +56 -0
- package/src/daxpy/daxpy.mjs +150 -0
- package/src/dcopy/dcopy.d.mts +52 -0
- package/src/dcopy/dcopy.mjs +140 -0
- package/src/ddot/ddot.d.mts +62 -0
- package/src/ddot/ddot.mjs +184 -0
- package/src/devdocs.mjs +13 -0
- package/src/dnrm2/dnrm2.d.mts +50 -0
- package/src/dnrm2/dnrm2.mjs +189 -0
- package/src/drot/drot.d.mts +67 -0
- package/src/drot/drot.mjs +170 -0
- package/src/drotm/drotm.d.mts +67 -0
- package/src/drotm/drotm.mjs +171 -0
- package/src/dscal/dscal.d.mts +52 -0
- package/src/dscal/dscal.mjs +119 -0
- package/src/dswap/dswap.d.mts +57 -0
- package/src/dswap/dswap.mjs +155 -0
- package/src/idamax/idamax.d.mts +20 -2
- package/src/idamax/idamax.mjs +56 -24
- package/src/init.mjs +117 -56
- package/src/isamax/isamax.d.mts +20 -2
- package/src/isamax/isamax.mjs +21 -16
- package/src/random/random.d.mts +37 -39
- package/src/random/random.mjs +39 -7
- package/src/sasum/sasum.d.mts +2 -2
- package/src/sasum/sasum.mjs +20 -16
- package/src/saxpy/saxpy.d.mts +2 -2
- package/src/saxpy/saxpy.mjs +14 -11
- package/src/scopy/scopy.d.mts +2 -2
- package/src/scopy/scopy.mjs +13 -9
- package/src/sdot/sdot.d.mts +2 -2
- package/src/sdot/sdot.mjs +21 -17
- package/src/sgemm/sgemm.d.mts +2 -2
- package/src/sgemm/sgemm.mjs +109 -40
- package/src/sgemmtr/sgemmtr.d.mts +3 -2
- package/src/sgemmtr/sgemmtr.mjs +98 -40
- package/src/sgemv/sgemv.d.mts +2 -2
- package/src/sgemv/sgemv.mjs +69 -41
- package/src/sger/sger.d.mts +2 -2
- package/src/sger/sger.mjs +43 -19
- package/src/shaders/__test_pipeline_a.wgsl +3 -0
- package/src/shaders/__test_pipeline_b.wgsl +2 -0
- package/src/shaders/cscal.wgsl +33 -0
- package/src/shaders/daxpy.wgsl +66 -0
- package/src/shaders/dcopy.wgsl +34 -0
- package/src/shaders/ddot.wgsl +106 -0
- package/src/shaders/dnrm2.wgsl +167 -0
- package/src/shaders/drot.wgsl +81 -0
- package/src/shaders/drotm.wgsl +99 -0
- package/src/shaders/dscal.wgsl +60 -0
- package/src/shaders/dswap.wgsl +38 -0
- package/src/shaders/f64/utils/add.wgsl +6 -0
- package/src/shaders/f64/utils/divide.wgsl +45 -0
- package/src/shaders/f64/utils/multiply.wgsl +19 -10
- package/src/shaders/f64/utils/sqrt.wgsl +45 -0
- package/src/shaders/index.mjs +233 -14
- package/src/shaders/reduction/scaledSum.wgsl +65 -0
- package/src/shaders/reduction/scaledSumF64.wgsl +93 -0
- package/src/shaders/sgemm_large.wgsl +107 -18
- package/src/shaders/sgemm_small.wgsl +115 -15
- package/src/shaders/sgemmtr_large.wgsl +4 -1
- package/src/shaders/sgemmtr_small.wgsl +4 -1
- package/src/shaders/sgemv_n.wgsl +3 -1
- package/src/shaders/sgemv_t.wgsl +3 -1
- package/src/shaders/snrm2.wgsl +72 -23
- package/src/shaders/ssymv.wgsl +3 -1
- package/src/snrm2/snrm2.d.mts +2 -2
- package/src/snrm2/snrm2.mjs +41 -23
- package/src/srot/srot.d.mts +2 -4
- package/src/srot/srot.mjs +16 -11
- package/src/srotm/srotm.d.mts +2 -4
- package/src/srotm/srotm.mjs +17 -11
- package/src/sscal/sscal.d.mts +3 -3
- package/src/sscal/sscal.mjs +14 -12
- package/src/sswap/sswap.d.mts +2 -2
- package/src/sswap/sswap.mjs +18 -10
- package/src/ssymm/ssymm.d.mts +5 -4
- package/src/ssymm/ssymm.mjs +150 -54
- package/src/ssymv/ssymv.d.mts +2 -2
- package/src/ssymv/ssymv.mjs +47 -26
- package/src/ssyr/ssyr.d.mts +2 -2
- package/src/ssyr/ssyr.mjs +38 -17
- package/src/ssyr2/ssyr2.d.mts +2 -2
- package/src/ssyr2/ssyr2.mjs +48 -21
- package/src/ssyr2k/ssyr2k.d.mts +3 -2
- package/src/ssyr2k/ssyr2k.mjs +140 -62
- package/src/ssyrk/ssyrk.d.mts +3 -2
- package/src/ssyrk/ssyrk.mjs +91 -39
- package/src/strmm/strmm.d.mts +5 -4
- package/src/strmm/strmm.mjs +174 -60
- package/src/strmv/strmv.d.mts +2 -2
- package/src/strmv/strmv.mjs +42 -20
- package/src/strsm/strsm.d.mts +6 -4
- package/src/strsm/strsm.mjs +438 -174
- package/src/strsv/strsv.d.mts +5 -3
- package/src/strsv/strsv.mjs +89 -34
- package/src/util/benchmark.mjs +9 -9
- package/src/util/bindgroup.mjs +1 -3
- package/src/util/buffer.mjs +139 -24
- package/src/util/complex.mjs +87 -0
- package/src/util/compute.mjs +19 -16
- package/src/util/constants.mjs +57 -0
- package/src/util/device.mjs +49 -0
- package/src/util/pipeline.mjs +44 -10
- package/src/util/workgroup.mjs +72 -7
- package/src/shaders/browser-shaders.mjs +0 -81
- package/src/shaders/f64add.wgsl +0 -281
package/index.d.mts
CHANGED
|
@@ -3,23 +3,34 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { GpuVector } from "./src/classes/GpuVector.mjs";
|
|
5
5
|
export { GpuMatrix } from "./src/classes/GpuMatrix.mjs";
|
|
6
|
+
export { Complex32, Complex32Array } from "./src/classes/Complex32.mjs";
|
|
7
|
+
export { Complex64, Complex64Array } from "./src/classes/Complex64.mjs";
|
|
6
8
|
export {
|
|
7
9
|
randomFloat32Array,
|
|
8
10
|
randomFloat64Array,
|
|
9
11
|
randomTriangularFloat32Array,
|
|
10
12
|
} from "./src/random/random.mjs";
|
|
11
13
|
export { sscal } from "./src/sscal/sscal.mjs";
|
|
14
|
+
export { cscal } from "./src/cscal/cscal.mjs";
|
|
15
|
+
export { dscal } from "./src/dscal/dscal.mjs";
|
|
12
16
|
export { sswap } from "./src/sswap/sswap.mjs";
|
|
17
|
+
export { dswap } from "./src/dswap/dswap.mjs";
|
|
13
18
|
export { saxpy } from "./src/saxpy/saxpy.mjs";
|
|
19
|
+
export { daxpy } from "./src/daxpy/daxpy.mjs";
|
|
14
20
|
export { scopy } from "./src/scopy/scopy.mjs";
|
|
21
|
+
export { dcopy } from "./src/dcopy/dcopy.mjs";
|
|
15
22
|
export { sdot } from "./src/sdot/sdot.mjs";
|
|
16
23
|
export { sasum } from "./src/sasum/sasum.mjs";
|
|
17
24
|
export { dasum } from "./src/dasum/dasum.mjs";
|
|
25
|
+
export { ddot } from "./src/ddot/ddot.mjs";
|
|
18
26
|
export { snrm2 } from "./src/snrm2/snrm2.mjs";
|
|
27
|
+
export { dnrm2 } from "./src/dnrm2/dnrm2.mjs";
|
|
19
28
|
export { isamax } from "./src/isamax/isamax.mjs";
|
|
20
29
|
export { idamax } from "./src/idamax/idamax.mjs";
|
|
21
30
|
export { srot } from "./src/srot/srot.mjs";
|
|
31
|
+
export { drot } from "./src/drot/drot.mjs";
|
|
22
32
|
export { srotm } from "./src/srotm/srotm.mjs";
|
|
33
|
+
export { drotm } from "./src/drotm/drotm.mjs";
|
|
23
34
|
export { sgemv } from "./src/sgemv/sgemv.mjs";
|
|
24
35
|
export { ssymv } from "./src/ssymv/ssymv.mjs";
|
|
25
36
|
export { strmv } from "./src/strmv/strmv.mjs";
|
|
@@ -38,43 +49,37 @@ export { strsm } from "./src/strsm/strsm.mjs";
|
|
|
38
49
|
/**
|
|
39
50
|
* Initializes the WebGPU device.
|
|
40
51
|
*
|
|
52
|
+
* Devices are cached per option set: the same options return the same device,
|
|
53
|
+
* different options a separate one — so one process can drive several GPUs
|
|
54
|
+
* (`"high-performance"` and `"low-power"` typically resolve to the discrete and
|
|
55
|
+
* integrated adapters). Each routine dispatches to the device you pass it; GPU
|
|
56
|
+
* buffers cannot cross devices, so a `GpuVector`/`GpuMatrix` from one is
|
|
57
|
+
* rejected by another. {@link cleanup} releases them all.
|
|
58
|
+
*
|
|
41
59
|
* @param options.powerPreference - GPU power preference (default: `"high-performance"`).
|
|
42
60
|
* This is a hint to the browser: on dual-GPU systems, `"high-performance"` typically favors the discrete GPU
|
|
43
61
|
* and `"low-power"` favors the integrated one.
|
|
44
62
|
* See [MDN: GPU.requestAdapter()](https://developer.mozilla.org/en-US/docs/Web/API/GPU/requestAdapter).
|
|
45
|
-
* @param options.benchmark - enable GPU timestamp queries; BLAS functions return `
|
|
63
|
+
* @param options.benchmark - enable GPU timestamp queries; BLAS functions then also return `gpuTimeMs`
|
|
64
|
+
* alongside their normal result (e.g. sscal returns `{ x, gpuTimeMs }`, saxpy returns `{ y, gpuTimeMs }`) —
|
|
65
|
+
* see each routine's own docs for its exact return shape (default: `false`)
|
|
46
66
|
* @param options.dumpShaders - Node-only. Forwards Dawn's `dump_shaders` debug toggle, printing
|
|
47
67
|
* each pipeline's WGSL and compiled backend IR (SPIR-V/Vulkan, MSL/Metal, or HLSL/D3D12,
|
|
48
68
|
* whichever Dawn picked) to stderr as it compiles. A Dawn passthrough, not a wgblas format —
|
|
49
69
|
* no effect in the browser, which gives pages no API to request compiled shader IR (default: `false`)
|
|
50
70
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
71
|
+
* **Default (high-performance GPU):**
|
|
72
|
+
* {@includeCode examples/init/init.js}
|
|
73
|
+
*
|
|
74
|
+
* **Low-power (integrated GPU):**
|
|
75
|
+
* {@includeCode examples/init-low-power/init-low-power.js}
|
|
76
|
+
*
|
|
77
|
+
* **Benchmark mode:**
|
|
78
|
+
* {@includeCode examples/init-benchmark/init-benchmark.js}
|
|
58
79
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* import { init, gpuName } from "wgblas";
|
|
62
|
-
* await init({ powerPreference: "low-power" });
|
|
63
|
-
* const { description, device } = gpuName();
|
|
64
|
-
* console.log("description:", description, "device:", device);
|
|
65
|
-
* ```
|
|
80
|
+
* **Two GPUs at once:**
|
|
81
|
+
* {@includeCode examples/init-two-gpus/init-two-gpus.js}
|
|
66
82
|
*
|
|
67
|
-
* @example Benchmark mode
|
|
68
|
-
* ```js
|
|
69
|
-
* import { init, sscal } from "wgblas";
|
|
70
|
-
* const device = await init({ benchmark: true });
|
|
71
|
-
* const n = 5;
|
|
72
|
-
* const alpha = 2.0;
|
|
73
|
-
* const x = new Float32Array([1, 2, 3, 4, 5]);
|
|
74
|
-
* const { result, gpuTimeMs } = await sscal(device, n, alpha, x, 1);
|
|
75
|
-
* console.log(`Result: [${Array.from(result).join(", ")}]`);
|
|
76
|
-
* console.log(`GPU time: ${gpuTimeMs.toFixed(3)} ms`);
|
|
77
|
-
* ```
|
|
78
83
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L18-L54)
|
|
79
84
|
* @category Core
|
|
80
85
|
*/
|
|
@@ -85,33 +90,33 @@ export declare function init(options?: {
|
|
|
85
90
|
}): Promise<GPUDevice>;
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
|
-
* Destroys
|
|
89
|
-
*
|
|
93
|
+
* Destroys devices created by {@link init} and releases their cached pipelines and buffers.
|
|
94
|
+
* Call when done (required in Node.js to prevent crash on exit).
|
|
90
95
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
96
|
+
* With no argument, releases every device at once. Pass a device to release
|
|
97
|
+
* just that one and leave the others usable — handy when driving several GPUs.
|
|
98
|
+
* Unknown or already-released devices are ignored, so this is safe to call
|
|
99
|
+
* more than once.
|
|
94
100
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* ```
|
|
101
|
+
* @param device - the device to release; omit to release all of them.
|
|
102
|
+
*
|
|
103
|
+
* {@includeCode examples/cleanup/cleanup.js}
|
|
99
104
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L56-L65)
|
|
100
105
|
* @category Core
|
|
101
106
|
*/
|
|
102
|
-
export declare function cleanup(): void;
|
|
107
|
+
export declare function cleanup(device?: GPUDevice): void;
|
|
103
108
|
|
|
104
109
|
/**
|
|
105
110
|
* Returns the GPU device name from the WebGPU adapter info. Must be called after `init()`.
|
|
106
111
|
*
|
|
107
|
-
* @
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* const { description, device } = gpuName();
|
|
112
|
-
* console.log("description:", description, "device:", device);
|
|
113
|
-
* ```
|
|
112
|
+
* @param device - which device to report on; defaults to the one from the first
|
|
113
|
+
* `init()` call. Pass it explicitly when driving more than one GPU.
|
|
114
|
+
*
|
|
115
|
+
* {@includeCode examples/init/init.js}
|
|
114
116
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L81-L87)
|
|
115
117
|
* @category Core
|
|
116
118
|
*/
|
|
117
|
-
export declare function gpuName(): {
|
|
119
|
+
export declare function gpuName(device?: GPUDevice): {
|
|
120
|
+
description: string;
|
|
121
|
+
device: string;
|
|
122
|
+
};
|
package/index.mjs
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
export { init, cleanup, gpuName } from "./src/init.mjs";
|
|
2
2
|
export { GpuVector } from "./src/classes/GpuVector.mjs";
|
|
3
3
|
export { GpuMatrix } from "./src/classes/GpuMatrix.mjs";
|
|
4
|
+
export { Complex32, Complex32Array } from "./src/classes/Complex32.mjs";
|
|
5
|
+
export { Complex64, Complex64Array } from "./src/classes/Complex64.mjs";
|
|
4
6
|
export {
|
|
5
7
|
randomFloat32Array,
|
|
6
8
|
randomFloat64Array,
|
|
7
9
|
randomTriangularFloat32Array,
|
|
8
10
|
} from "./src/random/random.mjs";
|
|
9
11
|
export { sscal } from "./src/sscal/sscal.mjs";
|
|
12
|
+
export { cscal } from "./src/cscal/cscal.mjs";
|
|
13
|
+
export { dscal } from "./src/dscal/dscal.mjs";
|
|
10
14
|
export { sswap } from "./src/sswap/sswap.mjs";
|
|
15
|
+
export { dswap } from "./src/dswap/dswap.mjs";
|
|
11
16
|
export { saxpy } from "./src/saxpy/saxpy.mjs";
|
|
17
|
+
export { daxpy } from "./src/daxpy/daxpy.mjs";
|
|
12
18
|
export { scopy } from "./src/scopy/scopy.mjs";
|
|
19
|
+
export { dcopy } from "./src/dcopy/dcopy.mjs";
|
|
13
20
|
export { sdot } from "./src/sdot/sdot.mjs";
|
|
14
21
|
export { sasum } from "./src/sasum/sasum.mjs";
|
|
15
22
|
export { dasum } from "./src/dasum/dasum.mjs";
|
|
23
|
+
export { ddot } from "./src/ddot/ddot.mjs";
|
|
16
24
|
export { snrm2 } from "./src/snrm2/snrm2.mjs";
|
|
25
|
+
export { dnrm2 } from "./src/dnrm2/dnrm2.mjs";
|
|
17
26
|
export { isamax } from "./src/isamax/isamax.mjs";
|
|
18
27
|
export { idamax } from "./src/idamax/idamax.mjs";
|
|
19
28
|
export { srot } from "./src/srot/srot.mjs";
|
|
29
|
+
export { drot } from "./src/drot/drot.mjs";
|
|
20
30
|
export { srotm } from "./src/srotm/srotm.mjs";
|
|
31
|
+
export { drotm } from "./src/drotm/drotm.mjs";
|
|
21
32
|
export { sgemv } from "./src/sgemv/sgemv.mjs";
|
|
22
33
|
export { ssymv } from "./src/ssymv/ssymv.mjs";
|
|
23
34
|
export { strmv } from "./src/strmv/strmv.mjs";
|
package/package.json
CHANGED
|
@@ -1,131 +1,175 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wgblas",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "BLAS on WebGPU",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
7
7
|
"types": "./index.d.mts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./index.d.mts",
|
|
11
|
+
"import": "./index.mjs"
|
|
12
12
|
},
|
|
13
13
|
"./browser": "./dist/wgblas.browser.js",
|
|
14
14
|
"./classes/GpuVector": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"types": "./src/classes/GpuVector.d.mts",
|
|
16
|
+
"import": "./src/classes/GpuVector.mjs"
|
|
17
17
|
},
|
|
18
18
|
"./classes/GpuMatrix": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"types": "./src/classes/GpuMatrix.d.mts",
|
|
20
|
+
"import": "./src/classes/GpuMatrix.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./classes/Complex32": {
|
|
23
|
+
"types": "./src/classes/Complex32.d.mts",
|
|
24
|
+
"import": "./src/classes/Complex32.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./classes/Complex64": {
|
|
27
|
+
"types": "./src/classes/Complex64.d.mts",
|
|
28
|
+
"import": "./src/classes/Complex64.mjs"
|
|
21
29
|
},
|
|
22
30
|
"./random": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
31
|
+
"types": "./src/random/random.d.mts",
|
|
32
|
+
"import": "./src/random/random.mjs"
|
|
25
33
|
},
|
|
26
34
|
"./sscal": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
35
|
+
"types": "./src/sscal/sscal.d.mts",
|
|
36
|
+
"import": "./src/sscal/sscal.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./cscal": {
|
|
39
|
+
"types": "./src/cscal/cscal.d.mts",
|
|
40
|
+
"import": "./src/cscal/cscal.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./dscal": {
|
|
43
|
+
"types": "./src/dscal/dscal.d.mts",
|
|
44
|
+
"import": "./src/dscal/dscal.mjs"
|
|
29
45
|
},
|
|
30
46
|
"./sswap": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
47
|
+
"types": "./src/sswap/sswap.d.mts",
|
|
48
|
+
"import": "./src/sswap/sswap.mjs"
|
|
49
|
+
},
|
|
50
|
+
"./dswap": {
|
|
51
|
+
"types": "./src/dswap/dswap.d.mts",
|
|
52
|
+
"import": "./src/dswap/dswap.mjs"
|
|
33
53
|
},
|
|
34
54
|
"./saxpy": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
55
|
+
"types": "./src/saxpy/saxpy.d.mts",
|
|
56
|
+
"import": "./src/saxpy/saxpy.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./daxpy": {
|
|
59
|
+
"types": "./src/daxpy/daxpy.d.mts",
|
|
60
|
+
"import": "./src/daxpy/daxpy.mjs"
|
|
37
61
|
},
|
|
38
62
|
"./scopy": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
63
|
+
"types": "./src/scopy/scopy.d.mts",
|
|
64
|
+
"import": "./src/scopy/scopy.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./dcopy": {
|
|
67
|
+
"types": "./src/dcopy/dcopy.d.mts",
|
|
68
|
+
"import": "./src/dcopy/dcopy.mjs"
|
|
41
69
|
},
|
|
42
70
|
"./sdot": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
71
|
+
"types": "./src/sdot/sdot.d.mts",
|
|
72
|
+
"import": "./src/sdot/sdot.mjs"
|
|
45
73
|
},
|
|
46
74
|
"./sasum": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
75
|
+
"types": "./src/sasum/sasum.d.mts",
|
|
76
|
+
"import": "./src/sasum/sasum.mjs"
|
|
49
77
|
},
|
|
50
78
|
"./dasum": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
79
|
+
"types": "./src/dasum/dasum.d.mts",
|
|
80
|
+
"import": "./src/dasum/dasum.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./ddot": {
|
|
83
|
+
"types": "./src/ddot/ddot.d.mts",
|
|
84
|
+
"import": "./src/ddot/ddot.mjs"
|
|
53
85
|
},
|
|
54
86
|
"./snrm2": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
87
|
+
"types": "./src/snrm2/snrm2.d.mts",
|
|
88
|
+
"import": "./src/snrm2/snrm2.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./dnrm2": {
|
|
91
|
+
"types": "./src/dnrm2/dnrm2.d.mts",
|
|
92
|
+
"import": "./src/dnrm2/dnrm2.mjs"
|
|
57
93
|
},
|
|
58
94
|
"./isamax": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
95
|
+
"types": "./src/isamax/isamax.d.mts",
|
|
96
|
+
"import": "./src/isamax/isamax.mjs"
|
|
61
97
|
},
|
|
62
98
|
"./idamax": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
99
|
+
"types": "./src/idamax/idamax.d.mts",
|
|
100
|
+
"import": "./src/idamax/idamax.mjs"
|
|
65
101
|
},
|
|
66
102
|
"./srot": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
103
|
+
"types": "./src/srot/srot.d.mts",
|
|
104
|
+
"import": "./src/srot/srot.mjs"
|
|
105
|
+
},
|
|
106
|
+
"./drot": {
|
|
107
|
+
"types": "./src/drot/drot.d.mts",
|
|
108
|
+
"import": "./src/drot/drot.mjs"
|
|
69
109
|
},
|
|
70
110
|
"./srotm": {
|
|
71
|
-
"
|
|
72
|
-
"
|
|
111
|
+
"types": "./src/srotm/srotm.d.mts",
|
|
112
|
+
"import": "./src/srotm/srotm.mjs"
|
|
113
|
+
},
|
|
114
|
+
"./drotm": {
|
|
115
|
+
"types": "./src/drotm/drotm.d.mts",
|
|
116
|
+
"import": "./src/drotm/drotm.mjs"
|
|
73
117
|
},
|
|
74
118
|
"./sgemv": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
119
|
+
"types": "./src/sgemv/sgemv.d.mts",
|
|
120
|
+
"import": "./src/sgemv/sgemv.mjs"
|
|
77
121
|
},
|
|
78
122
|
"./ssymv": {
|
|
79
|
-
"
|
|
80
|
-
"
|
|
123
|
+
"types": "./src/ssymv/ssymv.d.mts",
|
|
124
|
+
"import": "./src/ssymv/ssymv.mjs"
|
|
81
125
|
},
|
|
82
126
|
"./strmv": {
|
|
83
|
-
"
|
|
84
|
-
"
|
|
127
|
+
"types": "./src/strmv/strmv.d.mts",
|
|
128
|
+
"import": "./src/strmv/strmv.mjs"
|
|
85
129
|
},
|
|
86
130
|
"./strsv": {
|
|
87
|
-
"
|
|
88
|
-
"
|
|
131
|
+
"types": "./src/strsv/strsv.d.mts",
|
|
132
|
+
"import": "./src/strsv/strsv.mjs"
|
|
89
133
|
},
|
|
90
134
|
"./sger": {
|
|
91
|
-
"
|
|
92
|
-
"
|
|
135
|
+
"types": "./src/sger/sger.d.mts",
|
|
136
|
+
"import": "./src/sger/sger.mjs"
|
|
93
137
|
},
|
|
94
138
|
"./ssyr": {
|
|
95
|
-
"
|
|
96
|
-
"
|
|
139
|
+
"types": "./src/ssyr/ssyr.d.mts",
|
|
140
|
+
"import": "./src/ssyr/ssyr.mjs"
|
|
97
141
|
},
|
|
98
142
|
"./ssyr2": {
|
|
99
|
-
"
|
|
100
|
-
"
|
|
143
|
+
"types": "./src/ssyr2/ssyr2.d.mts",
|
|
144
|
+
"import": "./src/ssyr2/ssyr2.mjs"
|
|
101
145
|
},
|
|
102
146
|
"./sgemm": {
|
|
103
|
-
"
|
|
104
|
-
"
|
|
147
|
+
"types": "./src/sgemm/sgemm.d.mts",
|
|
148
|
+
"import": "./src/sgemm/sgemm.mjs"
|
|
105
149
|
},
|
|
106
150
|
"./sgemmtr": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
151
|
+
"types": "./src/sgemmtr/sgemmtr.d.mts",
|
|
152
|
+
"import": "./src/sgemmtr/sgemmtr.mjs"
|
|
109
153
|
},
|
|
110
154
|
"./ssyrk": {
|
|
111
|
-
"
|
|
112
|
-
"
|
|
155
|
+
"types": "./src/ssyrk/ssyrk.d.mts",
|
|
156
|
+
"import": "./src/ssyrk/ssyrk.mjs"
|
|
113
157
|
},
|
|
114
158
|
"./ssyr2k": {
|
|
115
|
-
"
|
|
116
|
-
"
|
|
159
|
+
"types": "./src/ssyr2k/ssyr2k.d.mts",
|
|
160
|
+
"import": "./src/ssyr2k/ssyr2k.mjs"
|
|
117
161
|
},
|
|
118
162
|
"./ssymm": {
|
|
119
|
-
"
|
|
120
|
-
"
|
|
163
|
+
"types": "./src/ssymm/ssymm.d.mts",
|
|
164
|
+
"import": "./src/ssymm/ssymm.mjs"
|
|
121
165
|
},
|
|
122
166
|
"./strmm": {
|
|
123
|
-
"
|
|
124
|
-
"
|
|
167
|
+
"types": "./src/strmm/strmm.d.mts",
|
|
168
|
+
"import": "./src/strmm/strmm.mjs"
|
|
125
169
|
},
|
|
126
170
|
"./strsm": {
|
|
127
|
-
"
|
|
128
|
-
"
|
|
171
|
+
"types": "./src/strsm/strsm.d.mts",
|
|
172
|
+
"import": "./src/strsm/strsm.mjs"
|
|
129
173
|
}
|
|
130
174
|
},
|
|
131
175
|
"files": [
|
|
@@ -179,7 +223,18 @@
|
|
|
179
223
|
"@commitlint/cli": "^21.2.1",
|
|
180
224
|
"@commitlint/config-conventional": "^21.2.0",
|
|
181
225
|
"@eslint/js": "^10.0.1",
|
|
226
|
+
"@size-limit/file": "^13.0.3",
|
|
227
|
+
"@stdlib/array-complex64": "^0.3.2",
|
|
228
|
+
"@stdlib/blas-base-cscal": "^0.1.1",
|
|
182
229
|
"@stdlib/blas-base-dasum": "^0.4.1",
|
|
230
|
+
"@stdlib/blas-base-daxpy": "^0.4.1",
|
|
231
|
+
"@stdlib/blas-base-dcopy": "^0.4.1",
|
|
232
|
+
"@stdlib/blas-base-ddot": "^0.4.1",
|
|
233
|
+
"@stdlib/blas-base-dnrm2": "^0.4.1",
|
|
234
|
+
"@stdlib/blas-base-drot": "^0.1.1",
|
|
235
|
+
"@stdlib/blas-base-drotm": "^0.2.1",
|
|
236
|
+
"@stdlib/blas-base-dscal": "^0.4.1",
|
|
237
|
+
"@stdlib/blas-base-dswap": "^0.4.1",
|
|
183
238
|
"@stdlib/blas-base-idamax": "^0.1.1",
|
|
184
239
|
"@stdlib/blas-base-isamax": "^0.1.1",
|
|
185
240
|
"@stdlib/blas-base-sasum": "^0.3.1",
|
|
@@ -199,8 +254,10 @@
|
|
|
199
254
|
"@stdlib/blas-base-ssyr2": "^0.1.1",
|
|
200
255
|
"@stdlib/blas-base-strmv": "^0.1.0",
|
|
201
256
|
"@stdlib/blas-base-strsv": "^0.1.1",
|
|
257
|
+
"@stdlib/complex-float32-ctor": "^0.1.1",
|
|
202
258
|
"@stdlib/random-array-uniform": "^0.2.2",
|
|
203
259
|
"@stdlib/random-base-uniform": "^0.2.3",
|
|
260
|
+
"c8": "^12.0.0",
|
|
204
261
|
"esbuild": "^0.28.1",
|
|
205
262
|
"eslint": "^10.6.0",
|
|
206
263
|
"fast-check": "^4.8.0",
|
|
@@ -208,7 +265,10 @@
|
|
|
208
265
|
"husky": "^9.1.7",
|
|
209
266
|
"lint-staged": "^17.0.8",
|
|
210
267
|
"prettier": "^3.9.4",
|
|
268
|
+
"publint": "^0.3.24",
|
|
269
|
+
"size-limit": "^13.0.3",
|
|
211
270
|
"typedoc": "^0.28.19",
|
|
271
|
+
"typedoc-plugin-katex": "^0.1.2",
|
|
212
272
|
"typescript": "^6.0.3",
|
|
213
273
|
"vite": "^8.0.16"
|
|
214
274
|
},
|
|
@@ -216,12 +276,22 @@
|
|
|
216
276
|
"prepare": "husky",
|
|
217
277
|
"build:browser": "node scripts/build-browser.mjs",
|
|
218
278
|
"docs": "npx typedoc && npm run build:browser",
|
|
219
|
-
"prepublishOnly": "npm run build:browser"
|
|
279
|
+
"prepublishOnly": "npm run build:browser",
|
|
280
|
+
"coverage": "c8 --reporter=text --reporter=html node --test $(find tests \\( -name 'test.*.js' -o -name 'gpustorage.*.js' \\))",
|
|
281
|
+
"cpd": "jscpd src",
|
|
282
|
+
"size": "npm run build:browser && size-limit"
|
|
220
283
|
},
|
|
221
284
|
"lint-staged": {
|
|
222
285
|
"*.{js,mjs,cjs}": [
|
|
223
286
|
"prettier --write",
|
|
224
287
|
"eslint"
|
|
225
288
|
]
|
|
226
|
-
}
|
|
289
|
+
},
|
|
290
|
+
"size-limit": [
|
|
291
|
+
{
|
|
292
|
+
"name": "browser bundle (brotli)",
|
|
293
|
+
"path": "dist/wgblas.browser.js",
|
|
294
|
+
"limit": "50 KB"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
227
297
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single 32-bit (f32) complex number: a real and an imaginary component.
|
|
3
|
+
* JavaScript has no native complex number type, so this is the value type
|
|
4
|
+
* every complex routine in this library builds on.
|
|
5
|
+
*
|
|
6
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex32.mjs#L8">Source code: Complex32.mjs (L8)</a>
|
|
7
|
+
* @category Classes
|
|
8
|
+
*/
|
|
9
|
+
export declare class Complex32 {
|
|
10
|
+
/**
|
|
11
|
+
* @param re - real component, rounded to the nearest f32
|
|
12
|
+
* @param im - imaginary component, rounded to the nearest f32
|
|
13
|
+
*
|
|
14
|
+
* {@includeCode ../../examples/complex32/complex32.js}
|
|
15
|
+
*/
|
|
16
|
+
constructor(re: number, im: number);
|
|
17
|
+
|
|
18
|
+
/** Real component (f32-rounded via `Math.fround`). */
|
|
19
|
+
re: number;
|
|
20
|
+
|
|
21
|
+
/** Imaginary component (f32-rounded via `Math.fround`). */
|
|
22
|
+
im: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An array of Complex32 values — array-of-structs, each element its own
|
|
27
|
+
* independent Complex32 instance (as opposed to a struct-of-arrays layout
|
|
28
|
+
* with separate re/im buffers). Extends the native Array, so indexing
|
|
29
|
+
* (`arr[i]`), `.length`, iteration, `.map`, etc. all work as expected.
|
|
30
|
+
*
|
|
31
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex32.mjs#L38">Source code: Complex32.mjs (L38)</a>
|
|
32
|
+
* @category Classes
|
|
33
|
+
*/
|
|
34
|
+
export declare class Complex32Array extends Array<Complex32> {
|
|
35
|
+
/**
|
|
36
|
+
* @param arg - a length (fills with that many zero-valued Complex32
|
|
37
|
+
* entries), a flat interleaved `[re, im, re, im, ...]` list of numbers,
|
|
38
|
+
* or an iterable of existing Complex32 instances to copy
|
|
39
|
+
*
|
|
40
|
+
* {@includeCode ../../examples/complex32array/complex32array.js}
|
|
41
|
+
*/
|
|
42
|
+
constructor(arg?: number | Iterable<number> | Iterable<Complex32>);
|
|
43
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** @module devdocs/classes/Complex32 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single 32-bit (f32) complex number: a real and an imaginary component.
|
|
5
|
+
* JavaScript has no native complex number type, so this is the value type
|
|
6
|
+
* every complex routine in this library builds on.
|
|
7
|
+
*/
|
|
8
|
+
export class Complex32 {
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} re - real component, rounded to the nearest f32 (same
|
|
11
|
+
* `Math.fround` truncation splitDoubleDouble uses for f64 emulation) —
|
|
12
|
+
* a plain JS number is an f64, and "32" in Complex32 means each
|
|
13
|
+
* component is genuinely f32-precision, not just f64 stored in an
|
|
14
|
+
* f32-sized slot
|
|
15
|
+
* @param {number} im - imaginary component, rounded to the nearest f32
|
|
16
|
+
*/
|
|
17
|
+
constructor(re, im) {
|
|
18
|
+
this.re = Math.fround(re);
|
|
19
|
+
this.im = Math.fround(im);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An array of Complex32 values — array-of-structs, each element its own
|
|
25
|
+
* independent Complex32 instance (as opposed to a struct-of-arrays layout
|
|
26
|
+
* with separate re/im buffers). Extends the native Array so indexing
|
|
27
|
+
* (`arr[i]`), `.length`, iteration, `.map`, etc. all work as expected.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors @stdlib/array-complex64's constructor overloads (minus the
|
|
30
|
+
* ArrayBuffer-view form, which needs a flat backing buffer — incompatible
|
|
31
|
+
* with storing genuine Complex32 instances one per slot):
|
|
32
|
+
*
|
|
33
|
+
* new Complex32Array() // empty
|
|
34
|
+
* new Complex32Array(length) // length zero-valued entries
|
|
35
|
+
* new Complex32Array([1, 5, 3, 8]) // flat [re, im, re, im, ...] pairs
|
|
36
|
+
* new Complex32Array([z1, z2]) // copies existing Complex32 instances
|
|
37
|
+
*/
|
|
38
|
+
export class Complex32Array extends Array {
|
|
39
|
+
/**
|
|
40
|
+
* @param {number|Iterable<number>|Iterable<Complex32>} [arg] - a length,
|
|
41
|
+
* a flat interleaved [re, im, ...] list of numbers, or an iterable of
|
|
42
|
+
* existing Complex32 instances
|
|
43
|
+
*/
|
|
44
|
+
constructor(arg) {
|
|
45
|
+
if (arg === undefined) {
|
|
46
|
+
super();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof arg === "number") {
|
|
50
|
+
super(arg);
|
|
51
|
+
for (let i = 0; i < arg; i++) this[i] = new Complex32(0, 0);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const items = Array.from(arg);
|
|
56
|
+
super();
|
|
57
|
+
if (items.length === 0) return;
|
|
58
|
+
|
|
59
|
+
if (items[0] instanceof Complex32) {
|
|
60
|
+
for (const z of items) {
|
|
61
|
+
if (!(z instanceof Complex32))
|
|
62
|
+
throw new Error(
|
|
63
|
+
"Complex32Array expects every element to be a Complex32.",
|
|
64
|
+
);
|
|
65
|
+
this.push(z);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (items.length % 2 !== 0)
|
|
71
|
+
throw new Error(
|
|
72
|
+
"Complex32Array expects an even number of interleaved [re, im, ...] values.",
|
|
73
|
+
);
|
|
74
|
+
for (let i = 0; i < items.length; i += 2) {
|
|
75
|
+
if (typeof items[i] !== "number" || typeof items[i + 1] !== "number")
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Complex32Array expects interleaved [re, im, ...] values to be numbers.",
|
|
78
|
+
);
|
|
79
|
+
this.push(new Complex32(items[i], items[i + 1]));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|