GPUDevice from init()
number of elements (must be a positive integer)
Float64Array input vector
stride for x (must be a positive integer)
Float64Array output vector
stride for y (must be a positive integer)
Performs the operation $$y \leftarrow x$$ — GPU-resident overload; see the Float64Array overload above for the routine itself.
import { init, cleanup } from "wgblas";
import { dcopy } from "wgblas/dcopy";
import { dscal } from "wgblas/dscal";
import { GpuVector } from "wgblas/classes/GpuVector";
const device = await init();
const n = 5;
const scale = 2.0;
const x = new Float64Array([1, 2, 3, 4, 5]);
const y = new Float64Array(n);
const xGpu = GpuVector.from(x);
const yGpu = GpuVector.from(y);
console.log("x: ", x);
// copy x into y, then scale y — all on GPU with single readback
await dcopy(device, n, xGpu, 1, yGpu, 1);
await dscal(device, n, scale, yGpu, 1);
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)
GpuVector input vector (must be Float64Array-backed)
stride for x (must be a positive integer)
GpuVector output vector (must be Float64Array-backed, mutated in place)
stride for y (must be a positive integer)
Performs the operation $$y \leftarrow x$$ — double-double (Dekker) f64 emulation of scopy, since WGSL has no native f64 type.
Browser (standalone HTML):