Jutho / Strided.jl

A Julia package for strided array views and efficient manipulations thereof
Other
150 stars 13 forks source link

Expand `@.` within `@strided` #11

Closed mcabbott closed 4 years ago

mcabbott commented 4 years ago

xref #10

mcabbott commented 4 years ago

Note aside that tests fail on nightly, with this error:

T = Float32: Error During Test at /Users/me/.julia/dev/Strided/test/runtests.jl:239
  Test threw exception
  Expression: #= /Users/me/.julia/dev/Strided/test/runtests.jl:239 =# @inferred(B1 .+ sin.(B2 .- 3)) ≈ A1 .+ sin.(A2 .- 3)
  MethodError: similar(::Base.Broadcast.Broadcasted{Strided.StridedArrayStyle{2},Tuple{Base.OneTo{Int64},Base.OneTo{Int64}},typeof(sin),Tuple{Base.Broadcast.Broadcasted{Strided.StridedArrayStyle{2},Nothing,typeof(-),Tuple{StridedView{Float32,2,Array{Float32,1},typeof(identity)},Int64}}}}, ::Type{Float32}) is ambiguous. Candidates:
    similar(bc::Base.Broadcast.Broadcasted, ::Type{T}) where T in Base.Broadcast at broadcast.jl:196
    similar(bc::Base.Broadcast.Broadcasted{var"#s62",Axes,F,Args} where Args<:Tuple where F where Axes where var"#s62"<:Strided.StridedArrayStyle{N}, eltype::T) where {N, T} in Strided at /Users/me/.julia/dev/Strided/src/broadcast.jl:18
  Possible fix, define
    similar(::Base.Broadcast.Broadcasted{var"#s62",Axes,F,Args} where Args<:Tuple where F where Axes where var"#s62"<:Strided.StridedArrayStyle{N}, ::T) where {N, T<:(Type{T} where T)}
  Stacktrace:
   [1] copy at ./broadcast.jl:862 [inlined]
   [2] materialize(::Base.Broadcast.Broadcasted{Strided.StridedArrayStyle{2},Nothing,typeof(sin),Tuple{Base.Broadcast.Broadcasted{Strided.StridedArrayStyle{2},Nothing,typeof(-),Tuple{StridedView{Float32,2,Array{Float32,1},typeof(identity)},Int64}}}}) at ./broadcast.jl:837
   [3] macro expansion at /Users/me/.julia/dev/Strided/test/runtests.jl:239 [inlined]
coveralls commented 4 years ago

Coverage Status

Coverage decreased (-4.9%) to 79.739% when pulling 32061f5eaff4f52b7b814369eedf15485c381fbb on mcabbott:expand into 19ab49e4550a04dc66485578c4776375a43780fa on Jutho:master.

Jutho commented 4 years ago

Thanks for this @mcabbott . I will indeed need to look into the nightly problem. Strided.jl would need some proper attention and a proper update to also use the new multithreading strategy since Julia 1.3/1.4. Unfortunately I don't have much time for this currently.

Jutho commented 4 years ago

Looking at the specific nightly problem, I think it is sufficient (but did not test) to change:

function Base.similar(bc::Broadcasted{<:StridedArrayStyle{N}}, eltype::T) where {N,T}
    StridedView(similar(convert(Broadcasted{DefaultArrayStyle{N}}, bc), eltype))
end

to

function Base.similar(bc::Broadcasted{<:StridedArrayStyle{N}}, ::Type{T}) where {N,T}
    StridedView(similar(convert(Broadcasted{DefaultArrayStyle{N}}, bc), T))
end

I will fix this after merging your PR.

Jutho commented 4 years ago

I also have to look into why Travis is no longer reporting in my repos. Or switch to Github actions, but I am still getting used to those and still have to learn how to use them for documentation (not relevant for this package).

mcabbott commented 4 years ago

Thanks! And, strange about the broadcasting, I wonder why that changed.

One thought re threading would be to just copy the macro from https://github.com/JuliaLang/julia/pull/35003, as a direct replacement which uses @spawn.

Jutho commented 4 years ago

Oh, it seems like you're using the new threading @spawn interface, and LoopVectorization, and GPUs, and autodiff, and everything, in Tullio. This looks great. Is there any way in which I could collaborate. I'd love to lower the maintainance costs of my packages, and I am happy to retire them in favour of better alternatives.

mcabbott commented 4 years ago

Apparently I'd like to raise my maintenance costs... but I only learn by building. I think you're doing something smarter about blocking what I wrote, I've yet to understand all of it. But it would indeed be good to share more things, will try to think of ways.

Jutho commented 4 years ago

Where are you located and what is your "day job"? I quickly ran some tests with Tullio, and indeed, I think you can gain some speed with clever blocking strategies. I am not an expert, but gained some experience with it over the years. Unfortunately I have yet to gain experience with all the other things you are already trying (GPU kernels, autodiff, LoopVectorization), but I am definitely interested in all of those and also want to have them, the sooner the better.

Jutho commented 4 years ago

Rereading this (I was typing another comment somewhere else at the same time), my first question comes over very direct and somewhat impolite. I was just trying to learn about your interests and motivations, and indeed, exploring options for collaborations, both in spare time and maybe professionally.

mcabbott commented 4 years ago

No worries, I guess the short answer here is that my "day job" is things like 2002.12060 (for which doing the numerics in Julia was, in the end, probably a terrible choice!) but am also looking for new things.

Jutho commented 4 years ago

Oh, I did not even realise you were a fellow physicist. Are you a PostDoc or PhD student or do you have a permanent position? Anyway, if you are looking for a position that involves Julia programming for applications in high energy physics or condensed matter (using tensor networks, or related ideas, we are also interested in integrability etc), feel free to let me know.

I have some funding and I have been planning to post a job advertisement on the Julia Discourse page, but have been postponing this. I assumed that Corona-time is not the most convenient time for job interviews and hiring etc.