Skip to content
Open
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
17 changes: 17 additions & 0 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,29 @@ jobs:
done

- name: Run tests
if: matrix.version != '1.10'
uses: julia-actions/julia-runtest@v1
with:
coverage: ${{ matrix.coverage != 'false' }}
env:
JULIA_LLVM_ARGS: ${{ matrix.llvm_args }}

# TODO: remove once GPUToolbox 3.9 is registered (JuliaGPU/GPUToolbox.jl#50). Julia 1.10
# ignores `[sources]`, so install it by URL and run the tests in the test environment.
- name: Run tests (Julia 1.10)
if: matrix.version == '1.10'
shell: bash
run: |
julia --project=test -e 'using Pkg
Pkg.add(url="https://github.com/JuliaGPU/GPUToolbox.jl", rev="tb/binding-overlays")
Pkg.develop(path=".")'
# precompile with the test flags, like Pkg.test does, so Aqua's persistent-task
# check doesn't have to build packages within its time limit
julia --project=test --check-bounds=yes --code-coverage=user -e 'using Pkg; Pkg.precompile()'
julia --project=test --check-bounds=yes --code-coverage=user test/runtests.jl
env:
JULIA_LLVM_ARGS: ${{ matrix.llvm_args }}

- name: Process coverage
# CoverageTools 1.4.1 uses a PkgLoadSpec field renamed in Julia 1.14.
if: matrix.version != 'nightly' && matrix.coverage != 'false'
Expand Down
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ projects = ["test"]
[deps]
CompilerCaching = "9db33cc3-5358-4881-8759-fa4194144afd"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand All @@ -35,6 +36,11 @@ NVVM = "423072a2-8eda-41a8-b560-ab106c23935b"
SPIRV_LLVM_Backend_jll = "4376b9bf-cff8-51b6-bb48-39421dff0d0c"
SPIRV_LLVM_Translator_jll = "4a5d46fc-d8cf-5151-a261-86b458210efb"

# TODO: remove once GPUToolbox 3.9 is registered (JuliaGPU/GPUToolbox.jl#50)
# TODO: remove once GPUToolbox 3.9 is registered (JuliaGPU/GPUToolbox.jl#50)
[sources]
GPUToolbox = {url = "https://github.com/JuliaGPU/GPUToolbox.jl", rev = "tb/binding-overlays"}

[extensions]
CthulhuExt = "Cthulhu"
HighlightsExt = "Highlights"
Expand All @@ -44,6 +50,7 @@ AMDGPU_LLVM_Backend_jll = "23.1.3"
CompilerCaching = "0.4, 0.5, 0.6"
Cthulhu = "2, 3"
ExprTools = "0.1"
GPUToolbox = "3.9"
Highlights = "0.6"
InteractiveUtils = "1"
LLVM = "10.4"
Expand Down
26 changes: 26 additions & 0 deletions ext/CthulhuExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ if isdefined(Cthulhu, :AbstractProvider)
Cthulhu.AbstractProvider(interp::GPUInterpreter) = Cthulhu.DefaultProvider(interp)
end

# Cthulhu infers with an interpreter of its own that wraps ours, and that creates the frames.
# Their reads of overlaid bindings have to be redirected like in the frames we create (see
# bindings.jl), or the code shown is not the code that is compiled.
const CC = GPUCompiler.CC
@static if VERSION >= v"1.11-"
function CC.InferenceState(result::CC.InferenceResult, cache_mode::UInt8,
interp::Cthulhu.CthulhuInterpreter)
sv = @invoke CC.InferenceState(result::CC.InferenceResult, cache_mode::UInt8,
interp::CC.AbstractInterpreter)
sv === nothing && return nothing
native = interp.native
native isa GPUInterpreter && GPUCompiler.redirect_binding_reads!(native, sv)
return sv
end
else
function CC.InferenceState(result::CC.InferenceResult, cache::Symbol,
interp::Cthulhu.CthulhuInterpreter)
sv = @invoke CC.InferenceState(result::CC.InferenceResult, cache::Symbol,
interp::CC.AbstractInterpreter)
sv === nothing && return nothing
native = interp.native
native isa GPUInterpreter && GPUCompiler.redirect_binding_reads!(native, sv)
return sv
end
end

descend(@nospecialize(sig); warntype::Bool, kwargs...) =
warntype ? Cthulhu.descend_code_warntype(sig; kwargs...) :
Cthulhu.descend_code_typed(sig; kwargs...)
Expand Down
1 change: 1 addition & 0 deletions src/GPUCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ include("runtime.jl")
# compiler implementation
include("deprecated.jl")
include("jlgen.jl")
include("bindings.jl")
include("irgen.jl")
include("exception_sites.jl")
include("determinism.jl")
Expand Down
Loading
Loading