Skip to content
Closed
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
19 changes: 17 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
env:
JULIA_NUM_THREADS: "1"
JULIA_PKG_SERVER: ""
# SECRET_CODECOV_TOKEN: "..."

steps:

- label: "Julia 1.5"
plugins:
- JuliaCI/julia#v0.5:
version: 1.5
version: '1.5'
- JuliaCI/julia-test#v0.3: ~
# - JuliaCI/julia-coverage#v0.3:
# codecov: true
agents:
queue: "juliagpu"
cuda: "*"
if: build.message !~ /\[skip tests\]/
timeout_in_minutes: '60'

- label: "Julia nightly"
plugins:
- JuliaCI/julia#v0.5:
version: 'nightly'
- JuliaCI/julia-test#v0.3: ~
# - JuliaCI/julia-coverage#v0.3:
# codecov: true
agents:
queue: "juliagpu"
cuda: "*"
if: build.message !~ /\[skip tests\]/
timeout_in_minutes: 60
timeout_in_minutes: '60'
2 changes: 2 additions & 0 deletions .github/workflows/ci-julia-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- '1'
- '2'
- '3'
- '4'
- '5'
os:
- ubuntu-latest
threads:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- '1'
- '2'
- '3'
- '4'
- '5'
os:
- ubuntu-latest
threads:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ DiffRules = "1"
FillArrays = "0.10"
ForwardDiff = "0.10"
KernelAbstractions = "0.4"
LoopVectorization = "0.8.26, 0.9.7"
LoopVectorization = "0.8.26, 0.9.9"
NamedDims = "0.2"
OffsetArrays = "1"
Requires = "1"
TensorOperations = "3"
Tracker = "0.2"
VectorizationBase = "0.12.33, 0.13.10"
VectorizationBase = "0.12.33, 0.14.3"
Zygote = "0.5"
julia = "1.3"

Expand Down
2 changes: 1 addition & 1 deletion test/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ind2 = rand(1:10, 1024) # many repeats
dx2 = ForwardDiff.gradient(x -> sum(@tullio y[i] := x[ind2[i]] + x[i]), rand(1024))
@test dx2 ≈ _gradient(x -> sum(@tullio y[i] := x[ind2[i]] + x[i]), rand(1024))[1]

ind3 = vcat(unique(rand(1:1024, 10)), 1) # many missing, but includes at 1
ind3 = vcat(unique(rand(2:1024, 10)), 1) # many missing, no repeats, but always includes 1
g3 = ForwardDiff.gradient(x -> sum(@tullio y[ind3[i]] := i^2 * x[i]), ones(size(ind3)))
@test g3 ≈ _gradient(x -> sum(@tullio y[ind3[i]] := i^2 * x[i]), ones(size(ind3)))[1]
# You get weird errors here if indices of y don't start at 1.
Expand Down
102 changes: 0 additions & 102 deletions test/group-3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,105 +104,3 @@ _gradient(x...) = Yota.grad(x...)[2]

@info @sprintf("Yota tests took %.1f seconds", time()-t7)
=#

#===== LoopVectorization =====#

t8 = time()
using LoopVectorization
using VectorizationBase

@static if Base.VERSION >= v"1.5"
const Vec = VectorizationBase.Vec
else
const Vec = VectorizationBase.SVec
end

@testset "LoopVectorization onlyone" begin
ms = mask(Val(8), 2) # Mask{8,Bool}<1, 1, 0, 0, 0, 0, 0, 0>
sv = Vec{4,Int}(1,2,3,4) # Vec{4,Int64}<1, 2, 3, 4>

# preliminaries:
@test Tullio.allzero(sv) === false
@test Tullio.allzero(zero(sv)) === true

@test Tullio.anyone(ms) === true

# the main function:
@test Tullio.onlyone(false, 0) === false
@test Tullio.onlyone(true, 0) === true
@test Tullio.onlyone(true, 1) === false

# @test Tullio.onlyone(ms, 0) === Mask{UInt8}(0x02)
@test Tullio.onlyone(ms, 0).u == 0x02
# @test Tullio.onlyone(ms, sv) === Mask{UInt8}(0x00)
@test Tullio.onlyone(ms, sv).u == 0x00
# @test Tullio.onlyone(ms, zero(sv)) === Mask{UInt8}(0x02)
@test Tullio.onlyone(ms, zero(sv)).u == 0x02
end

@testset "parsing + LoopVectorization" begin include("parsing.jl") end

using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Base
@testset "gradients: Tracker + DiffRules + LoopVectorization" begin include("gradients.jl") end

@tullio grad=Dual
@testset "gradients: Tracker + ForwardDiff + LoopVectorization" begin include("gradients.jl") end

@info @sprintf("LoopVectorization tests took %.1f seconds", time()-t8)

@tullio avx=false

#===== TensorOperations =====#

t9 = time()
using TensorOperations

using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Base
@testset "gradients: Tracker + TensorOperations" begin include("gradients.jl") end

if VERSION < v"1.6-" # Zygote isn't working on 1.6

using Zygote
GRAD = :Zygote
_gradient(x...) = Zygote.gradient(x...)

@tullio grad=Base
@testset "gradients: Zygote + TensorOperations" begin include("gradients.jl") end

@testset "complex gradients with TensorOperations" begin

x0 = [1 2; 3 4] .+ [5im 0; 7im -8im]

@testset "analytic" begin

g1 = _gradient(x -> real(sum(x * x)), x0)[1]
g1i = _gradient(x -> imag(sum(x * x)), x0)[1]
@test g1 ≈ _gradient(x -> real(sum(@tullio y[i,j] := x[i,k] * x[k,j])), x0)[1]
@test g1i ≈ _gradient(x -> imag(sum(@tullio y[i,j] := x[i,k] * x[k,j])), x0)[1]

end
@testset "non-analytic" begin

g2 = _gradient(x -> real(sum(x * x')), x0)[1]
g2i = _gradient(x -> imag(sum(x * x')), x0)[1] # zero
@test_broken g2 ≈ _gradient(x -> real(sum(@tullio y[i,j] := x[i,k] * conj(x[j,k]))), x0)[1]
@test_broken g2i ≈ _gradient(x -> imag(sum(@tullio y[i,j] := x[i,k] * conj(x[j,k]))), x0)[1]

end
end

end # VERSION

@testset "parsing + TensorOperations" begin include("parsing.jl") end # testing correct fallback

@info @sprintf("TensorOperations tests took %.1f seconds", time()-t9)

#===== done! =====#
50 changes: 50 additions & 0 deletions test/group-4.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#===== LoopVectorization =====#

t8 = time()
using LoopVectorization
using VectorizationBase

@static if Base.VERSION >= v"1.5"
const Vec = VectorizationBase.Vec
else
const Vec = VectorizationBase.SVec
end

@testset "LoopVectorization onlyone" begin
ms = mask(Val(8), 2) # Mask{8,Bool}<1, 1, 0, 0, 0, 0, 0, 0>
sv = Vec{4,Int}(1,2,3,4) # Vec{4,Int64}<1, 2, 3, 4>

# preliminaries:
@test Tullio.allzero(sv) === false
@test Tullio.allzero(zero(sv)) === true

@test Tullio.anyone(ms) === true

# the main function:
@test Tullio.onlyone(false, 0) === false
@test Tullio.onlyone(true, 0) === true
@test Tullio.onlyone(true, 1) === false

# @test Tullio.onlyone(ms, 0) === Mask{UInt8}(0x02)
@test Tullio.onlyone(ms, 0).u == 0x02
# @test Tullio.onlyone(ms, sv) === Mask{UInt8}(0x00)
@test Tullio.onlyone(ms, sv).u == 0x00
# @test Tullio.onlyone(ms, zero(sv)) === Mask{UInt8}(0x02)
@test Tullio.onlyone(ms, zero(sv)).u == 0x02
end

@testset "parsing + LoopVectorization" begin include("parsing.jl") end

using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Base
@testset "gradients: Tracker + DiffRules + LoopVectorization" begin include("gradients.jl") end

@tullio grad=Dual
@testset "gradients: Tracker + ForwardDiff + LoopVectorization" begin include("gradients.jl") end

@info @sprintf("LoopVectorization tests took %.1f seconds", time()-t8)

@tullio avx=false
50 changes: 50 additions & 0 deletions test/group-5.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#===== TensorOperations =====#

t9 = time()
using TensorOperations

using Tracker
GRAD = :Tracker
_gradient(x...) = Tracker.gradient(x...)

@tullio grad=Base
@testset "gradients: Tracker + TensorOperations" begin include("gradients.jl") end

if VERSION < v"1.6-" # Zygote isn't working on 1.6

using Zygote
GRAD = :Zygote
_gradient(x...) = Zygote.gradient(x...)

@tullio grad=Base
@testset "gradients: Zygote + TensorOperations" begin include("gradients.jl") end

@testset "complex gradients with TensorOperations" begin

x0 = [1 2; 3 4] .+ [5im 0; 7im -8im]

@testset "analytic" begin

g1 = _gradient(x -> real(sum(x * x)), x0)[1]
g1i = _gradient(x -> imag(sum(x * x)), x0)[1]
@test g1 ≈ _gradient(x -> real(sum(@tullio y[i,j] := x[i,k] * x[k,j])), x0)[1]
@test g1i ≈ _gradient(x -> imag(sum(@tullio y[i,j] := x[i,k] * x[k,j])), x0)[1]

end
@testset "non-analytic" begin

g2 = _gradient(x -> real(sum(x * x')), x0)[1]
g2i = _gradient(x -> imag(sum(x * x')), x0)[1] # zero
@test_broken g2 ≈ _gradient(x -> real(sum(@tullio y[i,j] := x[i,k] * conj(x[j,k]))), x0)[1]
@test_broken g2i ≈ _gradient(x -> imag(sum(@tullio y[i,j] := x[i,k] * conj(x[j,k]))), x0)[1]

end
end

end # VERSION

@testset "parsing + TensorOperations" begin include("parsing.jl") end # testing correct fallback

@info @sprintf("TensorOperations tests took %.1f seconds", time()-t9)

#===== done! =====#
34 changes: 27 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,36 @@ is_buildkite = parse(Bool, get(ENV, "BUILDKITE", "false"))
if is_buildkite
test_group = "2" # if this is Buildkite, we only run group 2
else
test_group = get(ENV, "TULLIO_TEST_GROUP", "all")
test_group = string(get(ENV, "TULLIO_TEST_GROUP", "all"))
end
@info "" test_group is_buildkite

if test_group in ["all", "1"]
include("group-1.jl")
num_test_groups = 5
if !(test_group in vcat(["all"], string.(1:num_test_groups)))
throw(ArgumentError("\"$(test_group)\" is not a valid test group"))
end
if test_group in ["all", "2"]
include("group-2.jl")
# for i in 1:num_test_groups
for i in [1, 3, 5]
file_i = joinpath(@__DIR__, "group-$(i).jl")
if test_group in ["all", string(i)]
@info "Beginning to run test file" i file_i
include(file_i)
@info "Finished running test file" i file_i
else
@info "Skipping test file" i file_i
end
end
if test_group in ["all", "3"]
include("group-3.jl")
for i in [2, 4] # these groups are currently broken on Julia nightly
file_i = joinpath(@__DIR__, "group-$(i).jl")
if test_group in ["all", string(i)]
if (get(ENV, "CI", "") == "true") && (!(Base.VERSION < v"1.6.0"))
@info "Skipping test file because this is a CI job on nightly" i file_i
else
@info "Beginning to run test file" i file_i
include(file_i)
@info "Finished running test file" i file_i
end
else
@info "Skipping test file" i file_i
end
end