File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 121
121
122
122
const runtime_lock = ReentrantLock ()
123
123
124
+ const runtime_cache = Dict {String, Vector{UInt8}} ()
125
+
124
126
@locked function load_runtime (@nospecialize (job:: CompilerJob ))
125
127
global compile_cache
126
128
if compile_cache === nothing # during precompilation
@@ -135,15 +137,14 @@ const runtime_lock = ReentrantLock()
135
137
name = " runtime_$(slug) .bc"
136
138
path = joinpath (compile_cache, name)
137
139
138
- lib = try
139
- if ispath (path)
140
- open (path) do io
141
- parse (LLVM. Module, read (io))
142
- end
140
+ # cache the runtime library on disk and in memory
141
+ lib = if haskey (runtime_cache, slug)
142
+ parse (LLVM. Module, runtime_cache[slug])
143
+ elseif ispath (path)
144
+ runtime_cache[slug] = open (path) do io
145
+ read (io)
143
146
end
144
- catch ex
145
- @warn " Failed to load GPU runtime library at $path " exception= (ex, catch_backtrace ())
146
- nothing
147
+ parse (LLVM. Module, runtime_cache[slug])
147
148
end
148
149
149
150
if lib === nothing
You can’t perform that action at this time.
0 commit comments