Skip to content

Commit 0bd7be0

Browse files
authored
Merge pull request #45 from JuliaParallel/an/one
Updates for Julia 1.0
2 parents fc534b9 + 45b96a3 commit 0bd7be0

39 files changed

Lines changed: 515 additions & 499 deletions

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ os:
1010
- linux
1111

1212
julia:
13-
- 0.6
14-
- nightly
13+
- 0.7
14+
- 1.0
15+
# - nightly
1516

1617
matrix:
1718
allow_failures:
@@ -56,8 +57,9 @@ install:
5657
- export CPU_CORES=2
5758
- sh ./mpi.sh $MPI > /dev/null
5859
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
59-
- julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("Elemental")'
60+
- while sleep 30; do tail ./deps/build.log -f ; done &
61+
- julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Elemental")'
6062
- echo `ccache -s`
6163

6264
script:
63-
- julia --check-bounds=yes -e 'Pkg.test("Elemental")'
65+
- julia --check-bounds=yes -e 'using Pkg; Pkg.test("Elemental")'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ The install script will build against any MPI installation that can be detected
1414

1515
### Simple example without MPI
1616
```jl
17-
julia> using Elemental
17+
julia> using LinearAlgebra, Elemental
1818

1919
julia> A = Elemental.Matrix(Float64)
2020
0x0 Elemental.Matrix{Float64}
2121

2222
julia> Elemental.gaussian!(A, 100, 80);
2323

24-
julia> U, s, V = Elemental.svd(A);
24+
julia> U, s, V = svd(A);
2525

2626
julia> convert(Matrix{Float64}, s)[1:10]
2727
10-element Array{Float64,1}:
@@ -46,7 +46,7 @@ julia> man = MPIManager(np = 4);
4646

4747
julia> addprocs(man);
4848

49-
julia> using Elemental
49+
julia> using LinearAlgebra, Elemental
5050

5151
julia> @mpi_do man A = Elemental.DistMatrix(Float64);
5252

REQUIRE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
julia 0.6
2-
Compat 0.31.0
3-
DistributedArrays 0.4.0
1+
julia 0.7
2+
DistributedArrays 0.5

deps/build.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import Libdl, LibGit2, LinearAlgebra
2+
13
# Use this version of Elemental
24
Elsha = "79987d38b04838acf6b6195be1967177521ee908"
35

4-
using Compat
5-
6-
if is_windows()
6+
if Sys.iswindows()
77
error("Elemental only works on Unix Platforms")
88
end
99

@@ -26,12 +26,12 @@ cd(srcdir) do
2626
LibGit2.checkout!(LibGit2.GitRepo("."), "$Elsha")
2727
end
2828

29-
BLAS.check()
30-
blas = BLAS.vendor()
31-
mathlib = Libdl.dlpath(BLAS.libblas)
32-
blas64 = LinAlg.USE_BLAS64 ? "ON" : "OFF"
29+
LinearAlgebra.BLAS.check()
30+
blas = LinearAlgebra.BLAS.vendor()
31+
mathlib = Libdl.dlpath(LinearAlgebra.BLAS.libblas)
32+
blas64 = LinearAlgebra.USE_BLAS64 ? "ON" : "OFF"
3333
blas_suffix = blas === :openblas64 ? "_64_" : "_"
34-
build_procs = (haskey(ENV, "CI") && ENV["CI"] == "true") ? 2 : Sys.CPU_CORES
34+
build_procs = (haskey(ENV, "CI") && ENV["CI"] == "true") ? 2 : Sys.CPU_THREADS
3535

3636
builddir = joinpath(depdir, "builds")
3737
if isdir(builddir)
@@ -54,3 +54,4 @@ cd(builddir) do
5454
run(`make -j $build_procs`)
5555
run(`make install`)
5656
end
57+
GC.gc() # work-around for https://github.com/JuliaLang/julia/issues/28306

extras/elpp.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ finalize() = icxx"El::Finalize();"
2929
### ElementalMatrix ###
3030
# Many of the definitions in Elemental are very similar which makes it easy to define methods for a common abstract type. However, we should be careful when calling into the library with e.g. @cxx or icxx because all leaf types might not implement the actual method.
3131

32-
@compat abstract type ElementalMatrix{T} <: AbstractMatrix{T} end
32+
abstract type ElementalMatrix{T} <: AbstractMatrix{T} end
3333

3434
_getindex(A::ElementalMatrix, i::ElInt, j::ElInt) = icxx"$(A.buf).Get($i, $j);"
3535
getindex(A::ElementalMatrix, i::Integer, j::Integer) = _getindex(A, ElInt(i - 1), ElInt(j - 1))
@@ -63,16 +63,16 @@ end
6363
svdvals(A::ElementalMatrix) = svdvals!(copy(A))
6464

6565
### AbstractDistMatrix ###
66-
@compat abstract type AbstractDistMatrix{T} <: ElementalMatrix{T} end
66+
abstract type AbstractDistMatrix{T} <: ElementalMatrix{T} end
6767

6868
_resize!(A::AbstractDistMatrix, i::ElInt, j::ElInt) = icxx"$(A.buf).Resize($i, $j);"
6969
resize!(A::AbstractDistMatrix, i::Integer, j::Integer) = _resize!(A, ElInt(i), ElInt(j))
7070

7171
_reserve(A::AbstractDistMatrix, n::ElInt) = icxx"$(A.buf).Reserve($n);"
7272
reserve(A::AbstractDistMatrix, n::Integer) = _reserve(A, ElInt(n))
7373

74-
_queueUpdate{T}(A::AbstractDistMatrix{T}, i::ElInt, j::ElInt, x::T) = icxx"$(A.buf).QueueUpdate($i, $j, $x);"
75-
queueUpdate{T}(A::AbstractDistMatrix{T}, i::Integer, j::Integer, x) = _queueUpdate(A, ElInt(i - 1), ElInt(j - 1), T(x))
74+
_queueUpdate(A::AbstractDistMatrix{T}, i::ElInt, j::ElInt, x::T) where {T} = icxx"$(A.buf).QueueUpdate($i, $j, $x);"
75+
queueUpdate(A::AbstractDistMatrix{T}, i::Integer, j::Integer, x) where {T} = _queueUpdate(A, ElInt(i - 1), ElInt(j - 1), T(x))
7676

7777
processQueues!(A::AbstractDistMatrix) = icxx"$(A.buf).ProcessQueues();"
7878

@@ -81,7 +81,7 @@ zeros!(A::AbstractDistMatrix, m::Integer = size(A,1), n::Integer = size(A,2)) =
8181

8282
### Matrix ###
8383

84-
immutable Matrix{T} <: ElementalMatrix{T}
84+
struct Matrix{T} <: ElementalMatrix{T}
8585
# buf::Cxx.CppValue{Cxx.CxxQualType{Cxx.CppTemplate{Cxx.CppBaseType{symbol("El::Matrix")},Tuple{T}},(false,false,false)},56}
8686
buf::Any
8787
end
@@ -91,7 +91,7 @@ convert(::Type{Matrix{Float64}}, m::ElInt = 0, n::ElInt = 0) = Matrix{Float64}(i
9191

9292
_randn!(A::Matrix, i::ElInt, j::ElInt) = icxx"Gaussian($(A.buf), $i, $j);"
9393

94-
function svdvals!{T}(A::Matrix{T})
94+
function LinearAlgebra.svdvals!(A::Matrix{T}) where {T}
9595
s = Matrix{T}(min(size(A)...),1)
9696
@cxx El::SVD(A.buf, s.buf)
9797
return s
@@ -101,7 +101,7 @@ end
101101

102102
# DistMatrix
103103

104-
immutable DistMatrix{T,U,V} <: AbstractDistMatrix{T}
104+
struct DistMatrix{T,U,V} <: AbstractDistMatrix{T}
105105
# buf::Cxx.CppValue{Cxx.CxxQualType{Cxx.CppTemplate{Cxx.CppBaseType{symbol("El::DistMatrix")},Tuple{T,U,V,U}},(false,false,false)},144}
106106
buf::Any
107107
end
@@ -115,18 +115,18 @@ convert(::Type{Cxx.CppEnum{symbol("El::DistWrapNS::DistWrap")}}, x::Int) = Cxx.C
115115

116116
convert(::Type{DistMatrix{Float32,MC,MR}}, m::ElInt = 0, n::ElInt = 0) = DistMatrix{Float32,MC,MR}(icxx"El::DistMatrix<float,El::MC,El::MR>($m,$n);")
117117
convert(::Type{DistMatrix{Float64,MC,MR}}, m::ElInt = 0, n::ElInt = 0) = DistMatrix{Float64,MC,MR}(icxx"El::DistMatrix<double,El::MC,El::MR>($m,$n);")
118-
convert{T}(::Type{DistMatrix{T}}, m::ElInt = 0, n::ElInt = 0) = DistMatrix{T,MC,MR}(m, n)
118+
convert(::Type{DistMatrix{T}}, m::ElInt = 0, n::ElInt = 0) where {T} = DistMatrix{T,MC,MR}(m, n)
119119

120120
_randn!(A::DistMatrix, i::ElInt, j::ElInt) = icxx"Gaussian($(A.buf), $i, $j);"
121121

122-
function svdvals!{T}(A::DistMatrix{T})
122+
function LinearAlgebra.svdvals!(A::DistMatrix{T}) where {T}
123123
s = DistMatrix{T}(min(size(A)...),1)
124124
@cxx El::SVD(A.buf, s.buf)
125125
return s
126126
end
127127

128128
# DistSparseMatrix
129-
immutable DistSparseMatrix{T} <: AbstractDistMatrix{T}
129+
struct DistSparseMatrix{T} <: AbstractDistMatrix{T}
130130
buf::Any
131131
end
132132

@@ -136,16 +136,16 @@ convert(::Type{DistSparseMatrix{Float64}}, m::ElInt = 0, n::ElInt = 0) = DistSpa
136136
processLocalQueues!(A::DistSparseMatrix) = icxx"$(A.buf).ProcessLocalQueues();"
137137

138138
# DistMultiVec
139-
immutable DistMultiVec{T} <: AbstractDistMatrix{T}
139+
struct DistMultiVec{T} <: AbstractDistMatrix{T}
140140
buf::Any
141141
end
142142

143143
convert(::Type{DistMultiVec{ElInt}}, m::ElInt = 0, n::ElInt = 0) = DistMultiVec{ElInt}(icxx"El::DistMultiVec<El::Int>($m,$n);")
144144
convert(::Type{DistMultiVec{Float32}}, m::ElInt = 0, n::ElInt = 0) = DistMultiVec{Float32}(icxx"El::DistMultiVec<float>($m,$n);")
145145
convert(::Type{DistMultiVec{Float64}}, m::ElInt = 0, n::ElInt = 0) = DistMultiVec{Float64}(icxx"El::DistMultiVec<double>($m,$n);")
146146

147-
_setindex!{T}(A::DistMultiVec{T}, x::T, i::ElInt, j::ElInt) = icxx"$(A.buf).Set($i, $j, $x);"
148-
setindex!{T}(A::DistMultiVec{T}, x, i::Integer, j::Integer) = _setindex!(A, T(x), ElInt(i - 1), ElInt(j - 1))
147+
_setindex!(A::DistMultiVec{T}, x::T, i::ElInt, j::ElInt) where {T} = icxx"$(A.buf).Set($i, $j, $x);"
148+
setindex!(A::DistMultiVec{T}, x, i::Integer, j::Integer) where {T} = _setindex!(A, T(x), ElInt(i - 1), ElInt(j - 1))
149149

150150

151151
### SOCP ###

src/Elemental.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
module Elemental
22

3-
using Compat
4-
import Compat.String
3+
using Distributed
54
using DistributedArrays
5+
using LinearAlgebra
66

7-
import Base: *, \, Ac_mul_B
8-
import Base: convert, copy, copy!, countnz, dot, eltype, fill!, getindex, hcat, inv, length,
9-
logdet, pointer, print, setindex!, showarray, similar, size
10-
import Base.LinAlg: A_mul_B!, Ac_mul_B!, axpy!, norm, scale!, svd, svdvals, svdvals!
7+
import Base: *, \
8+
import Base: convert, copy, copy!, eltype, fill!, getindex, hcat, inv, length, pointer, print, setindex!, similar, size
119

1210
const libEl = abspath(joinpath(dirname(@__FILE__), "..", "deps", "usr", "lib", "libEl"))
1311

@@ -33,9 +31,11 @@ function Finalize()
3331
end
3432

3533
function __init__()
34+
# ccall(:jl_, Cvoid, (Any,), "starting up!")
3635
Init()
3736
DefaultGrid[] = Grid()
3837
atexit() do
38+
# ccall(:jl_, Cvoid, (Any,), "closing down!")
3939
Initialized() && Finalize()
4040
end
4141
end

src/blas_like/level1.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
for (elty, relty, ext) in ((:Float32, :Float32, :s),
22
(:Float64, :Float64, :d),
3-
(:Complex64, :Float32, :c),
4-
(:Complex128, :Float64, :z))
3+
(:ComplexF32, :Float32, :c),
4+
(:ComplexF64, :Float64, :z))
55
for (mat, sym) in ((:Matrix, "_"),
66
(:DistMatrix, "Dist_"),
77
(:DistMultiVec, "DistMultiVec_"))
88
@eval begin
9-
function axpy!::$elty, x::$mat{$elty}, y::$mat{$elty})
9+
function LinearAlgebra.axpy!::$elty, x::$mat{$elty}, y::$mat{$elty})
1010
ElError(ccall(($(string("ElAxpy", sym, ext)), libEl), Cuint,
11-
($elty, Ptr{Void}, Ptr{Void}),
11+
($elty, Ptr{Cvoid}, Ptr{Cvoid}),
1212
α, x.obj, y.obj))
1313
return y
1414
end
1515

1616
# Which is opposite Julia's copy! so we call it _copy! to avoid confusion
1717
function _copy!(src::$mat{$elty}, dest::$mat{$elty})
1818
ElError(ccall(($(string("ElCopy", sym, ext)), libEl), Cuint,
19-
(Ptr{Void}, Ptr{Void}),
19+
(Ptr{Cvoid}, Ptr{Cvoid}),
2020
src.obj, dest.obj))
2121
dest
2222
end
2323

24-
function dot(x::$mat{$elty}, y::$mat{$elty})
24+
function LinearAlgebra.dot(x::$mat{$elty}, y::$mat{$elty})
2525
rval = Ref{$elty}(0)
2626
ElError(ccall(($(string("ElDot", sym, ext)), libEl), Cuint,
27-
(Ptr{Void}, Ptr{Void}, Ref{$elty}),
27+
(Ptr{Cvoid}, Ptr{Cvoid}, Ref{$elty}),
2828
x.obj, y.obj, rval))
2929
return rval[]
3030
end
3131

3232
function fill!(x::$mat{$elty}, val::Number)
3333
ElError(ccall(($(string("ElFill", sym, ext)), libEl), Cuint,
34-
(Ptr{Void}, $elty),
34+
(Ptr{Cvoid}, $elty),
3535
x.obj, $elty(val)))
3636
return x
3737
end
@@ -40,7 +40,7 @@ for (elty, relty, ext) in ((:Float32, :Float32, :s),
4040
# C := [A, B]
4141
function hcat!(A::$mat{$elty}, B::$mat{$elty}, C::$mat{$elty})
4242
ElError(ccall(($(string("ElHCat", sym, ext)), libEl), Cuint,
43-
(Ptr{Void}, Ptr{Void}, Ptr{Void}),
43+
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
4444
A.obj, B.obj, C.obj))
4545
return C
4646
end
@@ -49,14 +49,14 @@ for (elty, relty, ext) in ((:Float32, :Float32, :s),
4949
function nrm2(x::$mat{$elty})
5050
rval = Ref{$relty}(0)
5151
ElError(ccall(($(string("ElNrm2", sym, ext)), libEl), Cuint,
52-
(Ptr{Void}, Ref{$relty}),
52+
(Ptr{Cvoid}, Ref{$relty}),
5353
x.obj, rval))
5454
return rval[]
5555
end
5656

5757
function scale!(x::$mat{$elty}, val::Number)
5858
ElError(ccall(($(string("ElScale", sym, ext)), libEl), Cuint,
59-
(Ptr{Void}, $elty),
59+
(Ptr{Cvoid}, $elty),
6060
x.obj, $elty(val)))
6161
return x
6262
end
@@ -65,7 +65,7 @@ for (elty, relty, ext) in ((:Float32, :Float32, :s),
6565
# C := [A; B]
6666
function vcat!(A::$mat{$elty}, B::$mat{$elty}, C::$mat{$elty})
6767
ElError(ccall(($(string("ElVCat", sym, ext)), libEl), Cuint,
68-
(Ptr{Void}, Ptr{Void}, Ptr{Void}),
68+
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
6969
A.obj, B.obj, C.obj))
7070
return C
7171
end

src/blas_like/level2.jl

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
for (elty, relty, ext) in ((:Float32, :Float32, :s),
2-
(:Float64, :Float64, :d),
3-
(:Complex64, :Float32, :c),
4-
(:Complex128, :Float64, :z))
1+
for (elty, ext) in ((:Float32, :s),
2+
(:Float64, :d),
3+
(:ComplexF32, :c),
4+
(:ComplexF64, :z))
55

66
# Distributed sparse gemv
7-
for (trans, elenum) in (("", :NORMAL), ("t", :TRANSPOSE), ("c", :ADJOINT))
8-
9-
f = Symbol("A", trans, "_mul_B!")
10-
11-
@eval begin
12-
function ($f)(α::$elty, A::DistSparseMatrix{$elty}, x::DistMultiVec{$elty}, β::$elty, y::DistMultiVec{$elty})
13-
ElError(ccall(($(string("ElMultiplyDist_", ext)), libEl), Cuint,
14-
(Cint, $elty, Ptr{Void}, Ptr{Void}, $elty, Ptr{Void}),
15-
$elenum, α, A.obj, x.obj, β, y.obj))
16-
return y
17-
end
7+
@eval begin
8+
function LinearAlgebra.mul!(y::DistMultiVec{$elty}, A::DistSparseMatrix{$elty}, x::DistMultiVec{$elty}, α::$elty, β::$elty)
9+
ElError(ccall(($(string("ElMultiplyDist_", ext)), libEl), Cuint,
10+
(Cint, $elty, Ptr{Cvoid}, Ptr{Cvoid}, $elty, Ptr{Cvoid}),
11+
NORMAL, α, A.obj, x.obj, β, y.obj))
12+
return y
13+
end
14+
function LinearAlgebra.mul!(y::DistMultiVec{$elty}, adjA::Adjoint{<:Any,DistSparseMatrix{$elty}}, x::DistMultiVec{$elty}, α::$elty, β::$elty)
15+
ElError(ccall(($(string("ElMultiplyDist_", ext)), libEl), Cuint,
16+
(Cint, $elty, Ptr{Cvoid}, Ptr{Cvoid}, $elty, Ptr{Cvoid}),
17+
ADJOINT, α, parent(adjA).obj, x.obj, β, y.obj))
18+
return y
19+
end
20+
function LinearAlgebra.mul!(y::DistMultiVec{$elty}, trA::Transpose{<:Any,DistSparseMatrix{$elty}}, x::DistMultiVec{$elty}, α::$elty, β::$elty)
21+
ElError(ccall(($(string("ElMultiplyDist_", ext)), libEl), Cuint,
22+
(Cint, $elty, Ptr{Cvoid}, Ptr{Cvoid}, $elty, Ptr{Cvoid}),
23+
TRANSPOSE, α, parent(trA).obj, x.obj, β, y.obj))
24+
return y
1825
end
1926
end
2027
end

src/blas_like/level3.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
for (elty, relty, ext) in ((:Float32, :Float32, :s),
22
(:Float64, :Float64, :d),
3-
(:Complex64, :Float32, :c),
4-
(:Complex128, :Float64, :z))
3+
(:ComplexF32, :Float32, :c),
4+
(:ComplexF64, :Float64, :z))
55

66
for (mat, sym) in ((:Matrix, "_"),
77
(:DistMatrix, "Dist_"))
@@ -10,15 +10,15 @@ for (elty, relty, ext) in ((:Float32, :Float32, :s),
1010

1111
function gemm(orientationOfA::Orientation, orientationOfB::Orientation, α::$elty, A::$mat{$elty}, B::$mat{$elty}, β::$elty, C::$mat{$elty})
1212
ElError(ccall(($(string("ElGemm", sym, ext)), libEl), Cuint,
13-
(Orientation, Orientation, $elty, Ptr{Void}, Ptr{Void}, $elty, Ptr{Void}),
13+
(Orientation, Orientation, $elty, Ptr{Cvoid}, Ptr{Cvoid}, $elty, Ptr{Cvoid}),
1414
orientationOfA, orientationOfB, α, A.obj, B.obj, β, C.obj))
1515
return C
1616
end
1717

1818
function trsm(side::LeftOrRight, uplo::UpperOrLower, orientation::Orientation, diag::UnitOrNonUnit, α::$elty, A::$mat{$elty}, B::$mat{$elty})
1919
ElError(ccall(($(string("ElTrsm", sym, ext)), libEl), Cuint,
2020
(LeftOrRight, UpperOrLower, Orientation, UnitOrNonUnit,
21-
$elty, Ptr{Void}, Ptr{Void}),
21+
$elty, Ptr{Cvoid}, Ptr{Cvoid}),
2222
side, uplo, orientation, diag,
2323
α, A.obj, B.obj))
2424
return B

0 commit comments

Comments
 (0)