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

Test-suite improvements. #566

Merged
merged 1 commit into from
Oct 22, 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
5 changes: 2 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ include("setup.jl") # make sure everything is precompiled
# choose tests
const tests = []
const test_runners = Dict()
## GPUArrays testsuite
for AT in (JLArray, Array), name in keys(TestSuite.tests)
push!(tests, "$(AT)$(Base.Filesystem.path_separator)$name")
test_runners["$(AT)$(Base.Filesystem.path_separator)$name"] = ()->TestSuite.tests[name](AT)
push!(tests, "$(AT)/$name")
test_runners["$(AT)/$name"] = ()->TestSuite.tests[name](AT)
end
unique!(tests)

Expand Down
5 changes: 1 addition & 4 deletions test/testsuite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ using Test

using Adapt

struct ArrayAdaptor{AT} end
Adapt.adapt_storage(::ArrayAdaptor{AT}, xs::AbstractArray) where {AT} = AT(xs)

test_result(a::Number, b::Number; kwargs...) = ≈(a, b; kwargs...)
test_result(a::Missing, b::Missing; kwargs...) = true
test_result(a::Number, b::Missing; kwargs...) = false
Expand All @@ -39,7 +36,7 @@ end
function compare(f, AT::Type{<:AbstractGPUArray}, xs...; kwargs...)
# copy on the CPU, adapt on the GPU, but keep Ref's
cpu_in = map(x -> isa(x, Base.RefValue) ? x[] : deepcopy(x), xs)
gpu_in = map(x -> isa(x, Base.RefValue) ? x[] : adapt(ArrayAdaptor{AT}(), x), xs)
gpu_in = map(x -> isa(x, Base.RefValue) ? x[] : adapt(AT, x), xs)

cpu_out = f(cpu_in...)
gpu_out = f(gpu_in...)
Expand Down
Loading