Skip to content

Commit 515c3e8

Browse files
authored
Merge pull request #291 from JuliaGPU/tb/runtime_intrinsics
Link the runtime when specific intrinsics occur.
2 parents 64296ac + 00629d2 commit 515c3e8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/driver.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const __llvm_initialized = Ref(false)
157157
if libraries
158158
runtime = load_runtime(job; ctx)
159159
runtime_fns = LLVM.name.(defs(runtime))
160+
runtime_intrinsics = ["julia.gc_alloc_obj"]
160161
end
161162

162163
@timeit_debug to "Library linking" begin
@@ -166,7 +167,7 @@ const __llvm_initialized = Ref(false)
166167
@timeit_debug to "target libraries" link_libraries!(job, ir, undefined_fns)
167168

168169
# GPU run-time library
169-
if any(fn -> fn in runtime_fns, undefined_fns)
170+
if any(fn -> fn in runtime_fns || fn in runtime_intrinsics, undefined_fns)
170171
@timeit_debug to "runtime library" link_library!(ir, runtime)
171172
end
172173
end

src/optim.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,11 @@ function lower_gc_frame!(fun::LLVM.Function)
322322
Builder(ctx) do builder
323323
# NOTE: this happens late during the pipeline, where we may have to
324324
# pass a kernel state arguments to the runtime function.
325-
state = kernel_state_type(job)
325+
state = if job.source.kernel
326+
kernel_state_type(job)
327+
else
328+
Nothing
329+
end
326330

327331
position!(builder, call)
328332
ptr = call!(builder, Runtime.get(:gc_pool_alloc), [sz]; state)

0 commit comments

Comments
 (0)