Skip to content

Commit

Permalink
hotfix for llvm ir!
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Demin committed Jan 26, 2024
1 parent 1e0fd5d commit 9561c0e
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 26 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
## Groebner v0.6.4 Release notes

Minor performance improvements, especially over finite fields of large characteristic.

Versions of dependencies:
- Updated dependency on AbstractAlgebra.jl and Nemo.jl.
- Now Groebmer.jl depends on HostCPUFeatures.jl v0.1+.

## Groebner v0.6.3 Release notes

Now we handle both `Nemo.GF` and `Nemo.Native.GF` as the coefficient ring.

## Groebner v0.6.1-2 Release notes

Bug fixes.
Some bug fixes.

## Groebner v0.6.0 Release notes

New features:
- Adds the possibility of parallel computation, can be activated by the `threaded` keyword argument in function `groebner`.
- Major speed-ups over the rationals thanks to the new learn & apply strategy and rational number reconstruction from Nemo.
- Major speed-ups over the rationals thanks to the new learn & apply strategy and the use of rational number reconstruction from Nemo.
- Marginal speed-ups over some finite fields due to the new implementations of arithmetic in Z/pZ.

Other:
Versions of dependencies:
- Added a dependency on Nemo.jl.

## Groebner v0.5.0 Release notes
Expand Down
25 changes: 24 additions & 1 deletion benchmark/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ git-tree-sha1 = "f1f03a9fa24271160ed7e73051fba3c1a759b53f"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.4.0"

[[deps.BitTwiddlingConvenienceFunctions]]
deps = ["Static"]
git-tree-sha1 = "0c5f81f47bbbcf4aea7b2959135713459170798b"
uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b"
version = "0.1.5"

[[deps.Calcium_jll]]
deps = ["Antic_jll", "Arb_jll", "Artifacts", "FLINT_jll", "GMP_jll", "JLLWrappers", "Libdl", "MPFR_jll", "Pkg"]
git-tree-sha1 = "37fd335ecca9bd6ab25a2a4d26b7b2f6fe64c246"
Expand Down Expand Up @@ -146,7 +152,7 @@ uuid = "781609d7-10c4-51f6-84f2-b8444358ff6d"
version = "6.2.1+2"

[[deps.Groebner]]
deps = ["AbstractAlgebra", "Atomix", "Combinatorics", "ExprTools", "Logging", "MultivariatePolynomials", "Nemo", "PrecompileTools", "PrettyTables", "Primes", "Printf", "Random", "TimerOutputs"]
deps = ["AbstractAlgebra", "Atomix", "Combinatorics", "ExprTools", "HostCPUFeatures", "Logging", "MultivariatePolynomials", "Nemo", "PrecompileTools", "PrettyTables", "Primes", "Printf", "Random", "TimerOutputs"]
path = ".."
uuid = "0b43b601-686d-58a3-8a1c-6623616c7cd4"
version = "0.6.3"
Expand All @@ -157,6 +163,17 @@ git-tree-sha1 = "6df9cd6ee79fc59feab33f63a1b3c9e95e2461d5"
uuid = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
version = "0.4.2"

[[deps.HostCPUFeatures]]
deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"]
git-tree-sha1 = "eb8fed28f4994600e29beef49744639d985a04b2"
uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0"
version = "0.1.16"

[[deps.IfElse]]
git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
version = "0.1.1"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
uuid = "18e54dd8-cb9d-406c-a71d-865a43cbb235"
Expand Down Expand Up @@ -369,6 +386,12 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[deps.Static]]
deps = ["IfElse"]
git-tree-sha1 = "f295e0a1da4ca425659c57441bcb59abb035a4bc"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.8.8"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand Down
25 changes: 24 additions & 1 deletion benchmark/generate/groebner/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ git-tree-sha1 = "f1f03a9fa24271160ed7e73051fba3c1a759b53f"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.4.0"

[[deps.BitTwiddlingConvenienceFunctions]]
deps = ["Static"]
git-tree-sha1 = "0c5f81f47bbbcf4aea7b2959135713459170798b"
uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b"
version = "0.1.5"

[[deps.Calcium_jll]]
deps = ["Antic_jll", "Arb_jll", "Artifacts", "FLINT_jll", "GMP_jll", "JLLWrappers", "Libdl", "MPFR_jll", "Pkg"]
git-tree-sha1 = "37fd335ecca9bd6ab25a2a4d26b7b2f6fe64c246"
Expand Down Expand Up @@ -146,7 +152,7 @@ uuid = "781609d7-10c4-51f6-84f2-b8444358ff6d"
version = "6.2.1+2"

[[deps.Groebner]]
deps = ["AbstractAlgebra", "Atomix", "Combinatorics", "ExprTools", "Logging", "MultivariatePolynomials", "Nemo", "PrecompileTools", "PrettyTables", "Primes", "Printf", "Random", "TimerOutputs"]
deps = ["AbstractAlgebra", "Atomix", "Combinatorics", "ExprTools", "HostCPUFeatures", "Logging", "MultivariatePolynomials", "Nemo", "PrecompileTools", "PrettyTables", "Primes", "Printf", "Random", "TimerOutputs"]
path = "../../.."
uuid = "0b43b601-686d-58a3-8a1c-6623616c7cd4"
version = "0.6.3"
Expand All @@ -157,6 +163,17 @@ git-tree-sha1 = "6df9cd6ee79fc59feab33f63a1b3c9e95e2461d5"
uuid = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
version = "0.4.2"

[[deps.HostCPUFeatures]]
deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"]
git-tree-sha1 = "eb8fed28f4994600e29beef49744639d985a04b2"
uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0"
version = "0.1.16"

[[deps.IfElse]]
git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
version = "0.1.1"

[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
uuid = "18e54dd8-cb9d-406c-a71d-865a43cbb235"
Expand Down Expand Up @@ -364,6 +381,12 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[deps.Static]]
deps = ["IfElse"]
git-tree-sha1 = "f295e0a1da4ca425659c57441bcb59abb035a4bc"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.8.8"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand Down
9 changes: 5 additions & 4 deletions benchmark/results/benchmark_result_0.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Benchmark results

2024-01-24T03:13:43.861
2024-01-26T23:39:30.428

Benchmarked backends: Any["groebner", "maple", "msolve"]

Benchmark suite: dummy benchmark set

- Workers: 16
- Timeout: 600 s
- Timeout: 1800 s
- Aggregated over: 1 runs

**All timings in seconds.**

|Model|groebner|maple|msolve|
|:----|---|---|---|
|dummy 1|0.00|0.01|0.04|
|dummy 2|0.00|0.02|0.03|
|dummy 1|0.00|0.24|0.03|
|dummy 2|0.00|0.23|0.03|

*Benchmarking environment:*

Expand All @@ -30,6 +30,7 @@ Versions of the dependencies:
* PrecompileTools : 1.2.0
* MultivariatePolynomials : 0.5.3
* Combinatorics : 1.0.2
* HostCPUFeatures : 0.1.16
* AbstractAlgebra : 0.34.7
* Nemo : 0.38.3
* Atomix : 0.1.0
Expand Down
5 changes: 3 additions & 2 deletions benchmark/results/groebner/benchmark_result_0.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Benchmark results

2024-01-24T03:13:25.755
2024-01-26T23:39:00.057

Benchmarked backend: groebner

Benchmark suite: dummy benchmark set

- Workers: 16
- Timeout: 600 s
- Timeout: 1800 s
- Aggregated over: 1 runs

**All timings in seconds.**
Expand All @@ -30,6 +30,7 @@ Versions of the dependencies:
* PrecompileTools : 1.2.0
* MultivariatePolynomials : 0.5.3
* Combinatorics : 1.0.2
* HostCPUFeatures : 0.1.16
* AbstractAlgebra : 0.34.7
* Nemo : 0.38.3
* Atomix : 0.1.0
Expand Down
11 changes: 6 additions & 5 deletions benchmark/results/maple/benchmark_result_0.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Benchmark results

2024-01-26T14:25:53.125
2024-01-26T23:39:14.885

Benchmarked backend: maple

Benchmark suite: dummy benchmark set

- Workers: 16
- Timeout: 120 s
- Aggregated over: 3 runs
- Timeout: 1800 s
- Aggregated over: 1 runs

**All timings in seconds.**

|Model|Total, s|
|:----|---|
|dummy 1|0.22|
|dummy 2|0.20|
|dummy 1|0.24|
|dummy 2|0.23|

*Benchmarking environment:*

Expand All @@ -30,6 +30,7 @@ Versions of the dependencies:
* PrecompileTools : 1.2.0
* MultivariatePolynomials : 0.5.3
* Combinatorics : 1.0.2
* HostCPUFeatures : 0.1.16
* AbstractAlgebra : 0.34.7
* Nemo : 0.38.3
* Atomix : 0.1.0
Expand Down
7 changes: 4 additions & 3 deletions benchmark/results/msolve/benchmark_result_0.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## Benchmark results

2024-01-24T03:13:42.132
2024-01-26T23:39:28.793

Benchmarked backend: msolve

Benchmark suite: dummy benchmark set

- Workers: 16
- Timeout: 600 s
- Timeout: 1800 s
- Aggregated over: 1 runs

**All timings in seconds.**

|Model|Total, s|
|:----|---|
|dummy 1|0.04|
|dummy 1|0.03|
|dummy 2|0.03|

*Benchmarking environment:*
Expand All @@ -30,6 +30,7 @@ Versions of the dependencies:
* PrecompileTools : 1.2.0
* MultivariatePolynomials : 0.5.3
* Combinatorics : 1.0.2
* HostCPUFeatures : 0.1.16
* AbstractAlgebra : 0.34.7
* Nemo : 0.38.3
* Atomix : 0.1.0
Expand Down
21 changes: 17 additions & 4 deletions src/utils/simd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ end
B = sizeof(T)
llvm_t = j_to_llvm_t(T)
mask = typemax_saturated(Int, N)
typecast_iN_to_i64(varname) =
if N == 64
""
else
"$(varname)64 = zext i$(N) $(varname)$(N) to i64\n"
end
textir = """
declare i$N @llvm.cttz.i$N(i$N, i1);
define i8 @entry(i64 %0, i64 %1, i64 %2) #0 {
Expand Down Expand Up @@ -293,7 +299,7 @@ end
L17:
%tz$N = call i$N @llvm.cttz.i$N(i$N %compressed, i1 true)
%tz64 = zext i$N %tz$N to i64
$(typecast_iN_to_i64("%tz"))
%vis = add nuw i64 %i, %tz64
%sapi2 = getelementptr inbounds $llvm_t, $llvm_t* %a, i64 %vis
%sbpi2 = getelementptr inbounds $llvm_t, $llvm_t* %b, i64 %vis
Expand Down Expand Up @@ -372,6 +378,13 @@ end
B = sizeof(T)
llvm_t = j_to_llvm_t(T)
mask = typemax_saturated(Int, N)
typecast_iN_to_i64(varname) =
if N == 64
""
else
"$(varname)64 = zext i$(N) $(varname)$(N) to i64\n"
end

textir = """
declare i$N @llvm.ctlz.i$N(i$N, i1);
define i8 @entry(i64 %0, i64 %1, i64 %2) #0 {
Expand Down Expand Up @@ -402,9 +415,9 @@ end
br i1 %matchfnotound, label %L30, label %L17
L17:
%tz$N = call i$N @llvm.ctlz.i$N(i$N %compressed, i1 true)
%tz$N.rev = sub i$N $(N-1), %tz$N
%tz64 = zext i$N %tz$N.rev to i64
%tz$N.rev = call i$N @llvm.ctlz.i$N(i$N %compressed, i1 true)
%tz$N = sub i$N $(N-1), %tz$N.rev
$(typecast_iN_to_i64("%tz"))
%vis = add nsw i64 %i, %tz64
%sapi2 = getelementptr inbounds $llvm_t, $llvm_t* %a, i64 %vis
%sbpi2 = getelementptr inbounds $llvm_t, $llvm_t* %b, i64 %vis
Expand Down
3 changes: 0 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ function try_import(name::Symbol)
end
end

# @test isempty(Test.detect_unbound_args(Groebner))
@test isempty(Test.detect_ambiguities(Groebner))

(xs, ys) = all(in(ys), xs)
(xs, ys) = (xs, ys) && (ys, xs)

# Groebner.versioninfo()

@time @testset "All tests" verbose = true begin
# Basic tests for addition in Zp
@time @includetests ["arithmetic/Zp"]
Expand Down

0 comments on commit 9561c0e

Please sign in to comment.