Skip to content

Commit 4d9b27f

Browse files
authored
Merge pull request #631 from JuliaGPU/tb/nightly
Re-enable nightly testing.
2 parents d6fde40 + 6540a44 commit 4d9b27f

File tree

8 files changed

+196
-122
lines changed

8 files changed

+196
-122
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
version: ['1.10', 'pre'] # 'nightly'
21+
version: ['1.10', 'pre', 'nightly']
2222
os: [ubuntu-latest, macOS-latest, windows-latest]
2323
arch: [x64]
2424
llvm_args: ['']
2525
include:
2626
# starting with Julia 1.10, we can enable opaque pointers
27+
# from Juila 1.12 on, this is the default.
2728
- version: '1.10'
2829
os: 'ubuntu-latest'
2930
arch: 'x64'
@@ -48,18 +49,6 @@ jobs:
4849
os: 'windows-latest'
4950
arch: 'x64'
5051
llvm_args: '--opaque-pointers'
51-
#- version: 'nightly'
52-
# os: 'ubuntu-latest'
53-
# arch: 'x64'
54-
# llvm_args: '--opaque-pointers'
55-
#- version: 'nightly'
56-
# os: 'macOS-latest'
57-
# arch: 'x64'
58-
# llvm_args: '--opaque-pointers'
59-
#- version: 'nightly'
60-
# os: 'windows-latest'
61-
# arch: 'x64'
62-
# llvm_args: '--opaque-pointers'
6352
steps:
6453
- uses: actions/checkout@v4
6554

src/interface.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ method_table(@nospecialize(job::CompilerJob)) = GLOBAL_METHOD_TABLE
252252

253253
# the inference parameters to use when constructing the GPUInterpreter
254254
function inference_params(@nospecialize(job::CompilerJob))
255-
return CC.InferenceParams(; unoptimize_throw_blocks=false)
255+
if VERSION >= v"1.12.0-DEV.1017"
256+
CC.InferenceParams()
257+
else
258+
CC.InferenceParams(; unoptimize_throw_blocks=false)
259+
end
256260
end
257261

258262
# the optimization parameters to use when constructing the GPUInterpreter

src/utils.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ end
9595
# XXX: it's not allowed to switch tasks while under this lock, can we guarantee that?
9696
# its probably easier to start using our own LLVM context when that's possible.
9797
macro locked(ex)
98+
if VERSION >= v"1.12.0-DEV.769"
99+
# no need to handle locking; it's taken care of by the engine
100+
# as long as we use a correct cache owner token.
101+
return esc(ex)
102+
end
103+
98104
def = splitdef(ex)
99105
def[:body] = quote
100106
ccall(:jl_typeinf_lock_begin, Cvoid, ())
@@ -109,6 +115,10 @@ end
109115

110116
# HACK: temporarily unlock again to perform a task switch
111117
macro unlocked(ex)
118+
if VERSION >= v"1.12.0-DEV.769"
119+
return esc(ex)
120+
end
121+
112122
def = splitdef(ex)
113123
def[:body] = quote
114124
ccall(:jl_typeinf_lock_end, Cvoid, ())

src/validation.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,18 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst)
218218
@safe_debug "Decoding arguments to jl_get_binding_or_error failed" inst bb=LLVM.parent(inst)
219219
push!(errors, (DELAYED_BINDING, bt, nothing))
220220
end
221+
elseif fn == "jl_reresolve_binding_value_seqcst" || fn == "ijl_reresolve_binding_value_seqcst"
222+
try
223+
# pry the binding from the IR
224+
expr = arguments(inst)[1]::ConstantExpr
225+
expr = first(operands(expr))::ConstantInt # get rid of inttoptr
226+
ptr = Ptr{Any}(convert(Int, expr))
227+
obj = Base.unsafe_pointer_to_objref(ptr)
228+
push!(errors, (DELAYED_BINDING, bt, obj.globalref))
229+
catch e
230+
@safe_debug "Decoding arguments to jl_reresolve_binding_value_seqcst failed" inst bb=LLVM.parent(inst)
231+
push!(errors, (DELAYED_BINDING, bt, nothing))
232+
end
221233
elseif fn == "jl_invoke" || fn == "ijl_invoke"
222234
try
223235
f, args, nargs, meth = arguments(inst)

test/gcn_tests.jl

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,44 +74,51 @@ end
7474
# bug: depending on a child function from multiple parents resulted in
7575
# the child only being present once
7676

77-
@noinline child(i) = sink_gcn(i)
78-
function parent1(i)
79-
child(i)
80-
return
77+
mod = @eval module $(gensym())
78+
export child, parent1, parent2
79+
80+
@noinline child(i) = sink_gcn(i)
81+
function parent1(i)
82+
child(i)
83+
return
84+
end
85+
function parent2(i)
86+
child(i+1)
87+
return
88+
end
8189
end
8290

83-
asm = sprint(io->GCN.code_native(io, parent1, Tuple{Int}; dump_module=true))
91+
asm = sprint(io->GCN.code_native(io, mod.parent1, Tuple{Int}; dump_module=true))
8492
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child_\d*,@function", asm)
8593

86-
function parent2(i)
87-
child(i+1)
88-
return
89-
end
90-
91-
asm = sprint(io->GCN.code_native(io, parent2, Tuple{Int}; dump_module=true))
94+
asm = sprint(io->GCN.code_native(io, mod.parent2, Tuple{Int}; dump_module=true))
9295
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child_\d*,@function", asm)
9396
end
9497

9598
@testset "child function reuse bis" begin
9699
# bug: similar, but slightly different issue as above
97100
# in the case of two child functions
98-
@noinline child1(i) = sink_gcn(i)
99-
@noinline child2(i) = sink_gcn(i+1)
100-
function parent1(i)
101-
child1(i) + child2(i)
102-
return
101+
102+
mod = @eval module $(gensym())
103+
export parent1, parent2, child1, child2
104+
105+
@noinline child1(i) = sink_gcn(i)
106+
@noinline child2(i) = sink_gcn(i+1)
107+
function parent1(i)
108+
child1(i) + child2(i)
109+
return
110+
end
111+
function parent2(i)
112+
child1(i+1) + child2(i+1)
113+
return
114+
end
103115
end
104116

105-
asm = sprint(io->GCN.code_native(io, parent1, Tuple{Int}; dump_module=true))
117+
asm = sprint(io->GCN.code_native(io, mod.parent1, Tuple{Int}; dump_module=true))
106118
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child1_\d*,@function", asm)
107119
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child2_\d*,@function", asm)
108120

109-
function parent2(i)
110-
child1(i+1) + child2(i+1)
111-
return
112-
end
113-
114-
asm = sprint(io->GCN.code_native(io, parent2, Tuple{Int}; dump_module=true))
121+
asm = sprint(io->GCN.code_native(io, mod.parent2, Tuple{Int}; dump_module=true))
115122
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child1_\d*,@function", asm)
116123
@test occursin(r"\.type.*julia_[[:alnum:]_.]*child2_\d*,@function", asm)
117124
end

test/native_tests.jl

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -388,46 +388,61 @@ Base.unsafe_trunc(::Type{Int}, x::CleverType) = unsafe_trunc(Int, x.x)
388388
end
389389

390390
@testset "invalid LLVM IR" begin
391-
foobar(i) = println(i)
391+
mod = @eval module $(gensym())
392+
export foobar
393+
foobar(i) = println(i)
394+
end
392395

393396
@test_throws_message(InvalidIRError,
394-
Native.code_execution(foobar, Tuple{Int})) do msg
397+
Native.code_execution(mod.foobar, Tuple{Int})) do msg
395398
occursin("invalid LLVM IR", msg) &&
396399
(occursin(GPUCompiler.RUNTIME_FUNCTION, msg) ||
397400
occursin(GPUCompiler.UNKNOWN_FUNCTION, msg) ||
398401
occursin(GPUCompiler.DYNAMIC_CALL, msg)) &&
399402
occursin("[1] println", msg) &&
400-
occursin(r"\[2\] .*foobar", msg)
403+
occursin("[2] foobar", msg)
401404
end
402405
end
403406

404407
@testset "invalid LLVM IR (ccall)" begin
405-
foobar(p) = (unsafe_store!(p, ccall(:time, Cint, ())); nothing)
408+
mod = @eval module $(gensym())
409+
export foobar
410+
function foobar(p)
411+
unsafe_store!(p, ccall(:time, Cint, ()))
412+
return
413+
end
414+
end
406415

407416
@test_throws_message(InvalidIRError,
408-
Native.code_execution(foobar, Tuple{Ptr{Int}})) do msg
417+
Native.code_execution(mod.foobar, Tuple{Ptr{Int}})) do msg
409418
if VERSION >= v"1.11-"
410419
occursin("invalid LLVM IR", msg) &&
411420
occursin(GPUCompiler.LAZY_FUNCTION, msg) &&
412421
occursin("call to time", msg) &&
413-
occursin(r"\[1\] .*foobar", msg)
422+
occursin("[1] foobar", msg)
414423
else
415424
occursin("invalid LLVM IR", msg) &&
416425
occursin(GPUCompiler.POINTER_FUNCTION, msg) &&
417-
occursin(r"\[1\] .*foobar", msg)
426+
occursin("[1] foobar", msg)
418427
end
419428
end
420429
end
421430

422431
@testset "delayed bindings" begin
423-
kernel() = (undefined; return)
432+
mod = @eval module $(gensym())
433+
export kernel
434+
function kernel()
435+
undefined
436+
return
437+
end
438+
end
424439

425440
@test_throws_message(InvalidIRError,
426-
Native.code_execution(kernel, Tuple{})) do msg
441+
Native.code_execution(mod.kernel, Tuple{})) do msg
427442
occursin("invalid LLVM IR", msg) &&
428443
occursin(GPUCompiler.DELAYED_BINDING, msg) &&
429-
occursin("use of 'undefined'", msg) &&
430-
occursin(r"\[1\] .*kernel", msg)
444+
occursin(r"use of '.*undefined'", msg) &&
445+
occursin("[1] kernel", msg)
431446
end
432447
end
433448

@@ -442,15 +457,18 @@ end
442457
occursin("invalid LLVM IR", msg) &&
443458
occursin(GPUCompiler.DYNAMIC_CALL, msg) &&
444459
occursin("call to nospecialize_child", msg) &&
445-
occursin(r"\[1\] kernel", msg)
460+
occursin("[1] kernel", msg)
446461
end
447462
end
448463

449464
@testset "dynamic call (apply)" begin
450-
func() = println(1)
465+
mod = @eval module $(gensym())
466+
export func
467+
func() = println(1)
468+
end
451469

452470
@test_throws_message(InvalidIRError,
453-
Native.code_execution(func, Tuple{})) do msg
471+
Native.code_execution(mod.func, Tuple{})) do msg
454472
occursin("invalid LLVM IR", msg) &&
455473
occursin(GPUCompiler.DYNAMIC_CALL, msg) &&
456474
occursin("call to println", msg) &&

0 commit comments

Comments
 (0)