Skip to content

Commit

Permalink
Test-suite improvements. (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored Oct 22, 2024
1 parent d2ba271 commit 44043dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
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

0 comments on commit 44043dd

Please sign in to comment.