-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assume mutability for canonical #31
Conversation
test/caching_allocations.jl
Outdated
@@ -51,6 +51,8 @@ end | |||
@test Y * Y isa AlgebraElement | |||
Y * Y | |||
k2 = @allocated Y * Y | |||
@show k1 | |||
@show k2 | |||
@test k2 / k1 < 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we are checking the value of this ratio ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that we know the caching had effect (i.e. reduced the number of allocations).
Should it then be < 1.0 ? what was it before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change it, I left it at 0.5
test/caching_allocations.jl
Outdated
@@ -51,6 +51,8 @@ end | |||
@test Y * Y isa AlgebraElement | |||
Y * Y | |||
k2 = @allocated Y * Y | |||
@show k1 | |||
@show k2 | |||
@test k2 / k1 < 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that we know the caching had effect (i.e. reduced the number of allocations).
Should it then be < 1.0 ? what was it before?
test/caching_allocations.jl
Outdated
@show k1 | ||
@show k2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't need those @show
s ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them to see what ratio we can now use
ec29d80
to
c364d06
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## mk/non_monomial_basis #31 +/- ##
=========================================================
- Coverage 94.29% 93.65% -0.65%
=========================================================
Files 14 14
Lines 631 630 -1
=========================================================
- Hits 595 590 -5
- Misses 36 40 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
For Ubuntu k1 = 28154117
k2 = 18786592
FixedBasis caching && allocations: Test Failed at /home/runner/work/StarAlgebras.jl/StarAlgebras.jl/test/caching_allocations.jl:56
Expression: k2 / k1 < 0.5
Evaluated: 0.6672769030547113 < 0.5 For Mac OS k1 = 28128821
k2 = 18786592
FixedBasis caching && allocations: Test Failed at /Users/runner/work/StarAlgebras.jl/StarAlgebras.jl/test/caching_allocations.jl:56
Expression: k2 / k1 < 0.5
Evaluated: 0.6678769792733226 < 0.5 For Windows k1 = 28154181
k2 = 18786592
FixedBasis caching && allocations: Test Failed at D:\a\StarAlgebras.jl\StarAlgebras.jl\test\caching_allocations.jl:56
Expression: k2 / k1 < 0.5
Evaluated: 0.6672753862028521 < 0.5 Let's use |
@blegat then it's a regression. On my branch I have
compare how much does canonicalization now allocate? |
We might need to force specializations on move functions like I did in 8f3fb92 |
* remove CachedMTable * introduce ImplicitBasis and ExplicitBasis * rename TrivialMStructure → LazyMStructure * remove baseless StarAlgebras * AlgebraElement coefficients don't need to be vector * first try on coefficients * Fixes * rename Basis → Fixed Basis * introduce DiracBasis <: ImplicitBasis * move mul! to mstructures * fix the order {K,V} of params in AbstractCoefficients * fix printing of LazyMStructure * add keytype, valtype for AbstractCoefficients * add getindex for LazyMStructure over DiracBasis * add == for AbstractCoefficients * make DiracBasis threadsafe * give it a try with different parametrization of MStructures * Fixes * move star_of to FixedBasis * return DiracDeltas on indexing DiracBasis * dispatch star through star(basis, coeffs) * move fmac! so that StarAlgebras actually load * implement basic canonicalize * more star dispatch * simplify AlgebraElement * fix: define MA.operate!(zero, ::SparseVector) * fix show methods * fix getindex for LazyMStructure * move coefficients to their separate files * move Dirac/FixedBases to their separate files * add (Dirac|Augmented)MStructure * reimplement MTables * fix the definitions of of StarAlgebra/AlgebraElements * add a new implementation of star * reimplement augmentation * various small fixes * add fmac! for AbstractVector * remove show for DiracMStructure now that it is basis free * quickly fix one * commit tmp.jl as an example of what works * move tmp.jl to test/perm_grp_algebra.jl * turn demo perm_grp_algebra.jl into testset * disable the old test for now * move compat section for Groups etc to test/Project.toml * Let AlgebraElement be an AbstractMutable * zero!(.) -> MA.operate!(zero, .) * neg! -> operate_to!(- * add! -> operate_to!(+ * mul! -> MA.operate_to! * mul! with mstruct to MA * sub! -> MA * fmac -> MA * Check for alias * unsafe_add! -> UnsafeAddMul * Document UnsafeAddMul * Fixes for Chebyshev (#23) * Fixes for Chebyshev * Add key_type * replace keytype → key_type * rename _nzpairs → nonzero_pairs * implement canonicalization via MA.operate!!(canonical, ...) * move the mutable API to coefficients * remove Dirac and use GroupElements directly This is akin to using monomials * rename AugmentedDirac to Augmented * fix: == for SparseCoefficients * reorganize defs for star, aug and norm/dot * implement MA API for SparseCoefficients * add zero_coeffs(::Type, ::AbstractBasis) currently defaults to * SparseCoefficients (ImplicitBasis) * SparseVectir (ExplicitBasis) * fix: use nonzero_pairs instead of pairs * fix: logic for canonical(::SparseCoefficients) * add getindex/setindex! for SparseCoefficients * reshuffle definitions in types.jl (this file needs to be broken down anyway) * one/zero & isone/iszero are surprisingly hard... * various small fixes/convenience additions * fix: use getindex instead of broadcasting * [tests] implement iteration over free words * [test] rewrite testset Arithmetic in group algebra * [tests] rewrite tests with free monoid algebra * [tests] rewrite tests for chaching multiplication * [tests] update constructors and sohs in group algebra * [tests] reenable tests * fix: test LinearAlgebra.dot * fix includes * bump version to 0.3 * [tests] fix: @Allocations exist in julia ≥ 1.9 * tidy up aug, star and adjoint * allow no cache in FixedBasis * document minimal AbstractCoefficients API * de-randomize !isone test * add default cache parameter (UInt32(0)) for FixedBasis * fix: compute hash on canonicalized coeffs * add Comparable to pass < for sorting in sparse coeffs * caching for MTables does not work for isbits elements This is because isbits elements may not track isdefined / isassigned status. As a consequence Matrix{T}(undef, dims) is initialized to garbage. * fix: use proper (double) indexing when evaluating AlgebraElement * enable canonical for Vectors * add += with MTable for AbstractVectors * fix: MA.operate!(zero, ...) failed for SparseVector{Rational...} Most probably due to Rationals initialized from random memory * remove old/unused functions * add Base.keys(b::ExplicitBasis) * expand docstring for AbstractBasis * inlining nonzero_pairs saves lots of allocations * test aug for Augmented basis * reduce allocations by hinting size * unbreak tests with MutableArithmetics 1.4.3 * test allocations only on 1.10 the number of allocations on nightly increased due to the introduction of Memory{T} in base julia * rearrange tests * lock complete! of MTable behind a SpinLock * Unbreak broken tests * Exclude on Julia latest * Missing newline * remove Comparable * update README with working examples * fix (?) for multithreading access to MTable cache * make augmented stuff a self-contained file * don't export supp * fix nonzero_pairs for a vector * add tests for arithmetic on coeffs * add tests for using dense vector as coeffs * add test for abstract coeffs * add a bit of docs what AbstractCoefficients is * formatting * increase coverage by removing old methods * fix norm/dot and provide coverage * fix iteration on AugmentedBasis and add tests * move the generic MA.operate! from ACoeffs to the lib * one more broken test * Base._return_type -> MA.promote_operation * Fix broken all tests but one * Turn last broken test into a passable test * Add eachindex back * Assume mutability for canonical (#31) * Assume mutability for canonical * Fix allocation test * Debug for Julia v1.6 * Use 0.7 --------- Co-authored-by: Benoît Legat <benoit.legat@gmail.com>
As we discussed, since we assume the coefficients to be mutable, it's best to just call
operate!
and not go through themutability
logic.I got the allocation tests starting to fail when calling
operate!
instead ofoperate!!
which made no sense.It turned out that the Julia's heuristic for specializing the type of arguments being functions changed its mind so I had to force it to specialize.