NaNMath.jl icon indicating copy to clipboard operation
NaNMath.jl copied to clipboard

Teach julia that `NaNMath` functions don't have effects

Open oscardssmith opened this issue 2 years ago • 6 comments

This allows constant folding and dead code elimination on Julia 1.8 and up.

oscardssmith avatar Aug 02 '23 17:08 oscardssmith

Codecov Report

Patch coverage: 80.00% and project coverage change: +0.02% :tada:

Comparison is base (d5ea765) 97.05% compared to head (d51c509) 97.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
+ Coverage   97.05%   97.08%   +0.02%     
==========================================
  Files           1        1              
  Lines         102      103       +1     
==========================================
+ Hits           99      100       +1     
  Misses          3        3              
Files Changed Coverage Δ
src/NaNMath.jl 97.08% <80.00%> (+0.02%) :arrow_up:

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 02 '23 17:08 codecov[bot]

I'm not the right person to review this.

ViralBShah avatar Aug 07 '23 13:08 ViralBShah

This needs a review from someone who understands @assume_effects

mlubin avatar Aug 14 '23 23:08 mlubin

I've talked to @vtjnash about this a bit and he thinks that libm might be leaking effectful information (rounding modes and signals) but I haven't been able to find observe this.

oscardssmith avatar Aug 14 '23 23:08 oscardssmith

In particular, note that C documentation for these explicitly states these are not pure due to side effects.

vtjnash avatar Aug 15 '23 00:08 vtjnash

however the two areas of impurity (rounding modes and flags) appear not to be accessible from julia (or at least I haven't been able to observe the impurity)

oscardssmith avatar Aug 15 '23 00:08 oscardssmith