Skip to content

Commit 0a57303

Browse files
committed
Fix precompilation harness.
1 parent 339330c commit 0a57303

File tree

3 files changed

+27
-35
lines changed

3 files changed

+27
-35
lines changed

test/helpers/precompile.jl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,10 @@ function precompile_test_harness(@nospecialize(f), separate::Bool)
1111
pushfirst!(DEPOT_PATH, load_cache_path)
1212
f(load_path)
1313
finally
14-
try
15-
rm(load_path, force=true, recursive=true)
16-
catch err
17-
@show err
18-
end
19-
if separate
20-
try
21-
rm(load_cache_path, force=true, recursive=true)
22-
catch err
23-
@show err
24-
end
25-
end
26-
filter!(()(load_path), LOAD_PATH)
27-
separate && filter!(()(load_cache_path), DEPOT_PATH)
14+
popfirst!(DEPOT_PATH)
15+
popfirst!(LOAD_PATH)
16+
rm(load_path, force=true, recursive=true)
17+
separate && rm(load_cache_path, force=true, recursive=true)
2818
end
2919
nothing
3020
end

test/native/precompile.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
precompile_test_harness("Inference caching") do load_path
44
# Write out the Native test setup as a micro package
5-
create_standalone(load_path, "TestCompiler", "native.jl")
5+
create_standalone(load_path, "NativeCompiler", "native.jl")
66

7-
write(joinpath(load_path, "InferenceCaching.jl"), :(module InferenceCaching
8-
import TestCompiler
7+
write(joinpath(load_path, "NativeBackend.jl"), :(
8+
module NativeBackend
9+
import NativeCompiler
910
using PrecompileTools
1011

1112
function kernel(A, x)
@@ -14,36 +15,36 @@ precompile_test_harness("Inference caching") do load_path
1415
end
1516

1617
let
17-
job, _ = TestCompiler.Native.create_job(kernel, (Vector{Int}, Int))
18+
job, _ = NativeCompiler.Native.create_job(kernel, (Vector{Int}, Int))
1819
precompile(job)
1920
end
2021

2122
# identity is foreign
2223
@setup_workload begin
23-
job, _ = TestCompiler.Native.create_job(identity, (Int,))
24+
job, _ = NativeCompiler.Native.create_job(identity, (Int,))
2425
@compile_workload begin
2526
precompile(job)
2627
end
2728
end
2829
end) |> string)
2930

30-
Base.compilecache(Base.PkgId("InferenceCaching"))
31+
Base.compilecache(Base.PkgId("NativeBackend"))
3132
@eval let
32-
import TestCompiler
33+
import NativeCompiler
3334

3435
# Check that no cached entry is present
3536
identity_mi = GPUCompiler.methodinstance(typeof(identity), Tuple{Int})
3637

3738
token = let
38-
job, _ = TestCompiler.Native.create_job(identity, (Int,))
39+
job, _ = NativeCompiler.Native.create_job(identity, (Int,))
3940
GPUCompiler.ci_cache_token(job)
4041
end
4142
@test !check_presence(identity_mi, token)
4243

43-
using InferenceCaching
44+
using NativeBackend
4445

4546
# Check that kernel survived
46-
kernel_mi = GPUCompiler.methodinstance(typeof(InferenceCaching.kernel), Tuple{Vector{Int}, Int})
47+
kernel_mi = GPUCompiler.methodinstance(typeof(NativeBackend.kernel), Tuple{Vector{Int}, Int})
4748
@test check_presence(kernel_mi, token)
4849

4950
# check that identity survived
@@ -55,15 +56,15 @@ precompile_test_harness("Inference caching") do load_path
5556
GPUCompiler.enable_disk_cache!()
5657
@test GPUCompiler.disk_cache_enabled() == true
5758

58-
job, _ = TestCompiler.Native.create_job(InferenceCaching.kernel, (Vector{Int}, Int))
59+
job, _ = NativeCompiler.Native.create_job(NativeBackend.kernel, (Vector{Int}, Int))
5960
@assert job.source == kernel_mi
6061
ci = GPUCompiler.ci_cache_lookup(GPUCompiler.ci_cache(job), job.source, job.world, job.world)
6162
@assert ci !== nothing
6263
@assert ci.inferred !== nothing
6364
path = GPUCompiler.cache_file(ci, job.config)
6465
@test path !== nothing
6566
@test !ispath(path)
66-
TestCompiler.Native.cached_execution(InferenceCaching.kernel, (Vector{Int}, Int))
67+
NativeCompiler.Native.cached_execution(NativeBackend.kernel, (Vector{Int}, Int))
6768
@test ispath(path)
6869
GPUCompiler.clear_disk_cache!()
6970
@test !ispath(path)

test/ptx/precompile.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
precompile_test_harness("Inference caching") do load_path
22
# Write out the PTX test helpers as a micro package
3-
create_standalone(load_path, "TestCompiler", "ptx.jl")
3+
create_standalone(load_path, "PTXCompiler", "ptx.jl")
44

5-
write(joinpath(load_path, "InferenceCaching.jl"), :(module InferenceCaching
6-
import TestCompiler
5+
write(joinpath(load_path, "PTXBackend.jl"), :(
6+
module PTXBackend
7+
import PTXCompiler
78
using PrecompileTools
89

910
function kernel()
1011
return
1112
end
1213

1314
let
14-
job, _ = TestCompiler.PTX.create_job(kernel, ())
15+
job, _ = PTXCompiler.PTX.create_job(kernel, ())
1516
precompile(job)
1617
end
1718

1819
# identity is foreign
1920
@setup_workload begin
20-
job, _ = TestCompiler.PTX.create_job(identity, (Int,))
21+
job, _ = PTXCompiler.PTX.create_job(identity, (Int,))
2122
@compile_workload begin
2223
precompile(job)
2324
end
2425
end
2526
end) |> string)
2627

27-
Base.compilecache(Base.PkgId("InferenceCaching"))
28+
Base.compilecache(Base.PkgId("PTXBackend"))
2829
@eval let
29-
import TestCompiler
30+
import PTXCompiler
3031

3132
# Check that no cached entry is present
3233
identity_mi = GPUCompiler.methodinstance(typeof(identity), Tuple{Int})
@@ -41,10 +42,10 @@ precompile_test_harness("Inference caching") do load_path
4142
ci = isdefined(ci, :next) ? ci.next : nothing
4243
end
4344

44-
using InferenceCaching
45+
using PTXBackend
4546

4647
# Check that kernel survived
47-
kernel_mi = GPUCompiler.methodinstance(typeof(InferenceCaching.kernel), Tuple{})
48+
kernel_mi = GPUCompiler.methodinstance(typeof(PTXBackend.kernel), Tuple{})
4849
@test check_presence(kernel_mi, token)
4950

5051
# check that identity survived

0 commit comments

Comments
 (0)