jrenaud90/CyRK

Had to turn off `fastmath` for `nbrk_ode`

jrenaud90 opened this issue · 2 comments

Prior to v0.5.0, numba's fastmath variable was turned on for nbrk_ode. With the fix to issue #20 in PR #23 we noticed that the standard set of tests would fail on MacOS and Ubuntu systems. It was very random, even rerunning a test without a change in code could cause different results.
Some consistent findings:

  • Tests never failed on Windows.
  • More tests would fail on MacOS vs. Ubuntu.
  • Setting fastmath=False (in CyRK.nb.nbrk at the njit decorator) allowed tests to pass.

PR #23 changed the way minimum step size was calculated. Prior to this change it was set to:

10 * np.finfo(np.float64).eps

now it is set, correctly, to

10. * abs(np.nextafter(t, direction * np.inf) - t)

For small t this value is quite small (5e-323 vs. a EPS of ~1e-16). I believe there is something not playing well between this small value floating around (pun) while fastmath is on. At least on some operating systems.

It is more important that the step size is set correctly so, as of 0.5.0, fastmath is turned off for nbrk_ode there is a slight performance hit with this change.

It varies quite a bit, but this action looks like it hurt nbrk_odes performance by about 3--5% It is still consistently faster than cyrk_ode (by around 3--5x) and scipy (by around 10--100x).

At this point the numba solver is feature complete unless there turns out to be major demand for it. I will continue to maintain the current nbrk but do not intend to expand its abilities at this time.