diff --git a/.gitignore b/.gitignore index 338e0ee8f..c63f3dd79 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ docs/package-lock.json docs/node_modules Manifest*.toml LocalPreferences.toml + +test/gpuarrays_generated_tests.jl diff --git a/test/gpuarrays_tests.jl b/test/gpuarrays_tests.jl deleted file mode 100644 index 0a0be3106..000000000 --- a/test/gpuarrays_tests.jl +++ /dev/null @@ -1,89 +0,0 @@ -@testsetup module TSGPUArrays - export gpuarrays_test - - using AMDGPU - import GPUArrays - include(joinpath(pkgdir(GPUArrays), "test", "testsuite.jl")) - - gpuarrays_test(test_name::String) = TestSuite.tests[test_name](ROCArray) -end -# TODO define `@testitem` dynamically - -@testitem "gpuarrays - base" setup=[TSGPUArrays] begin - gpuarrays_test("base") -end -@testitem "gpuarrays - broadcasting" setup=[TSGPUArrays] begin - gpuarrays_test("broadcasting") -end -@testitem "gpuarrays - constructors" setup=[TSGPUArrays] begin - gpuarrays_test("constructors") -end -@testitem "gpuarrays - indexing find" setup=[TSGPUArrays] begin - gpuarrays_test("indexing find") -end -@testitem "gpuarrays - indexing multidimensional" setup=[TSGPUArrays] begin - if Sys.islinux() # TODO Windows does not support hostcalls. - gpuarrays_test("indexing multidimensional") - AMDGPU.synchronize(; stop_hostcalls=true) - end -end -@testitem "gpuarrays - indexing scalar" setup=[TSGPUArrays] begin - gpuarrays_test("indexing scalar") -end -@testitem "gpuarrays - linalg/core" setup=[TSGPUArrays] begin - gpuarrays_test("linalg/core") -end -@testitem "gpuarrays - linalg/mul!/matrix-matrix" setup=[TSGPUArrays] begin - gpuarrays_test("linalg/mul!/matrix-matrix") -end -@testitem "gpuarrays - linalg/mul!/vector-matrix" setup=[TSGPUArrays] begin - gpuarrays_test("linalg/mul!/vector-matrix") -end -@testitem "gpuarrays - linalg/norm" setup=[TSGPUArrays] begin - gpuarrays_test("linalg/norm") -end -@testitem "gpuarrays - math/intrinsics" setup=[TSGPUArrays] begin - gpuarrays_test("math/intrinsics") -end -@testitem "gpuarrays - math/power" setup=[TSGPUArrays] begin - gpuarrays_test("math/power") -end -@testitem "gpuarrays - random" setup=[TSGPUArrays] begin - gpuarrays_test("random") -end -@testitem "gpuarrays - reductions/== isequal" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/== isequal") -end -@testitem "gpuarrays - reductions/any all count" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/any all count") -end -@testitem "gpuarrays - reductions/mapreduce" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/mapreduce") -end -@testitem "gpuarrays - reductions/mapreducedim!" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/mapreducedim!") -end -@testitem "gpuarrays - reductions/mapreducedim!_large" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/mapreducedim!_large") -end -@testitem "gpuarrays - reductions/minimum maximum extrema" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/minimum maximum extrema") -end -@testitem "gpuarrays - reductions/reduce" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/reduce") -end -@testitem "gpuarrays - reductions/reducedim!" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/reducedim!") -end -@testitem "gpuarrays - reductions/sum prod" setup=[TSGPUArrays] begin - gpuarrays_test("reductions/sum prod") -end -@testitem "gpuarrays - statistics" setup=[TSGPUArrays] begin - gpuarrays_test("statistics") -end -@testitem "gpuarrays - uniformscaling" setup=[TSGPUArrays] begin - gpuarrays_test("uniformscaling") -end -@testitem "gpuarrays - alloc cache" setup=[TSGPUArrays] begin - gpuarrays_test("alloc cache") -end diff --git a/test/runtests.jl b/test/runtests.jl index f98ea29bf..045e6900c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,9 @@ using LinearAlgebra using ReTestItems using Test +import GPUArrays +include(joinpath(pkgdir(GPUArrays), "test", "testsuite.jl")) + macro grab_output(ex, io=stdout) quote mktemp() do fname, fout @@ -113,6 +116,32 @@ PrettyTables.pretty_table(data; column_labels=["Workers", "Device", "Tests"], fit_table_in_display_vertically=false, fit_table_in_display_horizontally=false) +# Hack to define GPUArrays `@testitems` dynamically - by writing them to a file. +function write_gpuarrays_tests() + template = """ + @testsetup module TSGPUArrays + export gpuarrays_test + + import GPUArrays, AMDGPU + include(joinpath(pkgdir(GPUArrays), "test", "testsuite.jl")) + + gpuarrays_test(test_name::String) = TestSuite.tests[test_name](AMDGPU.ROCArray) + end + """ + for test_name in keys(TestSuite.tests) + template = """ + $template + @testitem "gpuarrays - $test_name" setup=[TSGPUArrays] begin gpuarrays_test("$test_name") end + """ + end + + test_file = joinpath(dirname(@__FILE__), "gpuarrays_generated_tests.jl") + open(io -> write(io, template), test_file, "w") + @info "Writing GPUArrays test file: `$test_file`." + return +end +write_gpuarrays_tests() + runtests(AMDGPU; nworkers=np, nworker_threads=1, testitem_timeout=60 * 30) do ti for tt in TARGET_TESTS startswith(ti.name, tt) && return true