Skip to content

Commit

Permalink
add multithreading, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sumiya11 committed Dec 13, 2023
1 parent e4851dc commit 54a29fa
Show file tree
Hide file tree
Showing 19 changed files with 1,801 additions and 72 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SIMD = "fdea26ae-647d-5447-a871-4b548cad5224"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
UnsafeAtomics = "013be700-e6cd-48c3-b4a1-df204f14c38f"

[compat]
AbstractAlgebra = "0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34"
Expand Down
1 change: 1 addition & 0 deletions benchmark/CI-scripts/run-on-nightly/run_benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Pkg
Pkg.status()
Pkg.develop(path=(@__DIR__) * "/../../../")

include("../run_benchmarks.jl")
Expand Down
5 changes: 3 additions & 2 deletions benchmark/CI-scripts/run-on-stable/run_benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Pkg
Pkg.add("Groebner")
Pkg.update("Groebner")
Pkg.status()
Pkg.add(url="https://github.com/sumiya11/Groebner.jl")
# Pkg.update("Groebner")

include("../run_benchmarks.jl")

Expand Down
14 changes: 13 additions & 1 deletion benchmark/CI-scripts/run_benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ push!(
suite,
(
problem_name="groebner, AA, GF(2^31-1), katsura 10",
result=compute_gb(Groebner.katsuran(10, ordering=:degrevlex, ground=GF(2^31 - 1)))
result=compute_gb(
Groebner.katsuran(10, ordering=:degrevlex, ground=GF(2^31 - 1)),
5
)
)
)
push!(
suite,
(
problem_name="groebner, AA, GF(2^27+29), katsura 10",
result=compute_gb(
Groebner.katsuran(10, ordering=:degrevlex, ground=GF(2^27 + 29), 5)
)
)
)
push!(
Expand Down
2 changes: 2 additions & 0 deletions benchmark/CI-scripts/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using Test
using TestSetExtensions
using InteractiveUtils
using Base.Threads

const MAX_ACCEPTABLE_RELATIVE_DEVIATION = 0.1
const IGNORE_SMALL_ABSOLUTE_DEVIATION = 1e-3

@info "Start benchmarking.."
@info "Using $(nthreads()) threads in Groebner.jl"

# Run benchmarks on the latest stable version of Groebner.jl
dir_stable = (@__DIR__) * "/run-on-stable"
Expand Down
72 changes: 67 additions & 5 deletions experimental/example-maybe-bug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,79 @@ using AbstractAlgebra, BenchmarkTools # , Groebner
R, (x1, x2, x3) = PolynomialRing(GF(2^27 + 29), ["x1", "x2", "x3"], ordering=:degrevlex)
R, (x1, x2, x3) = PolynomialRing(GF(2^31 - 1), ["x1", "x2", "x3"], ordering=:degrevlex)

s = [x1 * x2^2 + 2, x1 * x3 + 3, x2 * x3 + 4 * x1 - 5]
gb = Groebner.groebner(s, loglevel=-5)
gb
s = [x1 * x2^5 + 2, x1^3 * x3 + 3, x2^2 * x3^3 + 4 * x1^4 - 5]
gb1 = Groebner.groebner(
s,
loglevel=-5,
linalg=:deterministic,
threaded=:yes,
threadalgo=:lock_free,
nworkers=3
);
gb2 = Groebner.groebner(
s,
loglevel=-5,
linalg=:deterministic,
threaded=:yes,
threadalgo=:compare_and_swap,
nworkers=3
);
gb3 = Groebner.groebner(s, loglevel=-5, linalg=:deterministic, threaded=:no);
gb1 == gb2 == gb3

p1 = 2^31 - 1
p2 = 2^29 + 11
p3 = 2^27 + 29
p4 = 2^25 + 35
s = Groebner.eco11(ordering=:degrevlex, ground=AbstractAlgebra.GF(p4))
s = Groebner.katsuran(10, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))

Groebner.logging_enabled() = false
Groebner.invariants_enabled() = false
@time gb1 = Groebner.groebner(
s,
linalg=:deterministic,
threaded=:yes,
threadalgo=:compare_and_swap,
loglevel=0,
nworkers=1
);
@time gb2 = Groebner.groebner(s, loglevel=0, linalg=:deterministic, threaded=:no);
gb1 == gb2

@time gb1 = Groebner.groebner(s);
BenchmarkTools.DEFAULT_PARAMETERS.samples = 3
systems = [
("kat7", Groebner.katsuran(7, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("kat8", Groebner.katsuran(8, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("kat9", Groebner.katsuran(9, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("kat10", Groebner.katsuran(10, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("cyc6", Groebner.cyclicn(6, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("cyc7", Groebner.cyclicn(7, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("cyc8", Groebner.cyclicn(8, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("eco10", Groebner.eco10(ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("eco11", Groebner.eco11(ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("eco12", Groebner.eco12(ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("noon6", Groebner.noonn(6, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2))),
("noon7", Groebner.noonn(7, ordering=:degrevlex, ground=AbstractAlgebra.GF(p2)))
]
for (name, s) in systems
@info "$name: lock_free / compare_and_swap / single_thread"
gb1 = @btime Groebner.groebner(
$s,
linalg=:deterministic,
threaded=:yes,
loglevel=0,
threadalgo=:lock_free
)
gb2 = @btime Groebner.groebner(
$s,
linalg=:deterministic,
threaded=:yes,
loglevel=0,
threadalgo=:compare_and_swap
)
gb3 = @btime Groebner.groebner($s, loglevel=0, linalg=:deterministic, threaded=:no)
@assert gb1 == gb2 == gb3
end

@time trace, gb2 = Groebner.groebner_learn(s);

Expand Down
Loading

0 comments on commit 54a29fa

Please sign in to comment.