Skip to content

Commit 0477de4

Browse files
authored
Merge pull request #171 from JuliaParallel/vc/rand
add rand! for DArrays
2 parents 2ee6c28 + 5acbcf3 commit 0477de4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/darray.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,3 +784,12 @@ function Base.fill!(A::DArray, x)
784784
end
785785
return A
786786
end
787+
788+
using Random
789+
790+
function Random.rand!(rng::AbstractRNG, A::DArray, ::Type{T}) where T
791+
asyncmap(procs(A)) do p
792+
remotecall_wait((rng, A, T)->rand!(rng, localpart(A), T), p, rng, A, T)
793+
end
794+
end
795+

test/darray.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Test, LinearAlgebra, SpecialFunctions
22
using Statistics: mean
33
using SparseArrays: nnz
4+
using Random
45
@everywhere using SparseArrays: sprandn
56

67
@testset "test distribute and other constructors" begin
@@ -988,6 +989,13 @@ check_leaks()
988989
close(d)
989990
end
990991

992+
@testset "rand!" begin
993+
d = dzeros(30, 30)
994+
rand!(d)
995+
996+
close(d)
997+
end
998+
991999
check_leaks()
9921000

9931001
d_closeall()

0 commit comments

Comments
 (0)