GPUDevice from init()
number of elements (must be a positive integer)
scalar multiplier
Float64Array input vector
stride for x (must be a positive integer)
Float64Array input/output vector
stride for y (must be a positive integer)
Performs the operation $$y \leftarrow \alpha x + y$$ — GPU-resident overload; see the Float64Array overload above for the routine itself.
Range: double-double keeps its leading part in an f32, so it has ~48 bits of precision but f32's exponent range. A double beyond ±3.4e38 reads as ±Infinity and one below ~1.2e-38 in magnitude as 0 (f32 subnormals may flush too, depending on the GPU) — including elements of an output array the routine never touches (stride gaps, padding, an unreferenced triangle) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
import { init, cleanup } from "wgblas";
import { daxpy } from "wgblas/daxpy";
import { dscal } from "wgblas/dscal";
import { GpuVector } from "wgblas/classes/GpuVector";
const device = await init();
const n = 5;
const alpha = 2;
const scale = 0.5;
const x = new Float64Array([1, 2, 3, 4, 5]);
const y = new Float64Array([10, 20, 30, 40, 50]);
const xGpu = GpuVector.from(x);
const yGpu = GpuVector.from(y);
console.log("x: ", x);
console.log("y: ", y);
// results stay on the GPU.
await daxpy(device, n, alpha, xGpu, 1, yGpu, 1);
await dscal(device, n, scale, yGpu, 1);
// single readback
const result = await yGpu.read();
console.log("result: ", result);
xGpu.destroy();
yGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
number of elements (must be a positive integer)
scalar multiplier
GpuVector input vector (must be Float64Array-backed)
stride for x (must be a positive integer)
GpuVector input/output vector (must be Float64Array-backed, mutated in place)
stride for y (must be a positive integer)
Performs the operation $$y \leftarrow \alpha x + y$$ — double-double (Dekker) f64 emulation of saxpy, since WGSL has no native f64 type.
Range: double-double keeps its leading part in an f32, so it has ~48 bits of precision but f32's exponent range. A double beyond ±3.4e38 reads as ±Infinity and one below ~1.2e-38 in magnitude as 0 (f32 subnormals may flush too, depending on the GPU) — including elements of an output array the routine never touches (stride gaps, padding, an unreferenced triangle) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
Browser (standalone HTML):