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

Fix nthreads on 1.9 (failure in the presence of interactive threads) #496

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

IanButterworth
Copy link
Contributor

Currently NNlib threaded functions fail if julia is sstarted with > 0 threads in the :interactive threadpool.

Here julia had -t2,1

BoundsError: attempt to access 196608×9×2 Array{Float32, 3} at index [1:196608, 1:9, 3]
        Stacktrace:
         [1] throw_boundserror(A::Array{Float32, 3}, I::Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Int64})
           @ Base ./abstractarray.jl:744
         [2] checkbounds
           @ ./abstractarray.jl:709 [inlined]
         [3] view
           @ ./subarray.jl:177 [inlined]
         [4] macro expansion
           @ ~/.julia/packages/NNlib/Jmwx0/src/impl/conv_im2col.jl:49 [inlined]
         [5] (::NNlib.var"#1110#threadsfor_fun#635"{NNlib.var"#1110#threadsfor_fun#634#636"{Array{Float32, 3}, Float32, Float32, SubArray{Float32, 5, Array{Float32, 5}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, SubArray{Float32, 5, Array{Float32, 5}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, SubArray{Float32, 5, Array{Float32, 5}, Tuple{Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}}, true}, NNlib.DenseConvDims{3, 3, 3, 6, 3}, Int64, Int64, Int64, UnitRange{Int64}}})(tid::Int64; onethread::Bool)

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

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

Thanks! Do you know if any NNlib code also suffers from the threadid cache + non-sticky task issue?

@IanButterworth
Copy link
Contributor Author

I have no idea. Worth checking

@CarloLucibello CarloLucibello merged commit e5cff84 into FluxML:master Jun 14, 2023
@IanButterworth IanButterworth deleted the ib/19_nthreads branch June 14, 2023 21:04
@IanButterworth
Copy link
Contributor Author

Just for the future, it's a little painful that this wasn't merged and released as a patch before #492 given that prompted 0.9.0

@CarloLucibello
Copy link
Member

yes, I realized that 30 seconds too late, sorry. I will make a backport in a few hours

CarloLucibello pushed a commit that referenced this pull request Jun 15, 2023
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.

3 participants