JuliaParallel/Dagger.jl

`@spawn` has confusing move semantics

Open

#357 geöffnet am 9. Sept. 2022

Auf GitHub ansehen
 (8 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Julia (86 Forks)batch import
documentationeager apienhancementhelp wanted

Repository-Metriken

Stars
 (706 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 5h) (4 gemergte PRs in 30 T)

Beschreibung

Note that

◖◗ Dagger.@spawn single=2 println(myid())
EagerThunk (running)

◖◗       From worker 2:        1
◖◗

◖◗ Dagger.spawn(() -> println(myid()), single=2)
EagerThunk (running)

◖◗       From worker 2:        2

I think what's happening here is that in the former case it is evaluating myid() on process 1 and the function executed on worker 2 is just println(1).

This seems like a problem, it's hard to guess that these examples would be different. I suggest that @spawn should match spawn so that its arguments can be read as if it were the function body passed to spawn. Otherwise I think it will need a lot of documentation.

A stronger argument might be that Distributed.@spawnat already works as I'm suggesting:

◖◗ @spawnat 2 println(myid());

◖◗       From worker 2:        2

(My suggestion is clearly badly breaking at least in principle, so this is tricky.)

Contributor Guide