5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 1// The result-file format committed to the fastandaccurate-results repo.
2// One file holds one work-precision sweep: one problem instance, one
3// solver, one environment.
5import {
6 canonicalSpec,
7 canonicalSpecJson,
8 PROBLEM_ID,
9 PROBLEM_VERSION,
10 type Laplace2dInstance,
11} from "../problems/laplace2d/spec";
12import type { RunPoint } from "./runner";
ad5dc23Three new instances, near-field target sets, and an adaptive timing policyJeremy Magland 13import type { TimingPolicy } from "./timing";
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 14
15export const RESULT_FORMAT = "fastandaccurate-result";
16export const RESULT_FORMAT_VERSION = 1;
18export interface ResultEnvironment {
e58e208chunkie-dlp runs in real MATLAB via the CLI; solver runtime field, matlab -batch harnessJeremy Magland 19 kind: "browser" | "node" | "matlab";
20 /** User agent (browser), node version (node), or MATLAB version. */
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 21 runtime: string;
e58e208chunkie-dlp runs in real MATLAB via the CLI; solver runtime field, matlab -batch harnessJeremy Magland 22 /** Absent for runs outside numbl (e.g. real MATLAB). */
23 numblVersion?: string;
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 24 os?: string;
25 cpu?: string;
26 /** Free-text label a human recognizes ("office workstation"). */
27 machineLabel?: string;
28 /** Whether a visitor can rerun this result in the browser. */
29 browserReproducible: boolean;
30}
32export interface ResultPoint {
33 n: number;
2f05269Connect work-precision curves by resolution, not time; strengthen the timing protocolJeremy Magland 34 /** The fastest of the timed runs. */
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 35 solveSeconds: number;
36 solveSecondsAll: number[];
37 coldSeconds: number;
38 relMax: number;
39 relL2: number;
40}
42export interface ResultFile {
43 format: typeof RESULT_FORMAT;
44 formatVersion: typeof RESULT_FORMAT_VERSION;
45 problem: string;
46 problemVersion: number;
47 instance: string;
48 spec: Record<string, unknown>;
49 specHash: string;
50 solver: {
51 id: string;
52 version: string;
53 backend: "cpu" | "gpu";
54 /** "builtin" for solvers in the fastandaccurate repo; otherwise a
55 * URL or free-text pointer to the solver's source. */
56 source: string;
57 };
58 environment: ResultEnvironment;
59 protocol: {
60 warmupRuns: number;
ad5dc23Three new instances, near-field target sets, and an adaptive timing policyJeremy Magland 61 /** The adaptive timed-run policy: at least minTimedRuns runs, then as
62 * many more as fit in timeBudgetSeconds, never past maxTimedRuns. How
63 * many a given point actually ran is the length of its
64 * solveSecondsAll. */
65 minTimedRuns: number;
66 timeBudgetSeconds: number;
67 maxTimedRuns: number;
2f05269Connect work-precision curves by resolution, not time; strengthen the timing protocolJeremy Magland 68 /** Which statistic of the timed runs is reported as solveSeconds. */
69 statistic: "min";
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 70 timer: string;
ad5dc23Three new instances, near-field target sets, and an adaptive timing policyJeremy Magland 71 /** Results written before the adaptive policy carry a fixed count
72 * here instead of the three fields above. */
73 timedRuns?: number;
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 74 };
75 createdUtc: string;
76 points: ResultPoint[];
77}
79/** SHA-256 hex digest, using WebCrypto (browser, worker, node >= 20). */
80export async function sha256Hex(text: string): Promise<string> {
81 const digest = await crypto.subtle.digest(
82 "SHA-256",
83 new TextEncoder().encode(text)
84 );
85 return Array.from(new Uint8Array(digest))
86 .map((b) => b.toString(16).padStart(2, "0"))
87 .join("");
88}
90export function toResultPoint(p: RunPoint): ResultPoint {
91 return {
92 n: p.n,
93 solveSeconds: p.solveSeconds,
94 solveSecondsAll: p.solveSecondsAll,
95 coldSeconds: p.coldSeconds,
96 relMax: p.relMax,
97 relL2: p.relL2,
98 };
99}
101export async function buildResultFile(opts: {
102 instance: Laplace2dInstance;
103 solver: { id: string; version: string; backend: "cpu" | "gpu"; source: string };
104 environment: ResultEnvironment;
ad5dc23Three new instances, near-field target sets, and an adaptive timing policyJeremy Magland 105 timing: TimingPolicy;
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 106 points: ResultPoint[];
e58e208chunkie-dlp runs in real MATLAB via the CLI; solver runtime field, matlab -batch harnessJeremy Magland 107 /** What measured the times (default numbl tic/toc). */
108 timer?: string;
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 109}): Promise<ResultFile> {
110 return {
111 format: RESULT_FORMAT,
112 formatVersion: RESULT_FORMAT_VERSION,
113 problem: PROBLEM_ID,
114 problemVersion: PROBLEM_VERSION,
115 instance: opts.instance.id,
116 spec: canonicalSpec(opts.instance) as unknown as Record<string, unknown>,
117 specHash: await sha256Hex(canonicalSpecJson(opts.instance)),
118 solver: opts.solver,
119 environment: opts.environment,
120 protocol: {
2f05269Connect work-precision curves by resolution, not time; strengthen the timing protocolJeremy Magland 121 warmupRuns: 2,
ad5dc23Three new instances, near-field target sets, and an adaptive timing policyJeremy Magland 122 minTimedRuns: opts.timing.minTimedRuns,
123 timeBudgetSeconds: opts.timing.timeBudgetSeconds,
124 maxTimedRuns: opts.timing.maxTimedRuns,
2f05269Connect work-precision curves by resolution, not time; strengthen the timing protocolJeremy Magland 125 statistic: "min",
e58e208chunkie-dlp runs in real MATLAB via the CLI; solver runtime field, matlab -batch harnessJeremy Magland 126 timer: opts.timer ?? "numbl tic/toc",
5127df5fastandaccurate: PDE solver benchmarks, laplace-dirichlet-2d with MFS and Nystrom DLP solversJeremy Magland 127 },
128 createdUtc: new Date().toISOString(),
129 points: opts.points,
130 };
131}