Table of Contents

Floating-point tolerance (2D FDTD)

A floating-point tolerance bounds the difference accepted when comparing numerical results. CPU and GPU updates can round differently, especially when a multiplication and addition are contracted into a single operation. Small differences can accumulate over many time steps.

The CUDA comparison tests measure the largest absolute difference relative to the largest reference magnitude:

$$ d=\frac{\max_k|u_k-v_k|}{\max_k|u_k|},\qquad d\leq T\epsilon N $$

Here $u$ is the serial result, $v$ is the CUDA result, $\epsilon$ is the machine epsilon of the field type, $N$ is the number of steps, and $T$ is the build-configured tolerance factor. When the reference is entirely zero, the test uses the largest absolute difference directly.

This is a bound on the compared array as a whole, rather than a separate relative error at every sample. It checks agreement with the serial calculation; it does not measure physical accuracy. The exact build provides a stricter comparison under controlled rounding conditions.