@thi.ng/simd
Version:
WASM based SIMD vector operations for batch processing
34 lines (33 loc) • 770 B
JavaScript
import { BINARY } from "./binary.js";
export * from "./api.js";
const init = (memory) => {
const buf = memory.buffer;
return {
...new WebAssembly.Instance(
new WebAssembly.Module(
new Uint8Array([...atob(BINARY)].map((x) => x.charCodeAt(0)))
),
{
env: {
memory,
abort(_, file, line, column) {
console.error(
`abort called in ${file}: ${line}:${column}`
);
}
}
}
).exports,
f32: new Float32Array(buf),
f64: new Float64Array(buf),
u32: new Uint32Array(buf),
i32: new Int32Array(buf),
u16: new Uint16Array(buf),
i16: new Int16Array(buf),
u8: new Uint8Array(buf),
i8: new Int8Array(buf)
};
};
export {
init
};