Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.26.4"

[deps]
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand All @@ -15,11 +16,12 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
ExprTools = "0.1"
FileWatching = "1"
InteractiveUtils = "1"
LLVM = "7.1"
Libdl = "1"
Logging = "1"
UUIDs = "1"
LLVM = "7.1"
Scratch = "1"
TimerOutputs = "0.5"
UUIDs = "1"
julia = "1.8"
17 changes: 6 additions & 11 deletions src/rtlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ end
# GPU run-time library
#

using FileWatching.Pidfile: mkpidlock


## higher-level functionality to work with runtime functions

Expand Down Expand Up @@ -115,10 +117,8 @@ function build_runtime(@nospecialize(job::CompilerJob))
mod
end

const runtime_lock = ReentrantLock()

@locked function load_runtime(@nospecialize(job::CompilerJob))
lock(runtime_lock) do
mkpidlock("$(compile_cache).lock"; stale_age=5) do
slug = runtime_slug(job)
if !supports_typed_pointers(context())
slug *= "-opaque"
Expand All @@ -139,14 +139,8 @@ const runtime_lock = ReentrantLock()

if lib === nothing
@debug "Building the GPU runtime library at $path"
mkpath(compile_cache)
lib = build_runtime(job)

# atomic write to disk
temp_path, io = mktemp(dirname(path); cleanup=false)
write(io, lib)
close(io)
Base.rename(temp_path, path; force=true)
write(path, lib)
end

return lib
Expand All @@ -156,8 +150,9 @@ end
# remove the existing cache
# NOTE: call this function from global scope, so any change triggers recompilation.
function reset_runtime()
lock(runtime_lock) do
mkpidlock("$(compile_cache).lock"; stale_age=5) do
rm(compile_cache; recursive=true, force=true)
mkpath(compile_cache)
end

return
Expand Down