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...)
367
367
_par (ex; lazy= false , opts= opts)
368
368
end
369
369
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
+
370
381
function _par (ex:: Expr ; lazy= true , recur= true , opts= ())
371
382
if ex. head == :call && recur
372
- f = ex. args[1 ]
383
+ f = replace_broadcast ( ex. args[1 ])
373
384
args = ex. args[2 : end ]
374
385
opts = esc .(opts)
375
386
if lazy
Original file line number Diff line number Diff line change 61
61
@test fetch (c) == 20
62
62
end
63
63
@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
64
69
@testset " waiting" begin
65
70
a = @spawn sleep (1 )
66
71
@test ! isready (a)
You can’t perform that action at this time.
0 commit comments