Skip to content
Merged
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ jobs:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
SPARSEARRAYS_AQUA_TEST: true
- name: Run Aqua and ambiguity tests
run: |
julia --color=yes -e 'using Pkg; Pkg.activate(temp=true); Pkg.develop(path=pwd()); Pkg.add(name="Aqua", version="0.8"); include(joinpath(pwd(), "test", "ambiguous.jl"))'
docs:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Dates = "<0.0.1, 1"
InteractiveUtils = "<0.0.1, 1"
Libdl = "<0.0.1, 1"
LinearAlgebra = "<0.0.1, 1"
ParallelTestRunner = "2"
Pkg = "<0.0.1, 1"
Printf = "<0.0.1, 1"
Random = "<0.0.1, 1"
Expand All @@ -27,9 +28,10 @@ julia = "1.11"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Dates", "InteractiveUtils", "Pkg", "Printf", "Test"]
test = ["Aqua", "Dates", "InteractiveUtils", "ParallelTestRunner", "Pkg", "Printf", "Test"]
83 changes: 20 additions & 63 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,75 +1,32 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, LinearAlgebra, SparseArrays

include("util/gha.jl")

if Base.get_bool_env("SPARSEARRAYS_AQUA_TEST", false)
include("ambiguous.jl")
end

include("allowscalar.jl")
include("fixed.jl")
include("higherorderfns.jl")
include("sparsematrix_constructors_indexing.jl")
include("sparsematrix_ops.jl")
include("sparsevector.jl")
include("issues.jl")
testfiles = ["allowscalar.jl", "fixed.jl", "higherorderfns.jl",
"sparsematrix_constructors_indexing.jl", "sparsematrix_ops.jl",
"sparsevector.jl", "issues.jl"]

if Base.USE_GPL_LIBS

include("cholmod.jl")
include("umfpack.jl")
include("spqr.jl")
include("linalg.jl")
include("linalg_solvers.jl")

nt = @static if isdefined(Threads, :maxthreadid)
Threads.maxthreadid()
else
Threads.nthreads()
end

# 1. If the OS is Windows and we are in GitHub Actions CI, we do NOT run
# the `threads` tests.
# 2. If the OS is Windows and we are NOT in GitHub Actions CI, we DO run
# the `threads` tests.
# - So, just as an example, if the OS is Windows and we are in
# Buildkite CI, we DO run the `threads` tests.
# 3. If the OS is NOT Windows, we DO run the `threads` tests.
append!(testfiles, ["cholmod.jl", "umfpack.jl", "spqr.jl", "linalg.jl",
"linalg_solvers.jl"])
if Sys.iswindows() && is_github_actions_ci()
@warn "Skipping `threads` tests on Windows on GitHub Actions CI"
@test_skip false
else
@debug "Beginning the `threads` tests..."

# Test multithreaded execution
@testset "threaded SuiteSparse tests" verbose = true begin
@testset "threads = $nt" begin
include("threads.jl")
end
# test both nthreads==1 and nthreads>1. spawn a process to test whichever
# case we are not running currently.
other_nthreads = nt == 1 ? 4 : 1
@testset "threads = $other_nthreads" begin
let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl`
p = run(
pipeline(
setenv(
cmd,
"JULIA_NUM_THREADS" => other_nthreads,
dir=@__DIR__()),
stdout = stdout,
stderr = stderr),
wait = false)
if !success(p)
error("SuiteSparse threads test failed with nthreads == $other_nthreads")
else
@test true # mimic the one @test in threads.jl
end
end
end
end

@debug "Finished the `threads` tests..."
push!(testfiles, "threads_suite.jl")
end
end

# ParallelTestRunner comes from the Pkg.test target; Julia base CI runs this
# file without it and falls back to the serial path.
if Base.find_package("ParallelTestRunner") !== nothing
using ParallelTestRunner
# Auto CPU thread count detection in ParallelTestRunner is bad
push!(ARGS, "--jobs=$(Sys.CPU_THREADS)")
testsuite = Dict{String,Expr}(splitext(f)[1] => :(include($(joinpath(@__DIR__, f))))
for f in testfiles)
runtests(SparseArrays, ARGS; testsuite)
else
foreach(include, testfiles)
end
8 changes: 5 additions & 3 deletions test/sparsematrix_constructors_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,9 @@ end
times = Float64[0,0,0]
best = [typemax(Float64), 0]
for searchtype in [0, 1, 2]
GC.gc()
# stabilizes the debug timings below, but forces 180 full
# collections across these loops which dominates the file's GC time
# GC.gc()
tres = @timed test_getindex_algs(S, I, J, searchtype)
res[searchtype+1] = tres[1]
times[searchtype+1] = tres[2]
Expand Down Expand Up @@ -890,9 +892,9 @@ end
for I in IA
Isorted = sort(I)
for S in SA
GC.gc()
# GC.gc() # see comment above
ru = @timed S[I, J]
GC.gc()
# GC.gc()
rs = @timed S[Isorted, Jsorted]
if debug
@printf(" %7d | %7d | %7d | %4.2e | %4.2e | %4.2e | %4.2e |\n", round(Int,nnz(S)/size(S, 2)), length(I), length(J), rs[2], ru[2], rs[3], ru[3])
Expand Down
6 changes: 6 additions & 0 deletions test/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,10 @@ end
floattypes = (Float32, Float64, BigFloat)
complextypes = (ComplexF32, ComplexF64)
eltypes = (inttypes..., floattypes..., complextypes...)
# The full eltype cross product compiles thousands of specializations
# (several CI minutes); do it only for the core types and pair the
# remaining eltypes with Float64.
coretypes = (Int64, Float64, ComplexF64)

for eltypemat in eltypes
(densemat, sparsemat) = eltypemat in inttypes ? (denseintmat, sparseintmat) :
Expand All @@ -1350,6 +1354,8 @@ end
LinearAlgebra.UnitLowerTriangular(sparsemat), LinearAlgebra.UnitUpperTriangular(sparsemat) )

for eltypevec in eltypes
(eltypemat in coretypes && eltypevec in coretypes) ||
eltypemat == Float64 || eltypevec == Float64 || continue
spvecs = eltypevec in inttypes ? sparseintvecs :
eltypevec in floattypes ? sparsefloatvecs :
eltypevec in complextypes && sparsecomplexvecs
Expand Down
36 changes: 36 additions & 0 deletions test/threads_suite.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, SparseArrays

nt = @static if isdefined(Threads, :maxthreadid)
Threads.maxthreadid()
else
Threads.nthreads()
end

@testset "threaded SuiteSparse tests" verbose = true begin
@testset "threads = $nt" begin
include("threads.jl")
end
# test both nthreads==1 and nthreads>1. spawn a process to test whichever
# case we are not running currently.
other_nthreads = nt == 1 ? 4 : 1
@testset "threads = $other_nthreads" begin
let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl`
p = run(
pipeline(
setenv(
cmd,
"JULIA_NUM_THREADS" => other_nthreads,
dir=@__DIR__()),
stdout = stdout,
stderr = stderr),
wait = false)
if !success(p)
error("SuiteSparse threads test failed with nthreads == $other_nthreads")
else
@test true # mimic the one @test in threads.jl
end
end
end
end
Loading