Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rough fix to allow at-pure optimization for generated thunks that have the pure field set #31012

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

jrevels
Copy link
Member

@jrevels jrevels commented Feb 8, 2019

I'm sure this is a broken implementation, but it fixes JuliaLabs/Cassette.jl#108.

Before this PR:

julia> Base.@pure datatype_align(::Type{T}) where T = T.layout
datatype_align (generic function with 1 method)

julia> function broken(::Type{T}) where {T}
            align = datatype_align(T)
            Val(align)
       end
broken (generic function with 1 method)

julia> using Cassette

julia> Cassette.@context CUDACtx;

julia> const cudactx = Cassette.disablehooks(CUDACtx());

julia> @code_typed Cassette.overdub(cudactx, broken, Float64)
CodeInfo(
1%1 = Base.getfield($(QuoteNode(Float64)), :layout)::Ptr{Nothing}%2 = invoke Cassette.overdub(_2::Cassette.Context{nametype(CUDACtx),Nothing,Nothing,getfield(Cassette, Symbol("##PassType#365")),Nothing,Cassette.DisableHooks}, Main.Val::Type{Val}, %1::Ptr{Nothing})::Any
└──      return %2
) => Any

After this PR:

julia> @code_typed Cassette.overdub(cudactx, broken, Float64)
CodeInfo(
1%1 = Base.getfield($(QuoteNode(Float64)), :layout)::Ptr{Nothing}%2 = invoke Cassette.overdub(_2::Cassette.Context{nametype(CUDACtx),Nothing,Nothing,getfield(Cassette, Symbol("##PassType#365")),Nothing,Cassette.DisableHooks}, Main.Val::Type{Val}, %1::Ptr{Nothing})::Const(Val{Ptr{Nothing} @0x000000011495c010}(), true)
└──      return %2
) => Val{Ptr{Nothing} @0x000000011495c010}


if isdefined(method, :generator)
method.generator.expand_early || return false
mi = code_for_method(method, sig, sparams, sv.params.world, false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should sig here be derived from atypes rather than pulled from the method lookup?

@jrevels
Copy link
Member Author

jrevels commented Feb 25, 2019

Bump?

@ararslan ararslan requested review from JeffBezanson and Keno April 2, 2019 18:48
@vchuravy
Copy link
Member

Would be good to get some eyes on this since this leads to a Cassette performance cliff, since it can circumvent @pure annotations for functions like isbitstype

@ararslan
Copy link
Member

Bump. Anybody?

@jrevels
Copy link
Member Author

jrevels commented Jun 29, 2019

bumpety bump

@vchuravy vchuravy force-pushed the jr/checkgeneratedpure branch from 466b84e to 55c4cdc Compare June 30, 2019 02:39
…pure field set

Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
@vchuravy vchuravy force-pushed the jr/checkgeneratedpure branch from 55c4cdc to 99779db Compare June 30, 2019 03:07
@vchuravy
Copy link
Member

Rebased, added a test and addressed Jameson's comment.

@vchuravy vchuravy merged commit 0eed27e into master Jul 2, 2019
@vchuravy vchuravy deleted the jr/checkgeneratedpure branch July 2, 2019 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@pure seems to cause issues!
4 participants