Skip to content

Commit

Permalink
Test block-GMRES on GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 30, 2024
1 parent db20870 commit a4da5de
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ steps:
using Pkg
Pkg.add("CUDA")
Pkg.add("LinearOperators")
Pkg.add("KernelAbstractions")
Pkg.instantiate()
using CUDA
# CUDA.set_runtime_version!(v"11.8")'
Expand All @@ -36,6 +37,7 @@ steps:
julia --color=yes --project -e '
using Pkg
Pkg.add("AMDGPU")
Pkg.add("KernelAbstractions")
Pkg.instantiate()
include("test/gpu/amd.jl")'
timeout_in_minutes: 30
Expand All @@ -52,6 +54,7 @@ steps:
using Pkg
Pkg.add(url="https://github.com/JuliaGPU/oneAPI.jl", rev="master")
# Pkg.add("oneAPI")
Pkg.add("KernelAbstractions")
Pkg.instantiate()
include("test/gpu/intel.jl")'
timeout_in_minutes: 30
Expand All @@ -68,6 +71,7 @@ steps:
julia --color=yes --project -e '
using Pkg
Pkg.add("Metal")
Pkg.add("KernelAbstractions")
Pkg.instantiate()
include("test/gpu/metal.jl")'
timeout_in_minutes: 30
Expand Down
9 changes: 9 additions & 0 deletions test/gpu/amd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ include("gpu.jl")
@test norm(b - A * x) atol + rtol * norm(b)
end

@testset "block-GMRES -- $FC" begin
A, b = nonsymmetric_indefinite(FC=FC)
B = hcat(b, -b)
A = M(A)
B = M(B)
X, stats = block_gmres(A, B)
@test norm(B - A * X) atol + rtol * norm(B)
end

@testset "CG -- $FC" begin
A, b = symmetric_definite(FC=FC)
A = M(A)
Expand Down
16 changes: 15 additions & 1 deletion test/gpu/gpu.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
using SparseArrays, Random, Test
using LinearAlgebra, Krylov
using LinearAlgebra, Krylov, KernelAbstractions

@kernel function copy_triangle_kernel!(dest, src)
i, j = @index(Global, NTuple)
if j >= i
@inbounds dest[i, j] = src[i, j]
end
end

function Krylov.copy_triangle(Q::AbstractMatrix{FC}, R::AbstractMatrix{FC}, k::Int) where FC <: Krylov.FloatOrComplex
backend = get_backend(Q)
ndrange = (k, k)
copy_triangle_kernel!(backend)(R, Q; ndrange=ndrange)
KernelAbstractions.synchronize(backend)
end

Random.seed!(666)

Expand Down
9 changes: 9 additions & 0 deletions test/gpu/intel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ include("gpu.jl")
@test norm(b - A * x) atol + rtol * norm(b)
end

@testset "block-GMRES -- $FC" begin
A, b = nonsymmetric_indefinite(FC=FC)
B = hcat(b, -b)
A = M(A)
B = M(B)
X, stats = block_gmres(A, B)
@test norm(B - A * X) atol + rtol * norm(B)
end

@testset "CG -- $FC" begin
A, b = symmetric_definite(FC=FC)
A = M(A)
Expand Down
9 changes: 9 additions & 0 deletions test/gpu/nvidia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ include("gpu.jl")
@test norm(b - A * x) atol + rtol * norm(b)
end

@testset "block-GMRES -- $FC" begin
A, b = nonsymmetric_indefinite(FC=FC)
B = hcat(b, -b)
A = M(A)
B = M(B)
X, stats = block_gmres(A, B)
@test norm(B - A * X) atol + rtol * norm(B)
end

@testset "CG -- $FC" begin
A, b = symmetric_definite(FC=FC)
A = M(A)
Expand Down

0 comments on commit a4da5de

Please sign in to comment.