diff --git a/test/Polar/TestPolarForm.jl b/test/Polar/TestPolarForm.jl index bf9800a0..f1558717 100644 --- a/test/Polar/TestPolarForm.jl +++ b/test/Polar/TestPolarForm.jl @@ -2,8 +2,6 @@ module TestPolarFormulation using Test -using AMDGPU -using CUDA using FiniteDiff using KernelAbstractions using LinearAlgebra diff --git a/test/Polar/api.jl b/test/Polar/api.jl index 0c6d5691..c5e5dc28 100644 --- a/test/Polar/api.jl +++ b/test/Polar/api.jl @@ -135,8 +135,7 @@ function test_polar_api(polar, device, M) ## Cost Production cost_production = ExaPF.CostFunction(polar) - c2 = CUDA.@allowscalar cost_production(stack)[1] - @test isa(c2, Real) + @test isa(cost_production(stack), M) # Test display println(devnull, cost_production) println(devnull, basis) diff --git a/test/Polar/second_order.jl b/test/Polar/second_order.jl index 947d55f1..619311f8 100644 --- a/test/Polar/second_order.jl +++ b/test/Polar/second_order.jl @@ -62,7 +62,7 @@ function test_hessprod_with_finitediff(polar, device, MT; rtol=1e-6, atol=1e-6) proj_fd = zeros(nx+nu) mul!(proj_fd, H_fd, tgt) - if isa(device, ROCBackend) + if startswith(string(device), "ROCBackend") @test_broken myisapprox(projp, proj_fd, rtol=rtol) else @test myisapprox(projp, proj_fd, rtol=rtol) @@ -121,7 +121,7 @@ function test_full_space_hessian(polar, device, MT) Hd = FiniteDiff.finite_difference_jacobian(grad_fd_x, x) # Test that both Hessian match - if isa(device, ROCBackend) + if startswith(string(device), "ROCBackend") @test_broken myisapprox(Hd, H, rtol=1e-5) else @test myisapprox(Hd, H, rtol=1e-5) diff --git a/test/quickstart.jl b/test/quickstart.jl index 001e8fb5..ebe5fcd5 100644 --- a/test/quickstart.jl +++ b/test/quickstart.jl @@ -1,6 +1,4 @@ using Test -using AMDGPU -using CUDA using KernelAbstractions using ExaPF @@ -72,7 +70,7 @@ const LS = ExaPF.LinearSolvers @test convergence.n_iterations == 5 @test convergence.norm_residuals <= pf_algo.tol - if CUDA.has_cuda_gpu() + if test_cuda polar_gpu = ExaPF.PolarForm(pf, CUDABackend()) stack_gpu = ExaPF.NetworkStack(polar_gpu) diff --git a/test/runtests.jl b/test/runtests.jl index d1b9ca57..aa219014 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,9 @@ -using Test - -using Random using LinearAlgebra +using Pkg +using Random using SparseArrays +using Test -using AMDGPU -using CUDA using KernelAbstractions using ExaPF @@ -16,15 +14,31 @@ const BENCHMARK_DIR = joinpath(dirname(@__FILE__), "..", "benchmark") const EXAMPLES_DIR = joinpath(dirname(@__FILE__), "..", "examples") const CASES = ["case9.m", "case30.m"] -# ARCHS = Any[(CPU(), Array, SparseMatrixCSC)] -ARCHS = [] -if CUDA.has_cuda() +is_package_installed(name::String) = !isnothing(Base.find_package(name)) + +ARCHS = Any[(CPU(), Array, SparseMatrixCSC)] + +test_cuda = if is_package_installed("CUDA") + using CUDA + CUDA.has_cuda_gpu() +else + false +end +test_rocm = if is_package_installed("AMDGPU") + using AMDGPU + AMDGPU.has_rocm_gpu() +else + false +end + +# Setup CUDA +if test_cuda using CUDA.CUSPARSE CUDA.allowscalar(false) CUDA_ARCH = (CUDABackend(), CuArray, CuSparseMatrixCSR) push!(ARCHS, CUDA_ARCH) end -if AMDGPU.has_rocm_gpu() +if test_rocm using AMDGPU.rocSPARSE AMDGPU.allowscalar(false) ROC_ARCH = (ROCBackend(), ROCArray, ROCSparseMatrixCSR)