rft: make gamma(a,x) GPU compatible#520
Open
haakon-e wants to merge 1 commit intoJuliaMath:masterfrom
Open
Conversation
- improve type stability for En_expand_origin_general, En_safe_expfact, En_expand_origin - this improves type stability for expint(a, x) and thus gamma(a, x) - make gamma(n::Int) for n>20 call gamma(Float64(n)) for compatibility with CUDA.jl's device override of the gamma function - manually inline single recursion in _zeta, _trigamma - modify while loop in _expint to guarantee termination - add related tests
03fbbfd to
734535b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #520 +/- ##
==========================================
+ Coverage 94.17% 94.19% +0.01%
==========================================
Files 14 14
Lines 2971 2980 +9
==========================================
+ Hits 2798 2807 +9
Misses 173 173
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request refactors
src/expint.jl,src/gamma.jlto make the upper incomplete gamma functiongamma(a, x)GPU-compatible (verified on NVIDIA A100).Summary of changes
src/expint.jl:En_expand_origin_general,En_safe_expfact,En_expand_originto ensure their return types are consistent with the least precise floating point type of eitheraorx. These functions are conditionally used bygamma(a,x)through the call chain:fn -> En_expand_origin -> _expint -> expint -> _gamma(a,x) -> gamma(a,x)gamma(a,x)with complex arguments, so would appreciate an extra pair of eyes to verify that the way I get the floating point typeFTfrom the arguments is reasonable._expint.src/gamma.jl:_trigammaand_zeta(similar to what I did in rft: makegamma_inc,gamma_inc_invGPU-compatible #514)gamma(n::Union{Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64})to callgamma(Float64(n))instead of_gamma(Float64(n))whenevern > 20. This subtle change allows the CUDA.jl device override forgammato work for this method.test/gamma_inc.jl:gamma(a, x)is type stable and allocation-free.gamma(a,x)indeed do not allocate. I haven't done that in this PR