Skip to content

Commit 94e1a5e

Browse files
authored
Merge pull request #47 from JuliaParallel/an/lu
Wrap LU factorization
2 parents 0bd7be0 + 93dc46f commit 94e1a5e

File tree

5 files changed

+75
-15
lines changed

5 files changed

+75
-15
lines changed

.travis.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ notifications:
88

99
os:
1010
- linux
11+
- osx
1112

1213
julia:
1314
- 0.7
@@ -48,14 +49,17 @@ addons:
4849
- clang-3.8
4950

5051
install:
51-
- echo `ccache -s`
52-
- sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang-3.8
53-
- sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang++-3.8
52+
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
53+
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ; fi
54+
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH" ; fi
55+
- echo `${ccache -s}`
56+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang-3.8 ; fi
57+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang++-3.8 ; fi
5458
- echo `which $CC`
5559
- echo `which $CXX`
56-
- curl https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz | sudo tar -x -z --strip-components 1 -C /usr
60+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz | sudo tar -x -z --strip-components 1 -C /usr ; fi
5761
- export CPU_CORES=2
58-
- sh ./mpi.sh $MPI > /dev/null
62+
- sh ./mpi.sh $MPI
5963
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
6064
- while sleep 30; do tail ./deps/build.log -f ; done &
6165
- julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Elemental")'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A package for dense and sparse distributed linear algebra and optimization. The
88
The package is installed with `Pkg.add("Elemental")`. The install script automatically downloads *Elemental* and will try build against the BLAS library used by Julia.
99

1010
### MPI
11-
The install script will build against any MPI installation that can be detected from calling `mpirun`. The package is tested with MPICH and OpenMPI but be aware that for OpenMPI at least version 1.8 is required because earlier versions of had bugs for complex data types. If you are using Linux and have installed OpenMPI from the repositories the version is (as always on Linux distributions) likely to be too old.
11+
The install script will build against any MPI installation that can be detected from calling `mpirun`. The package is tested with MPICH and OpenMPI but be aware that for OpenMPI at least version 1.8 is required because earlier versions of had bugs for complex data types. If you are using Linux and have installed OpenMPI from the repositories the version is (as always on Linux distributions) likely to be too old. Currently, MPICH isn't supported on macOS, see [this comment](https://github.com/pmodels/mpich/commit/2999a0ab3abc7a113d35d6117a9d1db8fa0ffa44#commitcomment-31131644) for details.
1212

1313
## Examples - SVD
1414

mpi.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ case "$os" in
1212
Darwin)
1313
brew update
1414
brew upgrade cmake
15-
brew upgrade gcc
15+
brew cask uninstall oclint
16+
brew install gcc
1617
case "$MPI_IMPL" in
1718
mpich|mpich3)
1819
brew install mpich

src/julia/generic.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,7 @@ LinearAlgebra.norm(x::ElementalMatrix) = nrm2(x)
169169
# end
170170
# end
171171

172-
LinearAlgebra.cholesky!(A::Hermitian{<:Any,<:ElementalMatrix}, ::Type{Val{false}}) = LinearAlgebra.Cholesky(cholesky(A.uplo == 'U' ? UPPER : LOWER, A.data), A.uplo)
172+
LinearAlgebra.cholesky!(A::Hermitian{<:Union{Real,Complex},<:ElementalMatrix}) = LinearAlgebra.Cholesky(_cholesky!(A.uplo == 'U' ? UPPER : LOWER, A.data), A.uplo, 0)
173+
LinearAlgebra.cholesky(A::Hermitian{<:Union{Real,Complex},<:ElementalMatrix}) = cholesky!(copy(A))
174+
175+
LinearAlgebra.lu(A::ElementalMatrix) = _lu!(copy(A))

src/lapack_like/factor.jl

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,72 @@ function RegSolveCtrl(::Type{T};
3434
ElBool(time))
3535
end
3636

37-
for (elty, ext) in ((:Float32, :s),
38-
(:Float64, :d),
39-
(:ComplexF32, :c),
40-
(:ComplexF64, :z))
41-
for mattype in ("", "Dist")
42-
mat = Symbol(mattype, "Matrix")
37+
mutable struct Permutation
38+
obj::Ptr{Cvoid}
39+
end
40+
41+
function destroy(P::Permutation)
42+
ElError(ccall(("ElPermutationDestroy", libEl), Cuint,
43+
(Ptr{Cvoid},),
44+
P.obj))
45+
return nothing
46+
end
47+
48+
function Permutation()
49+
obj = Ref{Ptr{Cvoid}}(0)
50+
ElError(ccall(("ElPermutationCreate", libEl), Cuint,
51+
(Ref{Ptr{Cvoid}},),
52+
obj))
53+
P = Permutation(obj[])
54+
finalizer(destroy, P)
55+
return P
56+
end
57+
58+
mutable struct DistPermutation
59+
obj::Ptr{Cvoid}
60+
end
61+
62+
function destroy(P::DistPermutation)
63+
ElError(ccall(("ElDistPermutationDestroy", libEl), Cuint,
64+
(Ptr{Cvoid},),
65+
P.obj))
66+
return nothing
67+
end
68+
69+
function DistPermutation(grid::Grid = DefaultGrid[])
70+
obj = Ref{Ptr{Cvoid}}(0)
71+
ElError(ccall(("ElDistPermutationCreate", libEl), Cuint,
72+
(Ref{Ptr{Cvoid}}, Ptr{Cvoid}),
73+
obj, grid.obj))
74+
P = DistPermutation(obj[])
75+
finalizer(destroy, P)
76+
return P
77+
end
78+
79+
for mattype in ("", "Dist")
80+
mat = Symbol(mattype, "Matrix")
81+
_p = Symbol(mattype, "Permutation")
82+
83+
for (elty, ext) in ((:Float32, :s),
84+
(:Float64, :d),
85+
(:ComplexF32, :c),
86+
(:ComplexF64, :z))
4387
@eval begin
4488

45-
function _cholesky(uplo::UpperOrLower, A::$mat{$elty})
89+
function _cholesky!(uplo::UpperOrLower, A::$mat{$elty})
4690
ElError(ccall(($(string("ElCholesky", mattype, "_", ext)), libEl), Cuint,
4791
(UpperOrLower, Ptr{Cvoid}),
4892
uplo, A.obj))
4993
return A
5094
end
95+
96+
function _lu!(A::$mat{$elty})
97+
p = $_p()
98+
ElError(ccall(($(string("ElLUPartialPiv", mattype, "_", ext)), libEl), Cuint,
99+
(Ptr{Cvoid}, Ptr{Cvoid}),
100+
A.obj, p.obj))
101+
return A, p
102+
end
51103
end
52104
end
53105
end

0 commit comments

Comments
 (0)