Skip to content

Commit

Permalink
Merge pull request #47 from JuliaParallel/an/lu
Browse files Browse the repository at this point in the history
Wrap LU factorization
  • Loading branch information
andreasnoack authored Nov 19, 2018
2 parents 0bd7be0 + 93dc46f commit 94e1a5e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 15 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ notifications:

os:
- linux
- osx

julia:
- 0.7
Expand Down Expand Up @@ -48,14 +49,17 @@ addons:
- clang-3.8

install:
- echo `ccache -s`
- sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang-3.8
- sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang++-3.8
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ; fi
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH" ; fi
- echo `${ccache -s}`
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang-3.8 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ln -s /usr/bin/ccache /usr/lib/ccache/clang++-3.8 ; fi
- echo `which $CC`
- echo `which $CXX`
- 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
- 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
- export CPU_CORES=2
- sh ./mpi.sh $MPI > /dev/null
- sh ./mpi.sh $MPI
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- while sleep 30; do tail ./deps/build.log -f ; done &
- julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Elemental")'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A package for dense and sparse distributed linear algebra and optimization. The
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.

### MPI
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.
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.

## Examples - SVD

Expand Down
3 changes: 2 additions & 1 deletion mpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ case "$os" in
Darwin)
brew update
brew upgrade cmake
brew upgrade gcc
brew cask uninstall oclint
brew install gcc
case "$MPI_IMPL" in
mpich|mpich3)
brew install mpich
Expand Down
5 changes: 4 additions & 1 deletion src/julia/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,7 @@ LinearAlgebra.norm(x::ElementalMatrix) = nrm2(x)
# end
# end

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

LinearAlgebra.lu(A::ElementalMatrix) = _lu!(copy(A))
66 changes: 59 additions & 7 deletions src/lapack_like/factor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,72 @@ function RegSolveCtrl(::Type{T};
ElBool(time))
end

for (elty, ext) in ((:Float32, :s),
(:Float64, :d),
(:ComplexF32, :c),
(:ComplexF64, :z))
for mattype in ("", "Dist")
mat = Symbol(mattype, "Matrix")
mutable struct Permutation
obj::Ptr{Cvoid}
end

function destroy(P::Permutation)
ElError(ccall(("ElPermutationDestroy", libEl), Cuint,
(Ptr{Cvoid},),
P.obj))
return nothing
end

function Permutation()
obj = Ref{Ptr{Cvoid}}(0)
ElError(ccall(("ElPermutationCreate", libEl), Cuint,
(Ref{Ptr{Cvoid}},),
obj))
P = Permutation(obj[])
finalizer(destroy, P)
return P
end

mutable struct DistPermutation
obj::Ptr{Cvoid}
end

function destroy(P::DistPermutation)
ElError(ccall(("ElDistPermutationDestroy", libEl), Cuint,
(Ptr{Cvoid},),
P.obj))
return nothing
end

function DistPermutation(grid::Grid = DefaultGrid[])
obj = Ref{Ptr{Cvoid}}(0)
ElError(ccall(("ElDistPermutationCreate", libEl), Cuint,
(Ref{Ptr{Cvoid}}, Ptr{Cvoid}),
obj, grid.obj))
P = DistPermutation(obj[])
finalizer(destroy, P)
return P
end

for mattype in ("", "Dist")
mat = Symbol(mattype, "Matrix")
_p = Symbol(mattype, "Permutation")

for (elty, ext) in ((:Float32, :s),
(:Float64, :d),
(:ComplexF32, :c),
(:ComplexF64, :z))
@eval begin

function _cholesky(uplo::UpperOrLower, A::$mat{$elty})
function _cholesky!(uplo::UpperOrLower, A::$mat{$elty})
ElError(ccall(($(string("ElCholesky", mattype, "_", ext)), libEl), Cuint,
(UpperOrLower, Ptr{Cvoid}),
uplo, A.obj))
return A
end

function _lu!(A::$mat{$elty})
p = $_p()
ElError(ccall(($(string("ElLUPartialPiv", mattype, "_", ext)), libEl), Cuint,
(Ptr{Cvoid}, Ptr{Cvoid}),
A.obj, p.obj))
return A, p
end
end
end
end

0 comments on commit 94e1a5e

Please sign in to comment.