From 236286962b4472d6fe22674b5c5761432cf2ebaa Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 08:16:51 +1300 Subject: [PATCH 1/9] Relax allocation tests on nightly --- test/big.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/big.jl b/test/big.jl index 9c0a5fd8..ecbbb4ab 100644 --- a/test/big.jl +++ b/test/big.jl @@ -45,9 +45,9 @@ end @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] MA.Test.int_test(T) @testset "Allocation" begin - allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 168 : 0) - allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 240 : 0) + allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) + allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 224 : 0) + allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 280 : 0) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 @@ -56,7 +56,7 @@ end T, MA.add!!, MA.add_to!!, - 168, + 224, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), @@ -66,7 +66,7 @@ end T, MA.sub!!, MA.sub_to!!, - 168, + 224, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), From 5f5722d43819e22395a250060649accba1f7fb1c Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 08:21:51 +1300 Subject: [PATCH 2/9] Update --- test/big.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/big.jl b/test/big.jl index ecbbb4ab..48746131 100644 --- a/test/big.jl +++ b/test/big.jl @@ -47,7 +47,7 @@ end @testset "Allocation" begin allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 224 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 280 : 0) + allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 312 : 0) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 From 1bdddce69dd9134d139e360f492d6567beb687ea Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 08:29:56 +1300 Subject: [PATCH 3/9] Update --- test/big.jl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/big.jl b/test/big.jl index 48746131..71d72b63 100644 --- a/test/big.jl +++ b/test/big.jl @@ -5,15 +5,15 @@ # one at http://mozilla.org/MPL/2.0/. function allocation_test( - op, - T, - short, - short_to, - n; + op::F1, + ::Type{T}, + short::F2, + short_to::F3, + n::Integer; a = T(2), b = T(3), c = T(4), -) +) where {T,F1,F2,F3} @test MA.promote_operation(op, T, T) == T alloc_test(() -> MA.promote_operation(op, T, T), 0) if op != div && op != - @@ -45,9 +45,9 @@ end @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] MA.Test.int_test(T) @testset "Allocation" begin - allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) - allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 224 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 312 : 0) + allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 192 : 0) + allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0) + allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 240 : 0) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 @@ -56,7 +56,7 @@ end T, MA.add!!, MA.add_to!!, - 224, + 192, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), @@ -66,7 +66,7 @@ end T, MA.sub!!, MA.sub_to!!, - 224, + 168, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), From d5101ce7351ac22cc011c3d4f9cf0e5a87b41416 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 09:05:48 +1300 Subject: [PATCH 4/9] Update --- test/big.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/big.jl b/test/big.jl index 71d72b63..37840036 100644 --- a/test/big.jl +++ b/test/big.jl @@ -45,9 +45,9 @@ end @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] MA.Test.int_test(T) @testset "Allocation" begin - allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 192 : 0) + allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 240 : 0) + allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 280 : 0) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 @@ -56,7 +56,7 @@ end T, MA.add!!, MA.add_to!!, - 192, + 224, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), From c27b48b3b56a35ee2b9be2129fda751fcef304e7 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 09:50:25 +1300 Subject: [PATCH 5/9] Update --- test/big.jl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/big.jl b/test/big.jl index 37840036..2fb37c59 100644 --- a/test/big.jl +++ b/test/big.jl @@ -45,9 +45,15 @@ end @testset "$T" for T in [BigInt, BigFloat, Rational{BigInt}] MA.Test.int_test(T) @testset "Allocation" begin - allocation_test(+, T, MA.add!!, MA.add_to!!, T <: Rational ? 224 : 0) - allocation_test(-, T, MA.sub!!, MA.sub_to!!, T <: Rational ? 168 : 0) - allocation_test(*, T, MA.mul!!, MA.mul_to!!, T <: Rational ? 280 : 0) + a, b = T(2), T(3) + a + b, a - b, a * b # compilation + # Test that the MA methods have fewer allocated than the Base method + n = T <: Rational ? (@allocated a + b) - 1 : 0 + allocation_test(+, T, MA.add!!, MA.add_to!!, n) + n = T <: Rational ? (@allocated a - b) - 1 : 0 + allocation_test(-, T, MA.sub!!, MA.sub_to!!, n) + n = T <: Rational ? (@allocated a * b) - 1 : 0 + allocation_test(*, T, MA.mul!!, MA.mul_to!!, n) add_sub_mul_test(MA.add_mul, T) add_sub_mul_test(MA.sub_mul, T) if T <: Rational # https://github.com/jump-dev/MutableArithmetics.jl/issues/167 @@ -56,7 +62,7 @@ end T, MA.add!!, MA.add_to!!, - 224, + (@allocated a + b) - 1, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), @@ -66,7 +72,7 @@ end T, MA.sub!!, MA.sub_to!!, - 168, + (@allocated a - b) - 1, a = T(1 // 2), b = T(3 // 2), c = T(5 // 2), From 48fe2237a12bd48bb551111a7a214fc4211dda93 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 09:58:24 +1300 Subject: [PATCH 6/9] Update --- test/broadcast.jl | 2 +- test/utilities.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/broadcast.jl b/test/broadcast.jl index 4124230b..b66500ad 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -31,7 +31,7 @@ end @test y == 5 # FIXME This should not allocate but I couldn't figure out where these # 240 come from. - alloc_test(() -> MA.broadcast!!(+, a, b), 30 * sizeof(Int)) + alloc_test_le(() -> MA.broadcast!!(+, a, b), 288) alloc_test(() -> MA.broadcast!!(+, a, c), 0) end diff --git a/test/utilities.jl b/test/utilities.jl index a1535121..efb14ca3 100644 --- a/test/utilities.jl +++ b/test/utilities.jl @@ -10,12 +10,12 @@ include("dummy.jl") # Half size on 32-bit. const BIGINT_ALLOC = Sys.WORD_SIZE == 64 ? 48 : 24 -function alloc_test(f, n) +function alloc_test(f::F, n) where {F} f() # compile @test n == @allocated f() end -function alloc_test_le(f, n) +function alloc_test_le(f::F, n) where {F} f() # compile @test n >= @allocated f() end From e7f3da4484062d890282e6d31d4623907dcee42d Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 09:58:41 +1300 Subject: [PATCH 7/9] Update --- test/broadcast.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/broadcast.jl b/test/broadcast.jl index b66500ad..524bbe27 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -30,7 +30,7 @@ end @test x == 4 @test y == 5 # FIXME This should not allocate but I couldn't figure out where these - # 240 come from. + # allocations come from. alloc_test_le(() -> MA.broadcast!!(+, a, b), 288) alloc_test(() -> MA.broadcast!!(+, a, c), 0) end From 3ca37099622db91ae37fa8ab0b8c7b91ec0f6df5 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Nov 2024 10:09:46 +1300 Subject: [PATCH 8/9] Update test/broadcast.jl --- test/broadcast.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/broadcast.jl b/test/broadcast.jl index 524bbe27..cb4de466 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -31,7 +31,7 @@ end @test y == 5 # FIXME This should not allocate but I couldn't figure out where these # allocations come from. - alloc_test_le(() -> MA.broadcast!!(+, a, b), 288) + alloc_test_le(() -> MA.broadcast!!(+, a, b), 336) alloc_test(() -> MA.broadcast!!(+, a, c), 0) end From fceadb474ed344f7bed1ccc994e7765030e45d49 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 13 Jan 2025 16:43:26 +1300 Subject: [PATCH 9/9] Update --- test/matmul.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/matmul.jl b/test/matmul.jl index 9e8d3b86..f45bbfce 100644 --- a/test/matmul.jl +++ b/test/matmul.jl @@ -281,10 +281,10 @@ end ) alloc_test(() -> MA.mutability(C, MA.add_mul, C, A, B), 0) end - - alloc_test(() -> MA.add_mul!!(C, A, B), BIGINT_ALLOC) - alloc_test(() -> MA.operate!!(MA.add_mul, C, A, B), BIGINT_ALLOC) - alloc_test(() -> MA.operate!(MA.add_mul, C, A, B), BIGINT_ALLOC) + allocs = BIGINT_ALLOC + (VERSION >= v"1.12.0-DEV" ? 8 : 0) + alloc_test(() -> MA.add_mul!!(C, A, B), allocs) + alloc_test(() -> MA.operate!!(MA.add_mul, C, A, B), allocs) + alloc_test(() -> MA.operate!(MA.add_mul, C, A, B), allocs) end end