Skip to content

Commit 679c9b9

Browse files
authored
Merge pull request #563 from JuliaGPU/tb/cached_config
Include the compiler config in the runtime cache lookup.
2 parents e9c4404 + 5330284 commit 679c9b9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/execution.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ end
115115

116116
# fast path: find an applicable CodeInstance and see if we have compiled it before
117117
ci = ci_cache_lookup(ci_cache(job), src, world, world)::Union{Nothing,CodeInstance}
118-
if ci !== nothing && haskey(cache, ci)
119-
obj = cache[ci]
118+
if ci !== nothing
119+
key = (ci, cfg)
120+
if haskey(cache, key)
121+
obj = cache[key]
122+
end
120123
end
121124

122125
# slow path: compile and link
@@ -128,10 +131,13 @@ end
128131
# we got here because of a *compile* hook; don't bother linking
129132
return obj
130133
end
131-
132134
obj = linker(job, asm)
133-
ci = ci_cache_lookup(ci_cache(job), src, world, world)::CodeInstance
134-
cache[ci] = obj
135+
136+
if ci === nothing
137+
ci = ci_cache_lookup(ci_cache(job), src, world, world)::CodeInstance
138+
key = (ci, cfg)
139+
end
140+
cache[key] = obj
135141
end
136142

137143
return obj

test/native_tests.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ end
7878
@eval @noinline $child(i) = i
7979
@eval $kernel(i) = $child(i)+1
8080

81-
target = NativeCompilerTarget()
82-
params = Native.CompilerParams()
83-
config = CompilerConfig(target, params; kernel=false)
84-
8581
# smoke test
8682
job, _ = Native.create_job(eval(kernel), (Int64,))
8783
ir = sprint(io->GPUCompiler.code_llvm(io, job))
@@ -142,6 +138,12 @@ end
142138
ir = Base.invokelatest(GPUCompiler.cached_compilation, cache, source, job.config, compiler, linker)
143139
@test invocations[] == 3
144140

141+
# change in configuration
142+
config = CompilerConfig(job.config; name="foobar")
143+
ir = Base.invokelatest(GPUCompiler.cached_compilation, cache, source, config, compiler, linker)
144+
@test invocations[] == 4
145+
@test contains(ir, "foobar")
146+
145147
# tasks running in the background should keep on using the old version
146148
c1, c2 = Condition(), Condition()
147149
function background(job)

0 commit comments

Comments
 (0)