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

fix tests if AMDGPU is not available #285

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 1 addition & 2 deletions test/Polar/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/quickstart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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)

Expand Down
19 changes: 12 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Test

using Random
using LinearAlgebra
using Random
using SparseArrays
using Test

using AMDGPU
using CUDA
Expand All @@ -16,15 +15,21 @@ 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 = CUDA.functional() && CUDA.has_cuda_gpu()
test_rocm = AMDGPU.functional() && AMDGPU.has_rocm_gpu()

# 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)
Expand Down
Loading