@@ -20,35 +20,59 @@ future_table = Ref(Dict{Future,Integer}())
20
20
21
21
22
22
function Distributed. remotecall (f, node_handle:: Node , args... ; kwargs... )
23
+ cid = cluster_handle. cid
23
24
pid = node_handle. pid
24
- r = remotecall (() -> remotecall (f, pid, args... ; kwargs... ), node_handle . cid)
25
- future_table[][r] = node_handle . cid
25
+ r = remotecall (() -> remotecall (f, pid, args... ; kwargs... ), cid)
26
+ future_table[][r] = cid
26
27
return r
27
28
end
28
29
29
30
function Distributed. remotecall (f, cluster_handle:: Cluster , args... ; kwargs... )
30
- r = remotecall (() -> asyncmap (w -> remotecall (f, w, args... ; kwargs... ), workers (role= :master )), cluster_handle. cid)
31
- future_table[][r] = cluster_handle. cid
31
+ cid = cluster_handle. cid
32
+ wids = workers (cluster_handle)
33
+ r = remotecall (() -> asyncmap (w -> remotecall (f, w, args... ; kwargs... ), wids), cid)
34
+ future_table[][r] = cid
32
35
return r
33
36
end
34
37
38
+ function Distributed. remotecall (f, cluster_handle:: Ctx , args... ; kwargs... )
39
+ cid = cluster_handle. cid
40
+ wids = workers (cluster_handle)
41
+ r = remotecall (() -> asyncmap (w -> remotecall (f, w, args... ; kwargs... ), wids), cid)
42
+ future_table[][r] = cid
43
+ return r
44
+ end
35
45
36
46
37
47
function Distributed. remotecall_fetch (f, node_handle:: Node , args... ; kwargs... )
48
+ cid = cluster_handle. cid
38
49
pid = node_handle. pid
39
- remotecall_fetch (() -> remotecall_fetch (f, pid, args... ; kwargs... ), node_handle . cid)
50
+ remotecall_fetch (() -> remotecall_fetch (f, pid, args... ; kwargs... ), cid)
40
51
end
41
52
42
53
function Distributed. remotecall_fetch (f, cluster_handle:: Cluster , args... ; kwargs... )
43
54
cid = cluster_handle. cid
44
- remotecall_fetch (() -> asyncmap (pid -> remotecall_fetch (f, pid, args... ; kwargs... ), workers (role= :master )), cid)
55
+ wids = workers (cluster_handle)
56
+ remotecall_fetch (() -> asyncmap (pid -> remotecall_fetch (f, pid, args... ; kwargs... ), wids), cid)
45
57
end
46
58
59
+ function Distributed. remotecall_fetch (f, cluster_handle:: Ctx , args... ; kwargs... )
60
+ cid = cluster_handle. cid
61
+ wids = workers (cluster_handle)
62
+ remotecall_fetch (() -> asyncmap (pid -> remotecall_fetch (f, pid, args... ; kwargs... ), wids), cid)
63
+ end
47
64
48
65
function Distributed. remotecall_fetch (reducer, f, cluster_handle:: Cluster , args... ; kwargs... )
49
- remotecall_fetch (() -> reduce (reducer, asyncmap (w -> remotecall_fetch (f, w, args... ; kwargs... ), workers (role= :master ))), cluster_handle. cid)
66
+ cid = cluster_handle. cid
67
+ wids = workers (cluster_handle)
68
+ remotecall_fetch (() -> reduce (reducer, asyncmap (w -> remotecall_fetch (f, w, args... ; kwargs... ), wids)), cid)
50
69
end
51
70
71
+ function Distributed. remotecall_fetch (reducer, f, cluster_handle:: Ctx , args... ; kwargs... )
72
+ cid = cluster_handle. cid
73
+ wids = workers (cluster_handle)
74
+ remotecall_fetch (() -> reduce (reducer, asyncmap (w -> remotecall_fetch (f, w, args... ; kwargs... ), wids)), cid)
75
+ end
52
76
53
77
54
78
function Distributed. remotecall_wait (f, node_handle:: Node , args... ; kwargs... )
@@ -59,8 +83,18 @@ function Distributed.remotecall_wait(f, node_handle::Node, args...; kwargs...)
59
83
end
60
84
61
85
function Distributed. remotecall_wait (f, cluster_handle:: Cluster , args... ; kwargs... )
62
- r = remotecall_wait (() -> asyncmap (w -> remotecall_wait (f, w, args... ; kwargs... ), workers (role= :master )), cluster_handle. cid)
63
- future_table[][r] = cluster_handle. cid
86
+ cid = cluster_handle. cid
87
+ wids = workers (cluster_handle)
88
+ r = remotecall_wait (() -> asyncmap (w -> remotecall_wait (f, w, args... ; kwargs... ), wids), cid)
89
+ future_table[][r] = cid
90
+ return r
91
+ end
92
+
93
+ function Distributed. remotecall_wait (f, cluster_handle:: Ctx , args... ; kwargs... )
94
+ cid = cluster_handle. cid
95
+ wids = workers (cluster_handle)
96
+ r = remotecall_wait (() -> asyncmap (w -> remotecall_wait (f, w, args... ; kwargs... ),wids), cid)
97
+ future_table[][r] = cid
64
98
return r
65
99
end
66
100
@@ -90,7 +124,15 @@ function Distributed.remote_do(f, node_handle::Node, args...; kwargs...)
90
124
end
91
125
92
126
function Distributed. remote_do (f, cluster_handle:: Cluster , args... ; kwargs... )
93
- remote_do (() -> for w in workers (role= :master ) remote_do (f, w, args... ; kwargs... ) end , cluster_handle. cid)
127
+ cid = cluster_handle. cid
128
+ wids = workers (cluster_handle)
129
+ remote_do (() -> for w in wids remote_do (f, w, args... ; kwargs... ) end , cid)
130
+ end
131
+
132
+ function Distributed. remote_do (f, cluster_handle:: Ctx , args... ; kwargs... )
133
+ cid = cluster_handle. cid
134
+ wids = workers (cluster_handle)
135
+ remote_do (() -> for w in wids remote_do (f, w, args... ; kwargs... ) end , cid)
94
136
end
95
137
96
138
# @spawn ???
100
142
macro spawnat_cluster (cluster_handle, arg)
101
143
quote
102
144
cid = $ cluster_handle. cid
103
- f = @spawnat (cid, asyncmap (w-> @spawnat (w, $ arg), workers (role= :master )))
145
+ wids = workers ($ cluster_handle)
146
+ f = @spawnat (cid, asyncmap (w-> @spawnat (w, $ arg), $ wids))
147
+ $ future_table[][f] = cid
148
+ f
149
+ end
150
+ end
151
+
152
+ macro spawnat_context (cluster_handle, arg)
153
+ quote
154
+ cid = $ cluster_handle. cid
155
+ wids = workers ($ cluster_handle)
156
+ f = @spawnat (cid, asyncmap (w-> @spawnat (w, $ arg), $ wids))
104
157
$ future_table[][f] = cid
105
158
f
106
159
end
@@ -120,14 +173,32 @@ end
120
173
macro fetchfrom_cluster (cluster_handle, arg)
121
174
quote
122
175
cid = $ cluster_handle. cid
123
- @fetchfrom (cid, asyncmap (w-> @fetchfrom (w, $ arg), workers (role= :master )))
176
+ wids = workers ($ cluster_handle)
177
+ @fetchfrom (cid, asyncmap (w-> @fetchfrom (w, $ arg), $ wids))
178
+ end
179
+ end
180
+
181
+ macro fetchfrom_context (cluster_handle, arg)
182
+ quote
183
+ cid = $ cluster_handle. cid
184
+ wids = workers ($ cluster_handle)
185
+ @fetchfrom (cid, asyncmap (w-> @fetchfrom (w, $ arg),$ wids))
124
186
end
125
187
end
126
188
127
189
macro fetchfrom_cluster (reducer, cluster_handle, arg)
128
190
quote
129
191
cid = $ cluster_handle. cid
130
- @fetchfrom (cid, reduce ($ reducer, asyncmap (w-> @fetchfrom (w, $ arg), workers (role= :master ))))
192
+ wids = workers ($ cluster_handle)
193
+ @fetchfrom (cid, reduce ($ reducer, asyncmap (w-> @fetchfrom (w, $ arg), $ wids)))
194
+ end
195
+ end
196
+
197
+ macro fetchfrom_context (reducer, cluster_handle, arg)
198
+ quote
199
+ cid = $ cluster_handle. cid
200
+ wids = workers ($ cluster_handle)
201
+ @fetchfrom (cid, reduce ($ reducer, asyncmap (w-> @fetchfrom (w, $ arg), $ wids)))
131
202
end
132
203
end
133
204
0 commit comments