Skip to content
Open

Pr3228 #3233

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
78 changes: 0 additions & 78 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1 @@
steps:
- label: "CUDA Julia v{{matrix.version}}"
matrix:
setup:
version:
- "1.10"
- "1.11"
- "1.12"
plugins:
- JuliaCI/julia#v1:
version: "{{matrix.version}}"
agents:
queue: "cuda"
if: build.message !~ /\[skip tests\]/
timeout_in_minutes: 60
commands: |
echo "--- Setup Julia packages"
JULIA_PKG_PRECOMPILE_AUTO="false" julia --color=yes -e '
using Pkg
pkgs = [PackageSpec(; path) for path in (".", "lib/EnzymeCore", "lib/EnzymeTestUtils")]
Pkg.develop(pkgs)
Pkg.add(PackageSpec(; name="CUDA", version="6"))' || exit 3

echo "+++ Run tests"
julia --color=yes test/cuda.jl
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager

# - label: "AMDGPU Julia v{{matrix.version}}"
# matrix:
# setup:
# version:
# - "1.10"
# plugins:
# - JuliaCI/julia#v1:
# version: "{{matrix.version}}"
# agents:
# queue: "rocm"
# if: build.message !~ /\[skip tests\]/
# timeout_in_minutes: 60
# commands: |
# echo "--- Setup Julia packages"
# julia --color=yes -e '
# using Pkg
# pkgs = [PackageSpec(; path) for path in (".", "lib/EnzymeCore", "lib/EnzymeTestUtils")]
# push!(pkgs, PackageSpec(; name="AMDGPU"))
# Pkg.develop(pkgs)' || exit 3
#
# echo "+++ Run tests"
# julia --color=yes test/amdgpu.jl
# env:
# JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
#
# - label: "Metal Julia v{{matrix.version}}"
# matrix:
# setup:
# version:
# - "1.10"
# plugins:
# - JuliaCI/julia#v1:
# version: "{{matrix.version}}"
# agents:
# queue: "juliaecosystem"
# os: "macos"
# arch: "aarch64"
# if: build.message !~ /\[skip tests\]/
# timeout_in_minutes: 60
# commands: |
# echo "--- Setup Julia packages"
# julia --color=yes -e '
# using Pkg
# pkgs = [PackageSpec(; path) for path in (".", "lib/EnzymeCore", "lib/EnzymeTestUtils")]
# push!(pkgs, PackageSpec(; name="Metal"))
# Pkg.develop(pkgs)' || exit 3
#
# echo "+++ Run tests"
# julia --color=yes test/metal.jl
# env:
# JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
152 changes: 0 additions & 152 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
- '1.12'
- 'nightly'
os:
- ubuntu-24.04
- macOS-latest
- windows-latest
llvm_args:
- ''
Expand All @@ -59,44 +57,6 @@ jobs:
- os: windows-latest
arch: default
libEnzyme: local
include:
- os: ubuntu-24.04
arch: x86
libEnzyme: packaged
version: '1.10'
assertions: false
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.10'
assertions: true
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.11'
assertions: true
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.12'
assertions: true
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.13'
assertions: true
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.10'
assertions: true
llvm_args: '--opaque-pointers'
- os: ubuntu-24.04
arch: default
libEnzyme: packaged
version: '1.11'
assertions: false
llvm_args: '--opaque-pointers'
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
Expand Down Expand Up @@ -177,115 +137,3 @@ jobs:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails

enzymetestutils:
timeout-minutes: 60
name: EnzymeTestUtils - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.libEnzyme }} libEnzyme - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
env:
JULIA_PROJECT: "lib/EnzymeTestUtils"
strategy:
fail-fast: false
matrix:
version:
- '1.10'
- '1.11'
- '1.12'
- 'nightly'
os:
- ubuntu-latest
arch:
- default
libEnzyme: [packaged]
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v3
- name: setup EnzymeTestUtils
shell: julia --color=yes {0}
id: setup_testutils
continue-on-error: ${{ matrix.version == 'nightly' }}
run: |
using Pkg
Pkg.develop([PackageSpec(; path) for path in (".", "lib/EnzymeCore")])
Pkg.instantiate()
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- name: Run the tests
if: matrix.version != 'nightly' || steps.setup_testutils.outcome == 'success'
continue-on-error: ${{ matrix.version == 'nightly' }}
id: run_tests
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.test("EnzymeTestUtils"; coverage=true)
- uses: julia-actions/julia-processcoverage@v1
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
directories: lib/EnzymeTestUtils/src
- uses: codecov/codecov-action@v7
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails

enzymecore:
timeout-minutes: 20
name: EnzymeCore - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.libEnzyme }} libEnzyme - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
env:
JULIA_PROJECT: "lib/EnzymeCore"
strategy:
fail-fast: false
matrix:
version:
- '1.10'
- '1.11'
- '1.12'
- 'nightly'
os:
- ubuntu-latest
arch:
- default
libEnzyme: [packaged]
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v3
- name: setup EnzymeCore
shell: julia --color=yes {0}
id: setup_testutils
continue-on-error: ${{ matrix.version == 'nightly' }}
run: |
using Pkg
Pkg.develop([PackageSpec(; path) for path in (".",)])
Pkg.instantiate()
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- name: Run the tests
if: matrix.version != 'nightly' || steps.setup_testutils.outcome == 'success'
continue-on-error: ${{ matrix.version == 'nightly' }}
id: run_tests
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.test("EnzymeCore"; coverage=true)
- uses: julia-actions/julia-processcoverage@v1
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
directories: lib/EnzymeCore/src
- uses: codecov/codecov-action@v7
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails
17 changes: 14 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
function unsafe_to_pointer end
export unsafe_to_pointer

const compiler_roots = Dict{Ptr{Cvoid}, Any}()
const compiler_roots_lock = ReentrantLock()

if VERSION >= v"1.12-"
@inline function unsafe_to_pointer(@nospecialize(val::Type))
@inline function _unsafe_to_pointer(@nospecialize(val::Type))
return Core.Intrinsics.llvmcall((
"""
declare nonnull ptr @julia.pointer_from_objref(ptr addrspace(11))
Expand All @@ -22,7 +25,7 @@ if VERSION >= v"1.12-"
""", "f"), Ptr{Cvoid}, Tuple{Any}, val)
end
elseif Int == Int64
@inline function unsafe_to_pointer(@nospecialize(val::Type))
@inline function _unsafe_to_pointer(@nospecialize(val::Type))
return Base.llvmcall((
"""
declare nonnull {}* @julia.pointer_from_objref({} addrspace(11)*)
Expand All @@ -36,7 +39,7 @@ elseif Int == Int64
""", "f"), Ptr{Cvoid}, Tuple{Any}, val)
end
else
@inline function unsafe_to_pointer(@nospecialize(val::Type))
@inline function _unsafe_to_pointer(@nospecialize(val::Type))
return Base.llvmcall((
"""
declare nonnull {}* @julia.pointer_from_objref({} addrspace(11)*)
Expand All @@ -51,6 +54,14 @@ else
end
end

function unsafe_to_pointer(@nospecialize(val::Type))
ptr = _unsafe_to_pointer(val)
lock(compiler_roots_lock) do
compiler_roots[ptr] = val
end
return ptr
end


@inline is_concrete_tuple(x::Type{T2}) where {T2} =
(T2 <: Tuple) && !(T2 === Tuple) && !(T2 isa UnionAll)
Expand Down
52 changes: 14 additions & 38 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
import Enzyme
import Enzyme_jll
using ParallelTestRunner: addworker, filter_tests!, find_tests, parse_args, runtests
using Enzyme
using Test

# Start with autodiscovered tests
testsuite = find_tests(@__DIR__)
# Add threads tests to be run with multiple Julia threads (will be configured in
# `test_worker`).
testsuite["threads/2"] = :(include($(joinpath(@__DIR__, "threads.jl"))))
# Exclude integration tests, they're handled differently (they each run in their
# own environment)
for (k, _) in testsuite
startswith(k, "integration/") && delete!(testsuite, k)
end

# Parse arguments
args = parse_args(ARGS)

if filter_tests!(testsuite, args)
# Skip GPU-specific tests by default.
delete!(testsuite, "metal")
delete!(testsuite, "cuda")
delete!(testsuite, "amdgpu")
delete!(testsuite, "common")
Enzyme.API.printall!(true)
Enzyme.Compiler.DumpPostOpt[] = true

# Skipped until https://github.com/EnzymeAD/Enzyme.jl/issues/2620 is fixed.
if Sys.iswindows()
delete!(testsuite, "ext/specialfunctions")
end
end
@testset "BigFloat arithmetic" begin
a = BigFloat(1.234)
da = BigFloat(-0.23)
b = BigFloat(0.56)
db = BigFloat(0.27)
af64 = 1.234 # for testing mixed methods
daf64 = -0.23 # for testing mixed methods
bf64 = 0.56 # for testing mixed methods
dbf64 = 0.27 # for testing mixed methods

function test_worker(name)
if name == "threads/2"
# Run the `threads/2` testset, with multiple threads.
return addworker(; exeflags = ["--threads=2"])
end
@test autodiff(Enzyme.Forward, +, Duplicated, Duplicated(a, da), Duplicated(b, db))[:1] ≈ da+db
end

const init_code = quote end

@info "Testing against" Enzyme_jll.libEnzyme
runtests(Enzyme, args; testsuite, init_code, test_worker)
Loading
Loading