Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ComponentArrays.jl in Krylov.jl #859

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ steps:
- label: "Nvidia GPUs -- CUDA.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
version: "1.10"
agents:
queue: "juliagpu"
cuda: "*"
Expand All @@ -22,7 +22,7 @@ steps:
- label: "AMD GPUs -- AMDGPU.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
version: "1.10"
agents:
queue: "juliagpu"
rocm: "*"
Expand All @@ -43,7 +43,7 @@ steps:
- label: "Intel GPUs -- oneAPI.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
version: "1.10"
agents:
queue: "juliagpu"
intel: "*"
Expand All @@ -58,7 +58,7 @@ steps:
- label: "Apple M1 GPUs -- Metal.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
version: "1.10"
agents:
queue: "juliaecosystem"
os: "macos"
Expand All @@ -74,13 +74,27 @@ steps:
- label: "CPUs -- StaticArrays.jl"
plugins:
- JuliaCI/julia#v1:
version: 1.9
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("StaticArrays")
Pkg.instantiate()
include("test/test_extensions.jl")'
include("test/cpu/static_arrays.jl")'
timeout_in_minutes: 30

- label: "CPUs -- ComponentArrays.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("ComponentArrays")
Pkg.instantiate()
include("test/cpu/component_arrays.jl")'
timeout_in_minutes: 30
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task:
- JULIA_VERSION: 1
- name: MacOS M1
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-base:latest
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
- JULIA_VERSION: 1
install_script: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
version: ['1.6', '1']
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
arch: [x64]
allow_failure: [false]
include:
Expand All @@ -23,15 +23,15 @@ jobs:
arch: x64
allow_failure: true
- version: 'nightly'
os: macOS-latest
os: macos-13
arch: x64
allow_failure: true
- version: 'nightly'
os: windows-latest
arch: x64
allow_failure: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
Expand Down
11 changes: 8 additions & 3 deletions src/krylov_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,22 @@ Return the most relevant storage type `S` based on the type of `v`.
function ktypeof end

function ktypeof(v::S) where S <: DenseVector
return S
if S.name.name == :ComponentArray
T = eltype(S)
return Vector{T}
else
return S
end
end

function ktypeof(v::S) where S <: DenseMatrix
return S
end

function ktypeof(v::S) where S <: AbstractVector
if S.name.name == :Zeros || S.name.name == :Ones || S.name.name == :SArray || S.name.name == :MArray || S.name.name == :SizedArray || S.name.name == :FieldArray || S.name.name == :ComponentArray
if S.name.name == :Zeros || S.name.name == :Ones || S.name.name == :SArray || S.name.name == :MArray || S.name.name == :SizedArray || S.name.name == :FieldArray
T = eltype(S)
return Vector{T} # FillArrays, StaticArrays, ComponentArrays
return Vector{T} # FillArrays, StaticArrays
else
return S # BlockArrays, PartitionedArrays, etc...
end
Expand Down
15 changes: 15 additions & 0 deletions test/cpu/component_arrays.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using LinearAlgebra, SparseArrays, Test
using Krylov, ComponentArrays

@testset "ComponentArrays" begin
n = 5

for T in (Float32, Float64)
A = rand(T, n, n)

b = ComponentVector{T}(a=[1, 2, 3], b=[4, 5])
@test Krylov.ktypeof(b) == Vector{T}
x, stats = gmres(A, b)
@test stats.solved
end
end
File renamed without changes.
Loading