Frontory

Open code, practice, and notes →

Download source with English comments · for reading

WebGPU · 25 CPU References and Error Budgets

Series contents · Technology map

Stage: Recovery, Measurement, and an Integrated Project · Editable example · Storage ID: webgpu-step-25

Goals and learning outcomes

Prerequisites

Continue using the output and notes from unit 24. Preserve the previous inputs and reference outputs before the CPU References and Error Budgets experiment.

Key concepts and explanations

Floating Point

CPU JavaScript number and GPU f32 operations have different precision. Summation with a different association order can produce small errors.

Validation Criteria

Absolute and relative error serve different roles depending on magnitude. Define tolerances and special-value handling before viewing results.

Practice setup

First read the execution-scope guidance on the example screen. The following preparation is for extending the assignment in a separate project. This is a document-guided exercise to implement yourself in a separate localhost or HTTPS project. Check the secure context, navigator.gpu, and adapter request result, and provide an unsupported-environment message. Preserve device.lost handling and resource release.

The linked example is a starting point. It does not implement every task below. Complete work beyond its supported scope in a separate project.

Practice tasks

  1. In reference.js, write a CPU particle-update function and generate fixed-seed inputs.
  2. Calculate per-element absolute and relative errors against the readback result.
  3. For inputs containing 0, negative, small, and large values, print the maximum error and failing indices.

Variables to observe

VariableBaselineChangeExpected change / hypothesis
Validation inputSmall positive valuesMix of 0, negative, and large valuesInputs of different magnitudes are expected to expose limitations of a relative-error-only criterion.

Predictions in this table are not measured results. Change one condition at a time and record why the actual result differs.

Completion criteria

Self-check

  1. Which tasks require exactly identical bit results?
  2. Can including NaN in error comparisons allow a check to pass?

Official references

Linked example and execution scope

Example source · Runtime environments and limits

Runs real WebGPU/WGSL. Requires HTTPS/localhost and a supported adapter; unsupported environments display a reason, and CPU results are not substituted for GPU results.

Source code and records are not overwritten automatically. Resetting an existing example also preserves your notes.

Next learning

Previous: The Scope of Timing · Next: Workgroup Size Experiments

Open code, practice, and notes →