diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..79f3e46 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI +on: + push: + branches: + - master + pull_request: +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1' + os: + - ubuntu-latest + - macos-latest + arch: + - x64 + exclude: + - os: macos-latest + arch: x64 + include: + - os: macos-latest + arch: aarch64 + version: '1' + - os: ubuntu-latest + arch: x64 + version: 'pre' + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + - uses: julia-actions/cache@v2 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e77c2b9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: julia -osx_image: xcode11.4 -notifications: - email: false -os: - - linux - - osx -julia: - - 1 - - nightly -matrix: - allow_failures: - - julia: nightly diff --git a/src/core/distmultivec.jl b/src/core/distmultivec.jl index a97e2c7..b9dfd2c 100644 --- a/src/core/distmultivec.jl +++ b/src/core/distmultivec.jl @@ -1,5 +1,6 @@ mutable struct DistMultiVec{T} <: ElementalMatrix{T} obj::Ptr{Cvoid} + grid::Grid # keep the grid around to avoid that it's freed before the matrix end for (elty, ext) in ((:ElInt, :i), @@ -16,24 +17,16 @@ for (elty, ext) in ((:ElInt, :i), return nothing end - function DistMultiVec(::Type{$elty}, cm::ElComm = MPI.CommWorld[]) + function DistMultiVec(::Type{$elty}, grid::Grid = DefaultGrid[]) obj = Ref{Ptr{Cvoid}}(C_NULL) ElError(ccall(($(string("ElDistMultiVecCreate_", ext)), libEl), Cuint, - (Ref{Ptr{Cvoid}}, ElComm), - obj, cm)) - A = DistMultiVec{$elty}(obj[]) + (Ref{Ptr{Cvoid}}, Ptr{Cvoid}), + obj, grid.obj)) + A = DistMultiVec{$elty}(obj[], grid) finalizer(destroy, A) return A end - function comm(A::DistMultiVec{$elty}) - cm = Ref{ElComm}() - ElError(ccall(($(string("ElDistMultiVecComm_", ext)), libEl), Cuint, - (Ptr{Cvoid}, Ref{ElComm}), - A.obj, cm)) - return cm[] - end - function get(x::DistMultiVec{$elty}, i::Integer = size(x, 1), j::Integer = 1) v = Ref{$elty}() ElError(ccall(($(string("ElDistMultiVecGet_", ext)), libEl), Cuint, @@ -117,8 +110,8 @@ end getindex(x::DistMultiVec, i, j) = get(x, i, j) -function similar(::DistMultiVec, ::Type{T}, sz::Dims, cm::ElComm = MPI.CommWorld[]) where {T} - A = DistMultiVec(T, cm) +function similar(::DistMultiVec, ::Type{T}, sz::Dims, grid::Grid = DefaultGrid[]) where {T} + A = DistMultiVec(T, grid) resize!(A, sz...) return A end diff --git a/src/core/distsparsematrix.jl b/src/core/distsparsematrix.jl index 131b210..d2f732c 100644 --- a/src/core/distsparsematrix.jl +++ b/src/core/distsparsematrix.jl @@ -1,5 +1,6 @@ mutable struct DistSparseMatrix{T} <: ElementalMatrix{T} obj::Ptr{Cvoid} + grid::Grid # keep the grid around to avoid that it's freed before the matrix end for (elty, ext) in ((:ElInt, :i), @@ -16,24 +17,16 @@ for (elty, ext) in ((:ElInt, :i), return nothing end - function DistSparseMatrix(::Type{$elty}, comm::ElComm = MPI.CommWorld[]) + function DistSparseMatrix(::Type{$elty}, grid::Grid = DefaultGrid[]) obj = Ref{Ptr{Cvoid}}(C_NULL) ElError(ccall(($(string("ElDistSparseMatrixCreate_", ext)), libEl), Cuint, - (Ref{Ptr{Cvoid}}, ElComm), - obj, comm)) - A = DistSparseMatrix{$elty}(obj[]) + (Ref{Ptr{Cvoid}}, Ptr{Cvoid}), + obj, grid.obj)) + A = DistSparseMatrix{$elty}(obj[], grid) finalizer(destroy, A) return A end - function comm(A::DistSparseMatrix{$elty}) - cm = Ref{ElComm}() - ElError(ccall(($(string("ElDistSparseMatrixComm_", ext)), libEl), Cuint, - (Ptr{Cvoid}, Ref{ElComm}), - A.obj, cm)) - return cm[] - end - function globalRow(A::DistSparseMatrix{$elty}, iLoc::Integer) i = Ref{ElInt}(0) ElError(ccall(($(string("ElDistSparseMatrixGlobalRow_", ext)), libEl), Cuint, @@ -112,8 +105,8 @@ for (elty, ext) in ((:ElInt, :i), end # The other constructors don't have a version with dimensions. Should they, or should this one go? -function DistSparseMatrix(::Type{T}, m::Integer, n::Integer, comm::ElComm = MPI.CommWorld[]) where {T} - A = DistSparseMatrix(T, comm) +function DistSparseMatrix(::Type{T}, m::Integer, n::Integer, grid::Grid = DefaultGrid[]) where {T} + A = DistSparseMatrix(T, grid) resize!(A, m, n) return A end diff --git a/src/lapack_like/euclidean_min.jl b/src/lapack_like/euclidean_min.jl index 9550f1a..90d1cce 100644 --- a/src/lapack_like/euclidean_min.jl +++ b/src/lapack_like/euclidean_min.jl @@ -23,7 +23,7 @@ function leastSquares(A::DistMatrix{T}, B::DistMatrix{T}; end function leastSquares(A::DistSparseMatrix{T}, B::DistMultiVec{T}; orientation::Orientation = NORMAL) where {T} - X = DistMultiVec(T, comm(A)) + X = DistMultiVec(T, A.grid) return leastSquares!(A, B, X, orientation = orientation) end @@ -49,7 +49,7 @@ function bpdn(A::DistMatrix{T}, B::DistMatrix{T}, lambda::T) where {T} return bpdn!(A, B, lambda, X) end function bpdn(A::DistSparseMatrix{T}, B::DistMultiVec{T}, lambda) where {T} - X = DistMultiVec(T, comm(A)) + X = DistMultiVec(T, A.grid) return bpdn!(A, B, lambda, X) end @@ -78,6 +78,6 @@ function ridge(A::DistMatrix{T}, B::DistMatrix{T}, gamma::T; ka...) where {T} return ridge!(A, B, gamma, X; ka...) end function ridge(A::DistSparseMatrix{T}, B::DistMultiVec{T}, gamma::T; ka...) where {T} - X = DistMultiVec(T, comm(A)) + X = DistMultiVec(T, A.grid) return ridge!(A, B, gamma, X; ka...) end \ No newline at end of file diff --git a/src/optimization/models.jl b/src/optimization/models.jl index 96b504c..37b2bcb 100644 --- a/src/optimization/models.jl +++ b/src/optimization/models.jl @@ -33,11 +33,11 @@ function lav(A::DistMatrix{T}, b::DistMatrix{T}) where {T<:Union{Float32,Float64 return lav!(A, b, x) end function lav(A::DistSparseMatrix{T}, b::DistMultiVec{T}) where {T<:Union{Float32,Float64}} - x = DistMultiVec(T, comm(A)) + x = DistMultiVec(T, A.grid) return lav!(A, b, x) end function lav(A::DistSparseMatrix{T}, b::DistMultiVec{T}, ctrl::LPAffineCtrl{T}) where {T<:Union{Float32,Float64}} - x = DistMultiVec(T, comm(A)) + x = DistMultiVec(T, A.grid) return lav!(A, b, x, ctrl) end