Skip to content

Commit c57af09

Browse files
committed
Use a PTX-specific runtime that doesn't get optimized away entirely.
Otherwise we can't properly test the kernel state handling.
1 parent c2336d2 commit c57af09

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/definitions/ptx.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ GPUCompiler.kernel_state_type(@nospecialize(job::PTXCompilerJob)) = PTXKernelSta
1616
ptx_kernel_state() =
1717
unsafe_load(convert(Ptr{PTXKernelState}, GPUCompiler.kernel_state_pointer()))
1818

19+
# a version of the test runtime that has some side effects, loading the kernel state
20+
# (so that we can test if kernel state arguments are appropriately optimized away)
21+
module PTXTestRuntime
22+
using ..GPUCompiler
23+
import ..PTXKernelState
24+
25+
kernel_state() = unsafe_load(convert(Ptr{PTXKernelState}, GPUCompiler.kernel_state_pointer()))
26+
27+
function signal_exception()
28+
kernel_state()
29+
return
30+
end
31+
32+
# dummy methods
33+
# HACK: if malloc returns 0 or traps, all calling functions (like jl_box_*)
34+
# get reduced to a trap, which really messes with our test suite.
35+
malloc(sz) = Ptr{Cvoid}(Int(0xDEADBEEF))
36+
report_oom(sz) = return
37+
report_exception(ex) = return
38+
report_exception_name(ex) = return
39+
report_exception_frame(idx, func, file, line) = return
40+
end
41+
GPUCompiler.runtime_module(::PTXCompilerJob) = PTXTestRuntime
42+
1943
function ptx_job(@nospecialize(func), @nospecialize(types); kernel::Bool=false,
2044
minthreads=nothing, maxthreads=nothing, blocks_per_sm=nothing,
2145
maxregs=nothing, kwargs...)

0 commit comments

Comments
 (0)