File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -367,9 +367,20 @@ macro spawn(exs...)
367367 _par (ex; lazy= false , opts= opts)
368368end
369369
370+ struct ExpandedBroadcast{F} end
371+ (eb:: ExpandedBroadcast{F} )(args... ) where F =
372+ Base. materialize (Base. broadcasted (F, args... ))
373+ replace_broadcast (ex) = ex
374+ function replace_broadcast (fn:: Symbol )
375+ if startswith (string (fn), ' .' )
376+ return :($ ExpandedBroadcast {$(Symbol(string(fn)[2:end]))} ())
377+ end
378+ return fn
379+ end
380+
370381function _par (ex:: Expr ; lazy= true , recur= true , opts= ())
371382 if ex. head == :call && recur
372- f = ex. args[1 ]
383+ f = replace_broadcast ( ex. args[1 ])
373384 args = ex. args[2 : end ]
374385 opts = esc .(opts)
375386 if lazy
Original file line number Diff line number Diff line change 6161 @test fetch (c) == 20
6262 end
6363 @test Dagger. Sch. EAGER_CONTEXT[] isa Context
64+ @testset " broadcast" begin
65+ A, B = rand (4 ), rand (4 )
66+ @test fetch (@spawn A .+ B) ≈ A .+ B
67+ @test fetch (@spawn A .* B) ≈ A .* B
68+ end
6469 @testset " waiting" begin
6570 a = @spawn sleep (1 )
6671 @test ! isready (a)
You can’t perform that action at this time.
0 commit comments