Skip to content

Comments

Optimization for PETSc preallocation#345

Merged
mohd-afeef-badri merged 13 commits intoarcaneframework:mainfrom
jojoasticot:dev/opti-preallocation
Jan 6, 2026
Merged

Optimization for PETSc preallocation#345
mohd-afeef-badri merged 13 commits intoarcaneframework:mainfrom
jojoasticot:dev/opti-preallocation

Conversation

@jojoasticot
Copy link
Contributor

Preallocate the matrix shape (nnz) only one time.
At each call to solve, the matrix will be filled with new values but the same shape.
At the destruction of the PETScDoFLinearSystemImpl object, all PETSc object will be freed. This include the matrix, the KSP solver and the Local2Global map indices.

Vectors are still allocated and freed at each call to solve.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 79.71014% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.48%. Comparing base (7c0e7c7) to head (8072890).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
femutils/DoFLinearSystem.cc 44.44% 10 Missing ⚠️
femutils/PETScDoFLinearSystem.cc 95.12% 1 Missing and 1 partial ⚠️
femutils/internal/DoFLinearSystemImplBase.h 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #345      +/-   ##
==========================================
+ Coverage   69.44%   69.48%   +0.04%     
==========================================
  Files         118      118              
  Lines       14614    14695      +81     
  Branches     1975     1983       +8     
==========================================
+ Hits        10148    10211      +63     
- Misses       4011     4028      +17     
- Partials      455      456       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jojoasticot jojoasticot marked this pull request as ready for review December 23, 2025 15:20
// noop
}

bool isMatrixSparsityConstant() const override
Copy link
Collaborator

Choose a reason for hiding this comment

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

check my comments above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is called in the [testlab]direct-solver test. I put a noop because the SequentialDoFLinearSystemImpl class does not have the constant sparsity and values attributes.

Comment on lines 2058 to 2060
Real end = platform::getRealTime();

info() << "TIME TAKEN: " << end - start;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

ITimeStats* tstat = m_time_stats;
Timer::Action timer_action(tstat, "Solving");

Real start = platform::getRealTime();
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Comment on lines 336 to 340
void setConstantMatrixSparsity(bool val);
void setConstantMatrixValues(bool val);
bool isMatrixSparsityConstant();
bool isMatrixValuesConstant();

Copy link
Member

Choose a reason for hiding this comment

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

Please add documentation for these methods.

@mohd-afeef-badri mohd-afeef-badri merged commit 462cbb8 into arcaneframework:main Jan 6, 2026
7 checks passed
@mohd-afeef-badri mohd-afeef-badri added the enhancement New feature or request label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants