Skip to content

Commit

Permalink
Merge pull request #563 from JuliaGPU/tb/cached_config
Browse files Browse the repository at this point in the history
Include the compiler config in the runtime cache lookup.
  • Loading branch information
maleadt committed Apr 9, 2024
2 parents e9c4404 + 5330284 commit 679c9b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ end

# fast path: find an applicable CodeInstance and see if we have compiled it before
ci = ci_cache_lookup(ci_cache(job), src, world, world)::Union{Nothing,CodeInstance}
if ci !== nothing && haskey(cache, ci)
obj = cache[ci]
if ci !== nothing
key = (ci, cfg)
if haskey(cache, key)
obj = cache[key]
end
end

# slow path: compile and link
Expand All @@ -128,10 +131,13 @@ end
# we got here because of a *compile* hook; don't bother linking
return obj
end

obj = linker(job, asm)
ci = ci_cache_lookup(ci_cache(job), src, world, world)::CodeInstance
cache[ci] = obj

if ci === nothing
ci = ci_cache_lookup(ci_cache(job), src, world, world)::CodeInstance
key = (ci, cfg)
end
cache[key] = obj
end

return obj
Expand Down
10 changes: 6 additions & 4 deletions test/native_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ end
@eval @noinline $child(i) = i
@eval $kernel(i) = $child(i)+1

target = NativeCompilerTarget()
params = Native.CompilerParams()
config = CompilerConfig(target, params; kernel=false)

# smoke test
job, _ = Native.create_job(eval(kernel), (Int64,))
ir = sprint(io->GPUCompiler.code_llvm(io, job))
Expand Down Expand Up @@ -142,6 +138,12 @@ end
ir = Base.invokelatest(GPUCompiler.cached_compilation, cache, source, job.config, compiler, linker)
@test invocations[] == 3

# change in configuration
config = CompilerConfig(job.config; name="foobar")
ir = Base.invokelatest(GPUCompiler.cached_compilation, cache, source, config, compiler, linker)
@test invocations[] == 4
@test contains(ir, "foobar")

# tasks running in the background should keep on using the old version
c1, c2 = Condition(), Condition()
function background(job)
Expand Down

0 comments on commit 679c9b9

Please sign in to comment.