Skip to content
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

Generalize CSC assembler #916

Merged
merged 6 commits into from
Sep 19, 2024
Merged

Generalize CSC assembler #916

merged 6 commits into from
Sep 19, 2024

Conversation

termi-official
Copy link
Member

@termi-official termi-official commented May 16, 2024

These changes should be sufficient to allow assembly into CSC matrix types other than SparseMatrixCSC and the Symmtric counterpart.

Also a step towards shaping the interface for #628 , since resize is not allowed on the GPU.

TODOs

  • Fix CI
  • Interface considerations

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 92.68293% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.63%. Comparing base (f848659) to head (b272ca3).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/assembler.jl 92.68% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #916      +/-   ##
==========================================
- Coverage   93.65%   93.63%   -0.03%     
==========================================
  Files          39       39              
  Lines        6003     6013      +10     
==========================================
+ Hits         5622     5630       +8     
- Misses        381      383       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@termi-official termi-official added needs changelog awaiting review PR is finished from the authors POV, waiting for feedback labels May 16, 2024
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
@KnutAM KnutAM added this to the v1.0.0 milestone May 19, 2024
@termi-official termi-official marked this pull request as draft May 22, 2024 09:13
@termi-official termi-official removed the awaiting review PR is finished from the authors POV, waiting for feedback label May 22, 2024
@termi-official termi-official marked this pull request as ready for review May 30, 2024 16:31
@termi-official termi-official added the awaiting review PR is finished from the authors POV, waiting for feedback label May 30, 2024
@termi-official termi-official requested a review from KnutAM May 30, 2024 16:33
Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is shaping up nicely. Some suggestions / discussion points which would be good to decide on before releasing 1.0.

The add to docs/devdocs comments can of course wait until the other details are finalized, just added it as reminders.

src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Show resolved Hide resolved
src/assembler.jl Show resolved Hide resolved
@termi-official
Copy link
Member Author

Thanks for the review Knut!

I would like to suggest that the removal of the symmetric API should go into a separate PR.

Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I like the name-changes, but perhaps there should be a @deprecate_binding or something @fredrikekre ?
I just think we are at a point now that we need to reduce annoyance to users where possible during the upgrade.

src/assembler.jl Outdated Show resolved Hide resolved
src/assembler.jl Outdated Show resolved Hide resolved
@termi-official
Copy link
Member Author

This should be ready again.

Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments when looking back on this. But still overall a good generalization IMO.

@@ -73,15 +73,15 @@ end;
#
# ScratchValues is a thread-local collection of data that each thread needs to own,
# since we need to be able to mutate the data in the threads independently
struct ScratchValues{T, CV <: CellValues, FV <: FacetValues, TT <: AbstractTensor, dim, Ti}
struct ScratchValues{T, CV <: CellValues, FV <: FacetValues, TT <: AbstractTensor, dim, AT <: Ferrite.AbstractSparseAssembler}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest not "documenting" the abstract type for now, since there is no clear interface.

Suggested change
struct ScratchValues{T, CV <: CellValues, FV <: FacetValues, TT <: AbstractTensor, dim, AT <: Ferrite.AbstractSparseAssembler}
struct ScratchValues{T, CV <: CellValues, FV <: FacetValues, TT <: AbstractTensor, dim, AT}

src/assembler.jl Outdated
end

finish_assemble(a::AbstractSparseCSCAssembler) = get_matrix(a)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Not covered by tests and I think this shouldn't be encouranged since it doesn't "do" anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need this interface for making virtually any assembly format efficient that is not vanilla CSR or CSC. E.g. EA or ParCSR, which need a synchronization phase after all data is there (instead of syncing potentially each element individually).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear what this should return if you have a matrix + a vector to assemble for example?

I would find a two step version more logical, I.e. finish_assemble!(a); K = get_matrix(a). (Not sure what the finish function should be called). Perhaps materialize! (or close!)

src/assembler.jl Show resolved Hide resolved
@@ -33,24 +40,28 @@ as described in the [manual](@ref man-assembly).
the same pattern. See the [manual section](@ref man-assembly) on assembly.
"""
function start_assemble(N::Int=0)
return Assembler(N)
return start_assemble(Float64, N)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return start_assemble(Float64, N)
return COOAssembler(N)

@fredrikekre fredrikekre force-pushed the do/more-generic-csc-assembler branch from 1e0e05c to 2b22a3e Compare September 19, 2024 13:00
@fredrikekre fredrikekre merged commit ee9d61c into master Sep 19, 2024
10 of 11 checks passed
@fredrikekre fredrikekre deleted the do/more-generic-csc-assembler branch September 19, 2024 13:26
KnutAM added a commit to KnutAM/FerriteAssembly.jl that referenced this pull request Sep 22, 2024
* Generalize to use Abstract[Cell/Facet]Values in codebase
* Apply renaming following Ferrite-FEM/Ferrite.jl#916
* Change default states to Vector{Nothing} instead of Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review PR is finished from the authors POV, waiting for feedback needs changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants