From caac92101e0f34496b728affa732ad2ec17f0de7 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Thu, 1 Nov 2018 10:43:02 +0100 Subject: [PATCH 1/2] Document that MPICH isn't supported on Mac and begin testing on Mac --- .travis.yml | 14 +++++++++----- README.md | 2 +- mpi.sh | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b312f6b..91d03f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ notifications: os: - linux + - osx julia: - 0.7 @@ -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")' diff --git a/README.md b/README.md index 9fe8e09..838f0b3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/mpi.sh b/mpi.sh index 1efe4ae..b6a7ef4 100644 --- a/mpi.sh +++ b/mpi.sh @@ -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 From 93dc46f616a34247e536970e46f7971cf738423e Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Mon, 12 Nov 2018 21:20:40 +0100 Subject: [PATCH 2/2] Wrap LU --- src/julia/generic.jl | 5 ++- src/lapack_like/factor.jl | 66 ++++++++++++++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/julia/generic.jl b/src/julia/generic.jl index 295a578..4767516 100644 --- a/src/julia/generic.jl +++ b/src/julia/generic.jl @@ -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)) diff --git a/src/lapack_like/factor.jl b/src/lapack_like/factor.jl index 04ab5b4..3b421f7 100644 --- a/src/lapack_like/factor.jl +++ b/src/lapack_like/factor.jl @@ -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