lattice / quda

QUDA is a library for performing calculations in lattice QCD on GPUs.
https://lattice.github.io/quda
Other
287 stars 94 forks source link

Default tolerance values for fp64 and fp32. #1425

Closed SaltyChiang closed 7 months ago

SaltyChiang commented 7 months ago

There are some default tolerance values for different kernels, for example, https://github.com/lattice/quda/blob/fd50676db06fc36efb3a791a3059c57cca70bb55/include/kernels/gauge_ape.cuh#L11-L12

I used to think they were 10 times the epsilon of fp64 and fp32. But I checked DBL_EPSLON and FLT_EPSLON in float.h:

#define DBL_EPSILON      2.2204460492503131e-016 // smallest such that 1.0+DBL_EPSILON != 1.0
#define FLT_EPSILON      1.192092896e-07F        // smallest such that 1.0+FLT_EPSILON != 1.0

It seems that 2e-15 for double precision and 1e-6 for single precision are more reasonable.

Are these values set intentionally or by accident?

maddyscientist commented 7 months ago

These tolerances are likely arbitrary.

I'm happy to make them 10x epsilon, and also happy to hear others opinions.

@cpviolator @weinbe2 any thoughts in this regard?

cpviolator commented 7 months ago

All good by me!

weinbe2 commented 7 months ago

Seems reasonable as well. I'd guess they came from some old code the QUDA code was based on for some reason even further in the past, but that's irrelevant now.

SaltyChiang commented 7 months ago

These values are set to ~10x epsilon for SU(3) projection in https://github.com/CLQCD/quda/commit/0fc4cb4123531c1b2d40d6cd42a61803ca47f44a.