Closed lnarmour closed 3 months ago
After looking more, this behaviour is due to float-point round off errors. The new code generator defaults the data type to 32-bit float but the epsilon used by the old wrapper, 1e-9 (it assumes doubles 64-bit floats are used), is too small. We could probably change the epsilon to be a function of the data type, but this still isn’t perfect since floating point noise is largely dependent on the particular program and the range of computed values.
This is indirectly addressed by PR #64.
If/when you notice that verification reports wrong answers, you should try rerunning everything with exact precision (i.e., int
or long
data types) and retesting with a small problem size (being careful about overflow issues). This will let you rule in/out FP round-off errors as the root cause.
Indeed. Floating point arithmetic is not associative, so strictly speaking, we should not be using this data type. We should state this at he outset (and possibly provide a nasty reviewer the ammunition they need to reject our papers :-)
Take the following two programs, which should be equivalent:
The second was obtained by calling ReductionDecomposition on the first.
issue
Now, using the acc script v1.1, generate new (v2) writeC code, the old makefile, wrapper and verification code with the following command:
Run the verification code to compare the new writeC code (for post.alpha) with the old writeC code (for pre.alpha) and observe that there are errors:
no issue for new and old writeC from same input
Now generate new and old writeC from the same input, either both pre.alpha or both post.alpha, run the verification code and observer no errors:
problem
I think the problem is with the ReductionDecomposition step. Apparently, the programs pre.alpha and post.alpha are not the same, when they should be. I don’t think the issue is with the code generator, since codegen for either pre.alpha or post.alpha individually compute the same result as old alphaz (unless the same bug is also present in old alphaz, which seems unlikely).