-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,281 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using AbstractAlgebra, Groebner | ||
|
||
R, (x, y, z, t) = AbstractAlgebra.polynomial_ring(AbstractAlgebra.QQ, ["x", "y", "z", "t"]) | ||
sys = [ | ||
y^2 * z + 2 * x * y * t - 2 * x - z, | ||
-x^3 * z + 4 * x * y^2 * z + 4 * x^2 * y * t + 2 * y^3 * t + 4 * x^2 - 10 * y^2 + | ||
4 * x * z - 10 * y * t + 2, | ||
2 * y * z * t + x * t^2 - x - 2 * z, | ||
-x * z^3 + 4 * y * z^2 * t + 4 * x * z * t^2 + 2 * y * t^3 + 4 * x * z + 4 * z^2 - | ||
10 * y * t - 10 * t^2 + 2 | ||
] | ||
|
||
gb_lex = Groebner.groebner(sys, ordering=Groebner.Lex()) | ||
gb_drl = Groebner.groebner(sys, ordering=Groebner.DegRevLex()) | ||
gb_fglm = Groebner.fglm(gb_drl, Groebner.DegRevLex(), Groebner.Lex()) | ||
|
||
@info "" gb_fglm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
using BenchmarkTools | ||
|
||
using HostCPUFeatures | ||
using HostCPUFeatures: | ||
register_size, | ||
pick_vector_width, | ||
pick_vector_width_shift, | ||
simd_integer_register_size, | ||
fma_fast, | ||
has_feature, | ||
register_count, | ||
cpu_name, | ||
register_size | ||
|
||
######### | ||
|
||
_setup1(n) = begin | ||
x = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
y = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
x, y | ||
end | ||
_setup2(n) = begin | ||
x = vcat(zeros(UInt8, n), rand(UInt8.([0, 0, 0, 1, 2, 3]), n)) | ||
y = vcat(zeros(UInt8, n), rand(UInt8.([0, 0, 0, 1, 2, 3]), n)) | ||
x, y | ||
end | ||
_setup3(T, n) = begin | ||
s = rand(T.([0, 0, 0, 1, 2, 3]), 3) | ||
x = Groebner.monom_construct_from_vector( | ||
Groebner.ExponentVector{T}, | ||
vcat(zeros(T, n), s) | ||
) | ||
y = Groebner.monom_construct_from_vector( | ||
Groebner.ExponentVector{T}, | ||
vcat(zeros(T, n), reverse(s)) | ||
) | ||
z = similar(x) | ||
@assert Groebner.monom_totaldeg(x) == Groebner.monom_totaldeg(y) | ||
z, x, y | ||
end | ||
|
||
######### | ||
|
||
begin | ||
n, step = 1, 5 | ||
while n < 500 | ||
@info "n = $n" | ||
print("Groebner.monom_is_equal\t\t") | ||
@btime Groebner.monom_is_equal(xx, yy) setup = begin | ||
cc, xx, yy = _setup3(Int8, max(1, $n)) | ||
end | ||
print("Groebner.monom_copy\t\t") | ||
@btime Groebner.monom_copy(xx) setup = begin | ||
cc, xx, yy = _setup3(Int8, max(1, $n)) | ||
end | ||
print("Groebner.monom_is_divisible\t") | ||
@btime Groebner.monom_is_divisible(xx, yy) setup = begin | ||
cc, xx, yy = _setup3(Int8, $n) | ||
end | ||
print("Groebner.monom_product!\t\t") | ||
@btime Groebner.monom_product!(cc, xx, yy) setup = begin | ||
cc, xx, yy = _setup3(Int8, max(1, $n)) | ||
end | ||
print("Groebner.monom_lcm!\t\t") | ||
@btime Groebner.monom_lcm!(cc, xx, yy) setup = begin | ||
cc, xx, yy = _setup3(Int8, max(1, $n)) | ||
end | ||
print("Groebner.monom_is_gcd_const\t") | ||
@btime Groebner.monom_is_gcd_const(xx, yy) setup = begin | ||
cc, xx, yy = _setup3(Int8, $n) | ||
end | ||
print("Groebner.monom_isless:lex\t") | ||
@btime Groebner.monom_isless(xx, yy, _ord) setup = begin | ||
cc, xx, yy = _setup3(Int8, max(1, $n)) | ||
_ord = Groebner._Lex{true}(ones(Int, length(xx))) | ||
end | ||
print("Groebner.monom_isless:drl\t") | ||
@btime Groebner.monom_isless(xx, yy, _ord) setup = begin | ||
cc, xx, yy = map(reverse, _setup3(Int8, max(1, $n))) | ||
xx[1] = xx[end] | ||
yy[1] = yy[end] | ||
@assert Groebner.monom_totaldeg(xx) == Groebner.monom_totaldeg(yy) | ||
_ord = Groebner._DegRevLex{true}(ones(Int, length(xx))) | ||
end | ||
n += step | ||
step = ceil(Int, step * 1.2) | ||
end | ||
end | ||
|
||
_setup4(n) = begin | ||
s = rand(UInt8.([0, 0, 0, 1, 2, 3]), 2) | ||
a, b = vcat(zeros(UInt8, n), s), vcat(zeros(UInt8, n), reverse(s)) | ||
a, b = reverse(a), reverse(b) | ||
x = Groebner.monom_construct_from_vector(Groebner.ExponentVector{UInt8}, a) | ||
y = Groebner.monom_construct_from_vector(Groebner.ExponentVector{UInt8}, b) | ||
vT(n) = | ||
if n + 2 < 8 | ||
Groebner.PackedTuple1 | ||
elseif n + 2 < 16 | ||
Groebner.PackedTuple2 | ||
elseif n + 2 < 24 | ||
Groebner.PackedTuple3 | ||
end | ||
xpacked = Groebner.monom_construct_from_vector(vT(n){UInt64, UInt8}, a) | ||
ypacked = Groebner.monom_construct_from_vector(vT(n){UInt64, UInt8}, b) | ||
x, y, xpacked, ypacked | ||
end | ||
begin | ||
n, step = 1, 3 | ||
while n < 22 | ||
@info "n = $n" | ||
print("Groebner.monom_isless:drl:packed\t") | ||
@btime Groebner.monom_isless(xpacked, ypacked, _ord) setup = begin | ||
x, y, xpacked, ypacked = _setup4($n) | ||
_ord = Groebner._DegRevLex{true}(ones(Int, length(x))) | ||
@assert Groebner.monom_totaldeg(xpacked) == Groebner.monom_totaldeg(ypacked) | ||
tmp1, tmp2 = | ||
Vector{Int8}(undef, length(x) - 1), Vector{Int8}(undef, length(x) - 1) | ||
@assert Groebner.monom_to_vector!(tmp1, x) == | ||
Groebner.monom_to_vector!(tmp2, xpacked) | ||
@assert Groebner.monom_to_vector!(tmp1, y) == | ||
Groebner.monom_to_vector!(tmp2, ypacked) | ||
end | ||
print("Groebner.monom_isless:drl:expvect\t") | ||
@btime Groebner.monom_isless(x, y, _ord) setup = begin | ||
x, y, xpacked, ypacked = _setup4($n) | ||
_ord = Groebner._DegRevLex{true}(ones(Int, length(x))) | ||
@assert Groebner.monom_totaldeg(x) == Groebner.monom_totaldeg(y) | ||
end | ||
n += step | ||
end | ||
end | ||
|
||
begin | ||
n, step = 1, 5 | ||
while n < 500 | ||
@info "n = $n" | ||
for _ in 1:1_000 | ||
x, y = _setup3(n) | ||
res1 = vector_are_orth(x, y) | ||
res2 = _vec_check_orth(x, y) | ||
@assert res1 == res2 | ||
end | ||
@btime vector_are_orth(xx, yy) setup = begin | ||
xx, yy = _setup3($n) | ||
end | ||
@btime _vec_check_orth(xx, yy) setup = begin | ||
xx, yy = _setup3($n) | ||
end | ||
n += step | ||
step = ceil(Int, step * 1.2) | ||
end | ||
end | ||
|
||
begin | ||
_setup1(n) = begin | ||
x = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
y = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
x, y | ||
end | ||
_setup2(n) = begin | ||
x = vcat(zeros(UInt8, n), rand(UInt8.([0, 0, 0, 1, 2, 3]), n)) | ||
y = vcat(zeros(UInt8, n), rand(UInt8.([0, 0, 0, 1, 2, 3]), n)) | ||
x, y | ||
end | ||
_setup3(n) = begin | ||
x = vcat(zeros(Int16, n), rand(Int16.([0, 0, 0, 1, 2, 3]), n)) | ||
y = vcat(zeros(Int16, n), rand(Int16.([0, 0, 0, 1, 2, 3]), n)) | ||
x, y | ||
end | ||
n, step = 1, 5 | ||
while n < 500 | ||
@info "n = $n" | ||
n += step | ||
step = ceil(Int, step * 1.2) | ||
for _ in 1:100 | ||
x, y = _setup3(n) | ||
res1 = vector_any_lt(x, y) | ||
res2 = vector_any_lt_simd(x, y) | ||
@assert res1 == res2 | ||
end | ||
@btime vector_any_lt(xx, yy) setup = begin | ||
xx, yy = _setup3($n) | ||
end | ||
@btime vector_any_lt_simd(xx, yy) setup = begin | ||
xx, yy = _setup3($n) | ||
end | ||
end | ||
end | ||
|
||
######### | ||
|
||
begin | ||
_setup1(n) = begin | ||
x = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
y = rand(UInt8.([0, 0, 0, 1, 2, 3]), n) | ||
similar(x), x, y | ||
end | ||
n, step = 1, 5 | ||
while n < 500 | ||
@info "n = $n" | ||
n += step | ||
step = ceil(Int, step * 1.2) | ||
for _ in 1:100 | ||
c, x, y = _setup1(n) | ||
res1 = vector_emax_1!(copy(c), x, y) | ||
res2 = vector_emax_2!(copy(c), x, y) | ||
@assert res1 == res2 | ||
end | ||
@btime vector_emax_1!(cc, xx, yy) setup = begin | ||
cc, xx, yy = _setup1($n) | ||
end | ||
@btime vector_emax_2!(cc, xx, yy) setup = begin | ||
cc, xx, yy = _setup1($n) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
.text | ||
.file "mod_p" | ||
.section .rodata.cst8,"aM",@progbits,8 | ||
.p2align 3 # -- Begin function julia_mod_p_61774 | ||
.LCPI0_0: | ||
.quad -9223372036854775808 # 0x8000000000000000 | ||
.text | ||
.globl julia_mod_p_61774 | ||
.p2align 4, 0x90 | ||
.type julia_mod_p_61774,@function | ||
julia_mod_p_61774: # @julia_mod_p_61774 | ||
.cfi_startproc | ||
# %bb.0: # %top | ||
push rbp | ||
.cfi_def_cfa_offset 16 | ||
.cfi_offset rbp, -16 | ||
mov rbp, rsp | ||
.cfi_def_cfa_register rbp | ||
push rsi | ||
push rdi | ||
.cfi_offset rdi, -32 | ||
.cfi_offset rsi, -24 | ||
mov r9, rdx | ||
mov r10, rcx | ||
vpmovsxbq ymm2, dword ptr [r8 + 96] | ||
vpmovzxbq ymm1, dword ptr [r8 + 100] # ymm1 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero,mem[2],zero,zero,zero,zero,zero,zero,zero,mem[3],zero,zero,zero,zero,zero,zero,zero | ||
mov r11, qword ptr [r8 + 80] | ||
mov rcx, qword ptr [r8 + 72] | ||
mov rax, qword ptr [r8 + 64] | ||
imul qword ptr [rdx] | ||
mov rdi, rdx | ||
mov rax, rcx | ||
imul qword ptr [r9 + 8] | ||
mov rcx, rdx | ||
mov rax, r11 | ||
imul qword ptr [r9 + 16] | ||
mov rsi, rdx | ||
vmovdqu ymm0, ymmword ptr [r9] | ||
mov rax, qword ptr [r8 + 88] | ||
imul qword ptr [r9 + 24] | ||
vmovq xmm3, rdx | ||
vmovq xmm4, rsi | ||
vpunpcklqdq xmm3, xmm4, xmm3 # xmm3 = xmm4[0],xmm3[0] | ||
vmovq xmm4, rcx | ||
vmovq xmm5, rdi | ||
vpunpcklqdq xmm4, xmm5, xmm4 # xmm4 = xmm5[0],xmm4[0] | ||
vinserti128 ymm3, ymm4, xmm3, 1 | ||
vpsrlq ymm4, ymm0, 32 | ||
vpmuludq ymm4, ymm4, ymm2 | ||
vpsrlq ymm5, ymm2, 32 | ||
vpmuludq ymm5, ymm0, ymm5 | ||
vpaddq ymm4, ymm5, ymm4 | ||
vpsllq ymm4, ymm4, 32 | ||
vpmuludq ymm2, ymm0, ymm2 | ||
vpaddq ymm2, ymm2, ymm3 | ||
vpaddq ymm2, ymm4, ymm2 | ||
vpxor xmm3, xmm3, xmm3 | ||
vpsrlvq ymm4, ymm2, ymm1 | ||
movabs rax, offset .LCPI0_0 | ||
vpbroadcastq ymm5, qword ptr [rax] | ||
vpsrlvq ymm1, ymm5, ymm1 | ||
vpxor ymm4, ymm4, ymm1 | ||
vpsubq ymm1, ymm4, ymm1 | ||
vpsrlq ymm2, ymm2, 63 | ||
vpaddq ymm1, ymm1, ymm2 | ||
vmovdqu ymm2, ymmword ptr [r8] | ||
vpsrlq ymm4, ymm2, 32 | ||
vpmuludq ymm4, ymm1, ymm4 | ||
vpsrlq ymm5, ymm1, 32 | ||
vpmuludq ymm5, ymm5, ymm2 | ||
vpaddq ymm4, ymm4, ymm5 | ||
vpsllq ymm4, ymm4, 32 | ||
vpmuludq ymm1, ymm1, ymm2 | ||
vpaddq ymm1, ymm1, ymm4 | ||
vpsubq ymm0, ymm0, ymm1 | ||
vpcmpgtq ymm1, ymm3, ymm0 | ||
vpand ymm1, ymm1, ymm2 | ||
vpaddq ymm0, ymm1, ymm0 | ||
vpcmpgtq ymm1, ymm0, ymm2 | ||
vpand ymm1, ymm1, ymm2 | ||
vpsubq ymm0, ymm0, ymm1 | ||
vmovdqu ymmword ptr [r10], ymm0 | ||
mov rax, r10 | ||
pop rdi | ||
pop rsi | ||
pop rbp | ||
vzeroupper | ||
ret | ||
.Lfunc_end0: | ||
.size julia_mod_p_61774, .Lfunc_end0-julia_mod_p_61774 | ||
.cfi_endproc | ||
# -- End function | ||
.section ".note.GNU-stack","",@progbits |
Oops, something went wrong.