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
157 changes: 157 additions & 0 deletions .buildkite/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# `src/` and `ext/`, `Project.toml` and the CI configuration, except the other back-ends'
# target files. The `if:` conditions implement the commit message tags documented in the
# Development section of the README; keep both in sync when adding a step.
#
# Every package also gets an "(llvmgpu)" step, which runs its tests with the llvmgpu
# toolchain (the `toolchain = "llvmgpu"` preference, set up by `.ci/toolchain.jl` in an
# environment of its own, as the default one persists on some agents).
# `[only llvmgpu]` selects only those steps and `[skip llvmgpu]` skips them; a package's own
# tags (e.g. `[only cuda]`) select both of its steps. Steps are skipped on draft pull
# requests unless a tag selects them.
steps:
- label: "CUDA.jl"
plugins:
Expand Down Expand Up @@ -34,6 +41,7 @@ steps:
- "ext/**"
- "Project.toml"
- ".buildkite/**"
- ".ci/**"
exclude:
- "src/{gcn,spirv,metal,bpf,native}.jl"
if: |
Expand All @@ -44,6 +52,38 @@ steps:
soft_fail:
- exit_status: 3

- label: "CUDA.jl (llvmgpu)"
plugins:
- JuliaCI/julia#v1:
version: "1.13"
command: |
unset LD_LIBRARY_PATH
echo "--- :julia: Instantiating project"
# an environment and checkouts of its own, so that the preference and the edited test
# environment don't reach the other steps
export JULIA_PROJECT="$$(mktemp -d)"
export JULIA_PKG_DEVDIR="$$JULIA_PROJECT/dev"
julia .ci/toolchain.jl CUDA

julia -e 'println("+++ :julia: Running tests")
using Pkg
Pkg.test("CUDA")'
agents:
queue: "cuda"
env:
JULIA_CPU_THREADS: "3"
if_changed:
include: *sources
exclude:
- "src/{gcn,spirv,metal,bpf,native}.jl"
if: |
build.message !~ /\[skip [^\]]*(tests|cuda|ptx|llvmgpu)/ &&
(build.message =~ /\[only [^\]]*(cuda|ptx|llvmgpu)/ ||
build.message !~ /\[only / && !build.pull_request.draft)
timeout_in_minutes: 120
# until the package works with IR of libLLVMGPU (JuliaGPU/CUDA.jl#3627)
soft_fail: true

- label: "oneAPI.jl"
plugins:
- JuliaCI/julia#v1:
Expand Down Expand Up @@ -77,6 +117,38 @@ steps:
soft_fail:
- exit_status: 3

- label: "oneAPI.jl (llvmgpu)"
plugins:
- JuliaCI/julia#v1:
version: "1.13"
command: |
echo "--- :julia: Instantiating project"
# an environment and checkouts of its own, so that the preference and the edited test
# environment don't reach the other steps
export JULIA_PROJECT="$$(mktemp -d)"
export JULIA_PKG_DEVDIR="$$JULIA_PROJECT/dev"
julia .ci/toolchain.jl oneAPI
julia -e 'using Pkg;
println("+++ :julia: Building support library")
include(joinpath(Pkg.devdir(), "oneAPI", "deps", "build_ci.jl"))'

julia -e 'println("+++ :julia: Running tests")
using Pkg
Pkg.test("oneAPI")'
agents:
queue: "oneapi"
if_changed:
include: *sources
exclude:
- "src/{ptx,gcn,metal,bpf,native}.jl"
if: |
build.message !~ /\[skip [^\]]*(tests|oneapi|spirv|llvmgpu)/ &&
(build.message =~ /\[only [^\]]*(oneapi|spirv|llvmgpu)/ ||
build.message !~ /\[only / && !build.pull_request.draft)
timeout_in_minutes: 60
# until the package works with IR of libLLVMGPU (JuliaGPU/oneAPI.jl#780)
soft_fail: true

- label: "AMDGPU.jl"
plugins:
- JuliaCI/julia#v1:
Expand Down Expand Up @@ -106,6 +178,35 @@ steps:
soft_fail:
- exit_status: 3

- label: "AMDGPU.jl (llvmgpu)"
plugins:
- JuliaCI/julia#v1:
version: "1.13"
command: |
echo "--- :julia: Instantiating project"
# an environment and checkouts of its own, so that the preference and the edited test
# environment don't reach the other steps
export JULIA_PROJECT="$$(mktemp -d)"
export JULIA_PKG_DEVDIR="$$JULIA_PROJECT/dev"
julia .ci/toolchain.jl AMDGPU

julia -e 'println("+++ :julia: Running tests")
using Pkg
Pkg.test("AMDGPU")'
agents:
queue: "rocm"
if_changed:
include: *sources
exclude:
- "src/{ptx,spirv,metal,bpf,native}.jl"
if: |
build.message !~ /\[skip [^\]]*(tests|amdgpu|gcn|llvmgpu)/ &&
(build.message =~ /\[only [^\]]*(amdgpu|gcn|llvmgpu)/ ||
build.message !~ /\[only / && !build.pull_request.draft)
timeout_in_minutes: 60
# until the package works with IR of libLLVMGPU (JuliaGPU/AMDGPU.jl#1250)
soft_fail: true

- label: "Metal.jl"
plugins:
- JuliaCI/julia#v1:
Expand Down Expand Up @@ -146,6 +247,33 @@ steps:
soft_fail:
- exit_status: 3

- label: "Metal.jl (llvmgpu)"
plugins:
- JuliaCI/julia#v1:
version: "1.13"
command: |
echo "--- :julia: Instantiating project"
# an environment and checkouts of its own, so that the preference and the edited test
# environment don't reach the other steps
export JULIA_PROJECT="$$(mktemp -d)"
export JULIA_PKG_DEVDIR="$$JULIA_PROJECT/dev"
JULIA_PKG_PRECOMPILE_AUTO=0 julia .ci/toolchain.jl Metal --workspace

julia -e 'println("+++ :julia: Running tests")
using Pkg
Pkg.test("Metal")'
agents:
queue: "metal"
if_changed:
include: *sources
exclude:
- "src/{ptx,gcn,spirv,bpf,native}.jl"
if: |
build.message !~ /\[skip [^\]]*(tests|metal|llvmgpu)/ &&
(build.message =~ /\[only [^\]]*(metal|llvmgpu)/ ||
build.message !~ /\[only / && !build.pull_request.draft)
timeout_in_minutes: 120

- label: "OpenCL.jl"
plugins:
- JuliaCI/julia#v1:
Expand Down Expand Up @@ -176,5 +304,34 @@ steps:
soft_fail:
- exit_status: 3

- label: "OpenCL.jl (llvmgpu)"
plugins:
- JuliaCI/julia#v1:
version: "1.13"
command: |
echo "--- :julia: Instantiating project"
# an environment and checkouts of its own, so that the preference and the edited test
# environment don't reach the other steps
export JULIA_PROJECT="$$(mktemp -d)"
export JULIA_PKG_DEVDIR="$$JULIA_PROJECT/dev"
julia .ci/toolchain.jl OpenCL SPIRVIntrinsics

julia -e 'println("+++ :julia: Running tests")
using Pkg
Pkg.test("OpenCL")'
agents:
queue: "cuda"
if_changed:
include: *sources
exclude:
- "src/{ptx,gcn,metal,bpf,native}.jl"
if: |
build.message !~ /\[skip [^\]]*(tests|opencl|spirv|llvmgpu)/ &&
(build.message =~ /\[only [^\]]*(opencl|spirv|llvmgpu)/ ||
build.message !~ /\[only / && !build.pull_request.draft)
timeout_in_minutes: 120
# until the package works with IR of libLLVMGPU (JuliaGPU/OpenCL.jl#631)
soft_fail: true

env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: "eager" # see freshly-registered versions without cloning the registry
58 changes: 58 additions & 0 deletions .ci/toolchain.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Set up a CI environment to test a downstream package with the llvmgpu toolchain.
#
# julia .ci/toolchain.jl PACKAGE [PACKAGES...] [--workspace]
#
# Develops GPUCompiler and the downstream PACKAGE (and further PACKAGES, e.g. packages of
# PACKAGE's repository) into the active environment, for `Pkg.test(PACKAGE)`. The
# preference goes into the active environment (in CI, a temporary one), which `Pkg.test`
# passes on to the test environment; GPUCompiler is added to PACKAGE's test dependencies so
# that it applies there. `--workspace` also instantiates PACKAGE's workspace against
# GPUCompiler (Metal.jl's tests run examples in its workspace environments).

using Pkg, TOML

const ROOT = dirname(@__DIR__)
const GPUCOMPILER_UUID = "61eb1bfa-7361-4325-ad38-22787b887f55"

function downstream(packages, workspace)
package = first(packages)
env = dirname(Base.active_project())

# an environment that doesn't exist yet (Pkg creates it on the first change)
mkpath(env)
file = joinpath(env, "LocalPreferences.toml")
open(io -> TOML.print(io, Dict("GPUCompiler" => Dict("toolchain" => "llvmgpu"))), file, "w")
println("$file:")
print(read(file, String))

Pkg.develop(path=ROOT)
Pkg.develop([PackageSpec(name=name) for name in packages])

checkout = joinpath(Pkg.devdir(), package)
if workspace
# before editing the test environment, which is part of the workspace and could
# then not be resolved; the examples that need the workspace run in the test
# process, which has loaded GPUCompiler already
Pkg.activate(checkout)
Pkg.develop(path=ROOT)
Pkg.instantiate(workspace=true)
Pkg.activate(env)
end
test_project = joinpath(checkout, "test", "Project.toml")
isfile(test_project) || error("$package has no test/Project.toml")
# by editing the text, as rewriting it with TOML.print reorders the file
deps = get(TOML.parsefile(test_project), "deps", Dict())
if !haskey(deps, "GPUCompiler")
text = read(test_project, String)
occursin(r"^\[deps\]$"m, text) || (text = "[deps]\n\n" * text)
text = replace(text, r"^\[deps\]$"m => "[deps]\nGPUCompiler = \"$GPUCOMPILER_UUID\"";
count=1)
write(test_project, text)
end

Pkg.status()
end

packages = filter(!=("--workspace"), ARGS)
isempty(packages) && error("Usage: julia .ci/toolchain.jl PACKAGE [PACKAGES...] [--workspace]")
downstream(packages, "--workspace" in ARGS)
19 changes: 17 additions & 2 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:

jobs:
release_test:
name: Julia ${{ matrix.version }} ${{ matrix.llvm_args }}${{ matrix.coverage == 'false' && ' (no coverage)' || '' }} - ${{ matrix.os }}
name: Julia ${{ matrix.version }} ${{ matrix.llvm_args }}${{ matrix.toolchain == 'llvmgpu' && ' with llvmgpu' || '' }}${{ matrix.coverage == 'false' && ' (no coverage)' || '' }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
Expand All @@ -23,7 +23,19 @@ jobs:
os: [ubuntu-24.04, ubuntu-24.04-arm, macOS-15, windows-2025]
llvm_args: ['']
coverage: ['true']
toolchain: ['julia']
include:
# the llvmgpu toolchain (JuliaIR's passes, libLLVMGPU), on fewer platforms. not on
# aarch64 Linux with Julia 1.12 or 1.13, whose GC lowering crashes on JuliaIR's
# code (JuliaLang/julia#62899).
- {version: '1.10', os: 'ubuntu-24.04', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.11', os: 'ubuntu-24.04', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.12', os: 'ubuntu-24.04', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.13', os: 'ubuntu-24.04', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: 'nightly', os: 'ubuntu-24.04', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.12', os: 'macOS-15', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.12', os: 'windows-2025', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
- {version: '1.11', os: 'ubuntu-24.04-arm', llvm_args: '', coverage: 'true', toolchain: 'llvmgpu'}
# code coverage recompiles the package instead of using its precompiled code,
# which hides bugs in how that code interacts with methods back-ends define
- version: '1.12'
Expand Down Expand Up @@ -68,11 +80,12 @@ jobs:
uses: julia-actions/cache@v3

# without a driver, CUDA_Compiler_jll selects no toolkit; libNVVM works without one
- name: Select a CUDA toolkit
- name: Set preferences
shell: bash
run: |
for dir in . test; do
echo -e '[CUDA_Compiler_jll]\nversion = "13.5"' >$dir/LocalPreferences.toml
echo -e '[GPUCompiler]\ntoolchain = "${{ matrix.toolchain || 'julia' }}"' >>$dir/LocalPreferences.toml
done

- name: Run tests
Expand All @@ -81,6 +94,8 @@ jobs:
coverage: ${{ matrix.coverage != 'false' }}
env:
JULIA_LLVM_ARGS: ${{ matrix.llvm_args }}
# makes the tests check that the preference applied
GPUCOMPILER_TEST_TOOLCHAIN: ${{ matrix.toolchain || 'julia' }}

- name: Process coverage
# CoverageTools 1.4.1 uses a PkgLoadSpec field renamed in Julia 1.14.
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test/Manifest.toml
test/LocalPreferences.toml
LocalPreferences.toml
Manifest.toml
Manifest-*.toml
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ projects = ["test"]
CompilerCaching = "9db33cc3-5358-4881-8759-fa4194144afd"
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JuliaIR = "3913dba9-7ba9-44aa-bf76-1cfa3b3073b1"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
LLVMGPU_jll = "a5c41ef1-0fc2-5e62-838b-0d6f5f7d5115"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand Down Expand Up @@ -46,8 +48,10 @@ Cthulhu = "2, 3"
ExprTools = "0.1"
Highlights = "0.6"
InteractiveUtils = "1"
LLVM = "10.4"
LLVMDowngrader_jll = "0.11, 0.12"
JuliaIR = "0.2"
LLVM = "10.8.1"
LLVMGPU_jll = "1.5"
LLVMDowngrader_jll = "0.11, 0.12, 0.13"
Libdl = "1"
Logging = "1"
NVPTX_LLVM_Backend_jll = "23"
Expand Down
Loading
Loading