Closed shipengcheng1230 closed 4 years ago
Yes apparently field access is not managed correctly by the @strided
macro. I will try to fix this asap.
Can you test with the latest version of Strided.jl (0.3.4). This problem should have been resolved.
The latest version works! Thank you!
julia> @btime @strided ff.($A, $bb.b);
47.551 μs (40 allocations: 81.89 KiB)
But I found that the fusion @.
isn't supported (Should this be another issue page?). Following the example above:
julia> c = randn(100, 100);
julia> @btime @strided c .= ff.(A, bb.b); # works!
47.806 μs (42 allocations: 3.84 KiB)
julia> @btime @strided @. c = ff(A, bb.b); # should work as above?
94.127 μs (8 allocations: 144 bytes)
julia> @btime @. c = ff(A, bb.b); # without multithreading
97.249 μs (2 allocations: 48 bytes)
Yes these two macros expand differently, I will have to investigate why:
julia> ex=:(@strided @. c = ff(A, bb.b))
:(#= REPL[11]:1 =# @strided #= REPL[11]:1 =# @__dot__(c = ff(A, bb.b)))
julia> macroexpand(Main, ex)
:(c .= Strided.maybeunstrided.(ff.(Strided.maybestrided.(A), Strided.maybestrided.(bb.b))))
julia> ex = :(@strided c .= ff.(A, bb.b))
:(#= REPL[13]:1 =# @strided c .= ff.(A, bb.b))
julia> macroexpand(Main, ex)
:(Strided.maybestrided(c) .= (Strided.maybestrided(ff)).(Strided.maybestrided(A), Strided.maybestrided(bb.b)))
This makes sense, I guess @strided
sees the expression with the @.
not expanded, so it would need to expand it itself. I will have to refresh my understanding of macros to know how to do that correctly.
I just ran into this @.
issue, and came here to wonder about fixing it. I think it's as simple as inserting ex = macroexpand(__module__, ex)
as the first line of each macro.
Thanks for the fix @mcabbott .
Hi, consider the following MWE:
Also:
So when passing one of the fields in a user-defined struct, it stops to use multithreading. Same thing happens on a Linux machine. Do you have any idea why this happens? Thank you!