-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.mts
More file actions
105 lines (102 loc) · 3.88 KB
/
Copy pathindex.d.mts
File metadata and controls
105 lines (102 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* @module docs
*/
export { GpuVector } from "./src/classes/GpuVector.mjs";
export { GpuMatrix } from "./src/classes/GpuMatrix.mjs";
export {
randomFloat32Array,
randomFloat64Array,
randomTriangularFloat32Array,
} from "./src/random/random.mjs";
export { sscal } from "./src/sscal/sscal.mjs";
export { sswap } from "./src/sswap/sswap.mjs";
export { saxpy } from "./src/saxpy/saxpy.mjs";
export { scopy } from "./src/scopy/scopy.mjs";
export { sdot } from "./src/sdot/sdot.mjs";
export { sasum } from "./src/sasum/sasum.mjs";
export { dasum } from "./src/dasum/dasum.mjs";
export { snrm2 } from "./src/snrm2/snrm2.mjs";
export { isamax } from "./src/isamax/isamax.mjs";
export { idamax } from "./src/idamax/idamax.mjs";
export { srot } from "./src/srot/srot.mjs";
export { srotm } from "./src/srotm/srotm.mjs";
export { sgemv } from "./src/sgemv/sgemv.mjs";
export { ssymv } from "./src/ssymv/ssymv.mjs";
export { strmv } from "./src/strmv/strmv.mjs";
export { strsv } from "./src/strsv/strsv.mjs";
export { sger } from "./src/sger/sger.mjs";
export { ssyr } from "./src/ssyr/ssyr.mjs";
export { ssyr2 } from "./src/ssyr2/ssyr2.mjs";
/**
* Initializes the WebGPU device.
*
* @param options.powerPreference - GPU power preference (default: `"high-performance"`).
* This is a hint to the browser: on dual-GPU systems, `"high-performance"` typically favors the discrete GPU
* and `"low-power"` favors the integrated one.
* See [MDN: GPU.requestAdapter()](https://developer.mozilla.org/en-US/docs/Web/API/GPU/requestAdapter).
* @param options.benchmark - enable GPU timestamp queries; BLAS functions return `{ result, gpuTimeMs }` (default: `false`)
*
* @example Default (high-performance GPU)
* ```js
* import { init, gpuName } from "wgblas";
* await init();
* const { description, device } = gpuName();
* console.log("description:", description, "device:", device);
* ```
*
* @example Low-power (integrated GPU)
* ```js
* import { init, gpuName } from "wgblas";
* await init({ powerPreference: "low-power" });
* const { description, device } = gpuName();
* console.log("description:", description, "device:", device);
* ```
*
* @example Benchmark mode
* ```js
* import { init, sscal } from "wgblas";
* const device = await init({ benchmark: true });
* const n = 5;
* const alpha = 2.0;
* const x = new Float32Array([1, 2, 3, 4, 5]);
* const { result, gpuTimeMs } = await sscal(device, n, alpha, x, 1);
* console.log(`Result: [${Array.from(result).join(", ")}]`);
* console.log(`GPU time: ${gpuTimeMs.toFixed(3)} ms`);
* ```
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L18-L54)
* @category Core
*/
export declare function init(options?: {
powerPreference?: GPUPowerPreference;
benchmark?: boolean;
}): Promise<GPUDevice>;
/**
* Destroys the WebGPU device, releases the adapter, resets benchmark state, and fires all internal
* cleanup callbacks (e.g. releasing cached GPU pipelines and buffers). Call when done (required in Node.js to prevent crash on exit).
*
* @example
* ```js
* import { init, cleanup, gpuName } from "wgblas";
*
* await init();
* console.log("GPU:", gpuName().description);
* if (typeof process !== "undefined") cleanup(); // Node.js only — browser cleanup is automatic
* ```
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L56-L65)
* @category Core
*/
export declare function cleanup(): void;
/**
* Returns the GPU device name from the WebGPU adapter info. Must be called after `init()`.
*
* @example
* ```js
* import { init, gpuName } from "wgblas";
* await init();
* const { description, device } = gpuName();
* console.log("description:", description, "device:", device);
* ```
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L81-L87)
* @category Core
*/
export declare function gpuName(): { description: string; device: string };