/ concept-collection / turing-surface
Sign in
concept-collection / turing-surface
60 lines · 2.3 KBCodeBlameHistory
2 * The whole suite on desktop WebGPU (Google Dawn), against the real pipeline:
3 * MATLAB source -> numbl lowering -> generated WGSL -> GPU.
4 *
5 * The same four check modules run in the browser (test.html), so both GPU
6 * stacks get the same guarantees. Run through vite-node, which is what resolves
7 * numbl's compiler sources and the `?raw` model imports:
8 *
9 * npm run test:node
10 */
11import { requestShtDevice } from '../src/sht/sht.ts';
12import { installWebGpu, errMsg, NO_ADAPTER_HINT } from './nodeWebGpu.ts';
13import { transformChecks } from '../test/transformChecks.ts';
14import { analyticChecks } from '../test/analyticChecks.ts';
15import { modelChecks } from '../test/modelChecks.ts';
16import { geometryChecks } from '../test/geometryChecks.ts';
591a4f5Reduce the Laplace-Beltrami matvec to 6 transforms per species per iterationDan Fortunato 17import { fluxChecks } from '../test/fluxChecks.ts';
f467ffaCompare several solver settings side by side, on one clockJeremy Magland 18import { compareChecks } from '../test/compareChecks.ts';
20let failures = 0;
21const check = (name: string, ok: boolean, detail: string): void => {
22 console.log(`${ok ? 'PASS' : 'FAIL'} ${name} ${detail}`);
23 if (!ok) failures++;
24};
25const log = (s: string): void => console.log(s);
27/**
28 * These checks compile MATLAB to compute shaders, so unlike the old CPU-solver
29 * suite they need a GPU. `--skip-without-gpu` lets a runner that has none say so
30 * and move on — CI uses it, because the browser suite runs the very same check
31 * modules on SwiftShader. A plain local run still fails loudly, so a missing GPU
32 * is never mistaken for a pass.
33 */
34const skipWithoutGpu = process.argv.includes('--skip-without-gpu');
36let runtime: string;
37let device: GPUDevice;
38try {
39 runtime = await installWebGpu();
40 device = await requestShtDevice();
41} catch (e) {
42 const detail = `${errMsg(e)}\n${NO_ADAPTER_HINT}`;
43 if (skipWithoutGpu) {
44 console.log(`SKIP no WebGPU available here, so these checks did not run.\n${detail}`);
45 process.exit(0);
46 }
47 console.error(`test-node: ${detail}`);
48 process.exit(1);
50console.log(`turing-surface tests — ${runtime}\n`);
52await transformChecks(device, check, log);
53await analyticChecks(device, check, log);
54await modelChecks(device, check, log);
55await geometryChecks(device, check, log);
591a4f5Reduce the Laplace-Beltrami matvec to 6 transforms per species per iterationDan Fortunato 56await fluxChecks(device, check, log);
f467ffaCompare several solver settings side by side, on one clockJeremy Magland 57await compareChecks(device, check, log);
59console.log(failures === 0 ? '\nAll tests passed.' : `\n${failures} failed.`);
60process.exit(failures === 0 ? 0 : 1);
moveopenescclose