From c30bde44d0ea23f0b1e03152a03d8c343b9bca75 Mon Sep 17 00:00:00 2001 From: Sukera Date: Thu, 7 Sep 2023 21:15:42 +0200 Subject: [PATCH 1/3] Add a function to reset the compile cache --- src/GPUCompiler.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/GPUCompiler.jl b/src/GPUCompiler.jl index 02301ade..9cdfca2b 100644 --- a/src/GPUCompiler.jl +++ b/src/GPUCompiler.jl @@ -51,7 +51,10 @@ compile_cache = "" # defined in __init__() function __init__() STDERR_HAS_COLOR[] = get(stderr, :color, false) + create_compile_cache() +end +function create_compile_cache() dir = @get_scratch!("compiled") ## add the Julia version dir = joinpath(dir, "v$(VERSION.major).$(VERSION.minor)") @@ -64,4 +67,10 @@ function __init__() global compile_cache = dir end +function reset_compile_cache() + dir = @get_scratch!("compiled") + rm(dir; force=true, recursive=true) + create_compile_cache() +end + end # module From 8c49b2677fdee0fa2ede47d21c0ef7075db1cc6a Mon Sep 17 00:00:00 2001 From: Sukera Date: Thu, 7 Sep 2023 21:23:23 +0200 Subject: [PATCH 2/3] Remove old function, add lock to new function --- src/GPUCompiler.jl | 10 ++++++++-- src/rtlib.jl | 10 ---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/GPUCompiler.jl b/src/GPUCompiler.jl index 9cdfca2b..fea08292 100644 --- a/src/GPUCompiler.jl +++ b/src/GPUCompiler.jl @@ -67,10 +67,16 @@ function create_compile_cache() global compile_cache = dir end +# remove the existing cache +# NOTE: call this function from global scope, so any change triggers recompilation. function reset_compile_cache() dir = @get_scratch!("compiled") - rm(dir; force=true, recursive=true) - create_compile_cache() + lock(runtime_lock) do + rm(dir; force=true, recursive=true) + create_compile_cache() + end + + return end end # module diff --git a/src/rtlib.jl b/src/rtlib.jl index 7d0000ac..6c1ea0f8 100644 --- a/src/rtlib.jl +++ b/src/rtlib.jl @@ -144,13 +144,3 @@ const runtime_lock = ReentrantLock() return lib end end - -# remove the existing cache -# NOTE: call this function from global scope, so any change triggers recompilation. -function reset_runtime() - lock(runtime_lock) do - rm(compile_cache; recursive=true, force=true) - end - - return -end From 83d24cb9c87a9d9126a0860088d47a3619555319 Mon Sep 17 00:00:00 2001 From: Sukera Date: Thu, 7 Sep 2023 21:24:37 +0200 Subject: [PATCH 3/3] Add backwards compatibility for reset_runtime --- src/GPUCompiler.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GPUCompiler.jl b/src/GPUCompiler.jl index fea08292..bae599c0 100644 --- a/src/GPUCompiler.jl +++ b/src/GPUCompiler.jl @@ -78,5 +78,7 @@ function reset_compile_cache() return end +# backwards compatibility +const reset_runtime = reset_compile_cache end # module