Skip to content

Commit 4b6ce98

Browse files
committed
Revert back to our hand-rolled test runner.
1 parent a9b5a82 commit 4b6ce98

21 files changed

+520
-230
lines changed

test/Project.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
4+
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
35
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
46
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
57
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
68
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
9+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
710
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
8-
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
11+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
912
SPIRV_LLVM_Translator_unified_jll = "85f0d8ed-5b39-5caa-b1ae-7472de402361"
1013
SPIRV_Tools_jll = "6ac6d60f-d740-5983-97d7-a4482c0689f4"
1114
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -14,3 +17,6 @@ demumble_jll = "1e29f10c-031c-5a83-9565-69cddfc27673"
1417

1518
[compat]
1619
Aqua = "0.8"
20+
21+
[extras]
22+
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
@testitem "Aqua" begin
2-
31
using Aqua
42

53
Aqua.test_all(GPUCompiler)
6-
7-
end

test/bpf_tests.jl renamed to test/bpf.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
@testitem "BPF" setup=[BPF, Helpers] begin
2-
3-
############################################################################################
4-
51
@testset "No-op" begin
62
kernel() = 0
73

@@ -40,5 +36,3 @@ end
4036
@test_throws GPUCompiler.InvalidIRError BPF.code_execution(kernel, (Int,))
4137
end
4238
end
43-
44-
end

test/examples_tests.jl renamed to test/examples.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@testitem "examples" begin
2-
31
function find_sources(path::String, sources=String[])
42
if isdir(path)
53
for entry in readdir(path)
@@ -23,5 +21,3 @@ cd(dir) do
2321
@test success(pipeline(`$cmd $example`, stderr=stderr))
2422
end
2523
end
26-
27-
end

test/gcn_tests.jl renamed to test/gcn.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
@testitem "GCN" setup=[GCN, Helpers] begin
2-
3-
@inline sink_gcn(i) = sink(i, Val(5))
4-
5-
@test GCNCompilerTarget(dev_isa="gfx900") == GCNCompilerTarget("gfx900")
6-
7-
############################################################################################
8-
91
@testset "IR" begin
102

113
@testset "kernel calling convention" begin
@@ -222,7 +214,3 @@ end
222214
end
223215

224216
end
225-
226-
############################################################################################
227-
228-
end

test/bpf_testsetup.jl renamed to test/helpers/bpf.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
@testsetup module BPF
1+
module BPF
22

3-
using GPUCompiler
3+
using ..GPUCompiler
4+
import ..TestRuntime
45

5-
6-
# create a native test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
96
struct CompilerParams <: AbstractCompilerParams end
107
GPUCompiler.runtime_module(::CompilerJob{<:Any,CompilerParams}) = TestRuntime
118

test/gcn_testsetup.jl renamed to test/helpers/gcn.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
@testsetup module GCN
1+
module GCN
22

3-
using GPUCompiler
3+
using ..GPUCompiler
4+
import ..TestRuntime
45

5-
6-
# create a GCN-based test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
96
struct CompilerParams <: AbstractCompilerParams end
107
GPUCompiler.runtime_module(::CompilerJob{<:Any,CompilerParams}) = TestRuntime
118

test/metal_testsetup.jl renamed to test/helpers/metal.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
@testsetup module Metal
1+
module Metal
22

3-
using GPUCompiler
3+
using ..GPUCompiler
4+
import ..TestRuntime
45

5-
6-
# create a Metal test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
96
struct CompilerParams <: AbstractCompilerParams end
107
GPUCompiler.runtime_module(::CompilerJob{<:Any,CompilerParams}) = TestRuntime
118

test/native_testsetup.jl renamed to test/helpers/native.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
@testsetup module Native
1+
module Native
22

3-
using GPUCompiler
4-
5-
6-
# create a native test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
3+
using ..GPUCompiler
4+
import ..TestRuntime
95

106
# local method table for device functions
117
Base.Experimental.@MethodTable(test_method_table)

test/precompile_testsetup.jl renamed to test/helpers/precompile.jl

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
@testsetup module Precompile
2-
3-
using Test
4-
using ReTestItems
5-
6-
export precompile_test_harness, check_presence, create_standalone
7-
81
function precompile_test_harness(@nospecialize(f), testset::String)
92
@testset "$testset" begin
103
precompile_test_harness(f, true)
@@ -50,19 +43,18 @@ function check_presence(mi, token)
5043
end
5144

5245
function create_standalone(load_path, name::String, file)
53-
cp(joinpath(@__DIR__, "runtime.jl"), joinpath(load_path, "runtime.jl"), force=true)
46+
code = :(
47+
module $(Symbol(name))
5448

55-
TS = include(file)
56-
code = TS.code
57-
if code.head == :begin
58-
code.head = :block
59-
end
60-
@assert code.head == :block
61-
code = Expr(:module, true, Symbol(name), code)
49+
using GPUCompiler
50+
51+
include($(joinpath(@__DIR__, "runtime.jl")))
52+
include($(joinpath(@__DIR__, file)))
53+
54+
end
55+
)
6256

6357
# Write out the test setup as a micro package
6458
write(joinpath(load_path, "$name.jl"), string(code))
6559
Base.compilecache(Base.PkgId(name))
6660
end
67-
68-
end # testsetup

test/ptx_testsetup.jl renamed to test/helpers/ptx.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
@testsetup module PTX
1+
module PTX
22

3-
using GPUCompiler
3+
using ..GPUCompiler
4+
import ..TestRuntime
45

5-
6-
# create a PTX-based test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
96
struct CompilerParams <: AbstractCompilerParams end
107

118
PTXCompilerJob = CompilerJob{PTXCompilerTarget,CompilerParams}
File renamed without changes.

test/spirv_testsetup.jl renamed to test/helpers/spirv.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
@testsetup module SPIRV
1+
module SPIRV
22

3-
using GPUCompiler
3+
using ..GPUCompiler
4+
import ..TestRuntime
45

5-
6-
# create a SPIRV-based test compiler, and generate reflection methods for it
7-
8-
include("runtime.jl")
96
struct CompilerParams <: AbstractCompilerParams end
107
GPUCompiler.runtime_module(::CompilerJob{<:Any,CompilerParams}) = TestRuntime
118

test/helper_testsetup.jl renamed to test/helpers/test.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
@testsetup module Helpers
2-
3-
using Test
4-
5-
export @test_throws_message, sink
6-
71
# @test_throw, with additional testing for the exception message
82
macro test_throws_message(f, typ, ex...)
93
quote
@@ -41,5 +35,3 @@ end
4135
ret i64 %value"""
4236
return :(Base.llvmcall($llvmcall_str, T, Tuple{T}, i))
4337
end
44-
45-
end

test/metal_tests.jl renamed to test/metal.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
@testitem "Metal" setup=[Metal, Helpers] begin
2-
3-
using LLVM
4-
5-
############################################################################################
6-
71
@testset "IR" begin
82

93
@testset "kernel functions" begin
@@ -110,7 +104,6 @@ end
110104
return
111105
end
112106

113-
114107
ir = sprint(io->Metal.code_llvm(io, kernel1, Tuple{Core.LLVMPtr{Float32,1}}; validate=true))
115108
@test occursin("@metal_os_log", ir)
116109

@@ -145,5 +138,3 @@ end
145138
end
146139

147140
end
148-
149-
end

test/native_tests.jl renamed to test/native.jl

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
@testitem "native" setup=[Native, Helpers] begin
2-
3-
using Test
4-
5-
############################################################################################
6-
71
@testset "reflection" begin
82
job, _ = Native.create_job(identity, (Int,))
93

@@ -233,7 +227,7 @@ end
233227
@test "We did not crash!" != ""
234228
end
235229

236-
@testset "CUDAnative.jl#278" begin
230+
@testset "CUDAjl#278" begin
237231
# codegen idempotency
238232
# NOTE: this isn't fixed, but surfaces here due to bad inference of checked_sub
239233
# NOTE: with the fix to print_to_string this doesn't error anymore,
@@ -563,18 +557,17 @@ end
563557
["jl_invoke", "apply_iterate",
564558
"inttoptr", "apply_type"])
565559
end
566-
end # testitem
567560

568-
@testitem "native precompile" setup=[Precompile,] begin
561+
############################################################################################
562+
563+
@testset "precompile" begin
569564

570-
using Test
571565
precompile_test_harness("Inference caching") do load_path
572566
# Write out the Native test setup as a micro package
573-
create_standalone(load_path, "NativeCompiler", "native_testsetup.jl")
567+
create_standalone(load_path, "TestCompiler", "native.jl")
574568

575569
write(joinpath(load_path, "InferenceCaching.jl"), :(module InferenceCaching
576-
import NativeCompiler
577-
import GPUCompiler
570+
import TestCompiler
578571
using PrecompileTools
579572

580573
function kernel(A, x)
@@ -583,13 +576,13 @@ precompile_test_harness("Inference caching") do load_path
583576
end
584577

585578
let
586-
job, _ = NativeCompiler.create_job(kernel, (Vector{Int}, Int))
579+
job, _ = TestCompiler.Native.create_job(kernel, (Vector{Int}, Int))
587580
precompile(job)
588581
end
589582

590583
# identity is foreign
591584
@setup_workload begin
592-
job, _ = NativeCompiler.create_job(identity, (Int,))
585+
job, _ = TestCompiler.Native.create_job(identity, (Int,))
593586
@compile_workload begin
594587
precompile(job)
595588
end
@@ -598,13 +591,13 @@ precompile_test_harness("Inference caching") do load_path
598591

599592
Base.compilecache(Base.PkgId("InferenceCaching"))
600593
@eval let
601-
import NativeCompiler
594+
import TestCompiler
602595

603596
# Check that no cached entry is present
604597
identity_mi = GPUCompiler.methodinstance(typeof(identity), Tuple{Int})
605598

606599
token = let
607-
job, _ = NativeCompiler.create_job(identity, (Int,))
600+
job, _ = TestCompiler.Native.create_job(identity, (Int,))
608601
GPUCompiler.ci_cache_token(job)
609602
end
610603
@test !check_presence(identity_mi, token)
@@ -624,21 +617,22 @@ precompile_test_harness("Inference caching") do load_path
624617
GPUCompiler.enable_disk_cache!()
625618
@test GPUCompiler.disk_cache_enabled() == true
626619

627-
job, _ = NativeCompiler.create_job(InferenceCaching.kernel, (Vector{Int}, Int))
620+
job, _ = TestCompiler.Native.create_job(InferenceCaching.kernel, (Vector{Int}, Int))
628621
@assert job.source == kernel_mi
629622
ci = GPUCompiler.ci_cache_lookup(GPUCompiler.ci_cache(job), job.source, job.world, job.world)
630623
@assert ci !== nothing
631624
@assert ci.inferred !== nothing
632625
path = GPUCompiler.cache_file(ci, job.config)
633626
@test path !== nothing
634627
@test !ispath(path)
635-
NativeCompiler.cached_execution(InferenceCaching.kernel, (Vector{Int}, Int))
628+
TestCompiler.Native.cached_execution(InferenceCaching.kernel, (Vector{Int}, Int))
636629
@test ispath(path)
637630
GPUCompiler.clear_disk_cache!()
638631
@test !ispath(path)
632+
633+
GPUCompiler.enable_disk_cache!(false)
634+
@test GPUCompiler.disk_cache_enabled() == false
639635
end
640636
end
641637

642-
############################################################################################
643-
644638
end

0 commit comments

Comments
 (0)