Skip to content

Commit 850e790

Browse files
authored
Fix return code in tests and fix tests (#62)
* Add number of test failures instaed of computing the bitwise and of them * Fix tests * Fix conversion from distributed vector to local Julia matrix such that each worker gets a copy of the distribted matrix. Also, fix seed in TSVD tests to avoid different seeds on each worker * Add Random to test dependencies
1 parent a260810 commit 850e790

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ julia = "1"
2020
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
2121
MPIClusterManagers = "e7922434-ae4b-11e9-05c5-9780451d2c66"
2222
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
23-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
23+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2424
TSVD = "9449cd9e-2762-5aa3-a617-5413e99d722e"
25+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2526

2627
[targets]
27-
test = ["Test", "MPI", "MPIClusterManagers", "Primes", "TSVD"]
28+
test = ["Test", "MPI", "MPIClusterManagers", "Primes", "TSVD", "Random"]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ julia> man = MPIManager(np = 4);
9393

9494
julia> addprocs(man);
9595

96-
julia> @mpi_do man using Elemental, TSVD
96+
julia> @mpi_do man using Elemental, TSVD, Random
9797

9898
julia> @mpi_do man A = Elemental.DistMatrix(Float64);
9999

100100
julia> @mpi_do man Elemental.gaussian!(A, 5000, 2000);
101101

102+
julia> @mpi_do man Random.seed!(123) # to avoid different initial vectors on the workers
103+
102104
julia> @mpi_do man r = tsvd(A, 5);
103105

104106
julia> @mpi_do man println(r[2][1:5])

src/julia/generic.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ Base.copyto!(dest::DistMatrix, src::ElementalMatrix) = _copy!(src, dest)
106106

107107
function Base.copyto!(dest::Base.VecOrMat, src::DistMatrix{T}) where {T}
108108
m, n = size(src, 1), size(src, 2)
109-
if MPI.commRank(comm(src)) == 0
109+
# if MPI.commRank(comm(src)) == 0
110110
for j = 1:n
111111
for i = 1:m
112112
queuePull(src, i, j)
113113
end
114114
end
115-
end
115+
# end
116116
dest_mat = ndims(dest) == 1 ? reshape(dest, :, 1) : dest
117117
processPullQueue(src, dest_mat)
118118
return dest
@@ -176,8 +176,8 @@ function Base.convert(::Type{DistMatrix{T}}, A::DistMultiVec{T}) where {T}
176176
return B
177177
end
178178

179-
Base.convert(::Type{Array}, xd::DistMatrix{T}) where {T} =
180-
Base.copyto!(Base.zeros(T, size(xd)), xd)
179+
Base.convert(::Type{Array}, xd::DistMatrix{T}) where {T} =
180+
copyto!(Base.zeros(T, size(xd)), xd)
181181

182182
Base.Array(xd::DistMatrix) = convert(Array, xd)
183183

test/generic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64})
66
Elemental.gaussian!(A, 10)
77
@test convert(Elemental.DistMatrix{T}, ones(T, 5)) == ones(5,1)
88
B = Elemental.DistMatrix(T)
9-
Array(copy!(B, T[2 1; 1 2])) == T[2 1; 1 2]
9+
Array(copyto!(B, T[2 1; 1 2])) == T[2 1; 1 2]
1010
end

test/lavdense.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ end
104104
for T in (Float32, Float64)
105105
A = El.DistMatrix(T)
106106
b = El.DistMatrix(T)
107-
copy!(A, T[2 1; 1 2])
108-
copy!(b, T[4, 5])
107+
copyto!(A, T[2 1; 1 2])
108+
copyto!(b, T[4, 5])
109109
x = Array(El.leastSquares(A, b))
110110
if worldRank == 0
111111
@test isapprox(x, T[1, 2])

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function runtests_repl()
5151
end
5252

5353
function runtests()
54-
return runtests_mpirun() & runtests_repl()
54+
return runtests_mpirun() + runtests_repl()
5555
end
5656

5757
exit(runtests())

test/tsvd.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
using Elemental, TSVD, LinearAlgebra
2-
1+
using Elemental, TSVD, LinearAlgebra, Test
2+
using Random
33
A = Elemental.DistMatrix(Float64)
44
Elemental.gaussian!(A, 500, 200)
5+
6+
# Warning! If seed is not set, each worker will end up with a different initial vector
7+
# making the Lanczos processes inconsistent
8+
Random.seed!(123)
59
vals_Elemental = tsvd(A, 5)[2]
6-
vals_LAPACK = svdvals(convert(Array, A))[1:5]
10+
localA = Array(A)
11+
vals_LAPACK = svdvals(localA)[1:5]
712
@test vals_Elemental vals_LAPACK

0 commit comments

Comments
 (0)