@@ -78,23 +78,31 @@ Base.hash(d::DArray, h::UInt) = Base.hash(d.id, h)
78
78
# # core constructors ##
79
79
80
80
function DArray (id, init, dims, pids, idxs, cuts)
81
- r= Channel (1 )
81
+ localtypes = Vector {DataType} (undef,length (pids))
82
+
82
83
@sync begin
83
84
for i = 1 : length (pids)
84
85
@async begin
85
86
local typA
86
87
if isa (init, Function)
87
- typA= remotecall_fetch (construct_localparts, pids[i], init, id, dims, pids, idxs, cuts)
88
+ typA = remotecall_fetch (construct_localparts, pids[i], init, id, dims, pids, idxs, cuts)
88
89
else
89
90
# constructing from an array of remote refs.
90
- typA= remotecall_fetch (construct_localparts, pids[i], init[i], id, dims, pids, idxs, cuts)
91
+ typA = remotecall_fetch (construct_localparts, pids[i], init[i], id, dims, pids, idxs, cuts)
91
92
end
92
- ! isready (r) && put! (r, typA)
93
+ localtypes[i] = typA
93
94
end
94
95
end
95
96
end
96
97
97
- A = take! (r)
98
+ if length (unique (localtypes)) != 1
99
+ @sync for p in pids
100
+ @async remotecall_fetch (release_localpart, p, id)
101
+ end
102
+ throw (ErrorException (" Constructed localparts have different `eltype`: $(localtypes) " ))
103
+ end
104
+ A = first (localtypes)
105
+
98
106
if myid () in pids
99
107
d = registry[id]
100
108
d = isa (d, WeakRef) ? d. value : d
0 commit comments