Refactor: convert ia-it nested loops to iat flat loops with OpenMP in ESolver_DP#7394
Open
chengleizheng wants to merge 2 commits into
Open
Refactor: convert ia-it nested loops to iat flat loops with OpenMP in ESolver_DP#7394chengleizheng wants to merge 2 commits into
chengleizheng wants to merge 2 commits into
Conversation
…t2ia lookup arrays and added #pragma omp parallel for guarded by #ifdef _OPENMP in runner() coord building, runner() force assignment, and type_map() atype assignment.
Collaborator
|
Nice try, you can do more, and put your test and analysis here. |
mohanchen
reviewed
May 30, 2026
| #ifdef _OPENMP | ||
| #pragma omp parallel for | ||
| #endif | ||
| for (int iat = 0; iat < ucell.nat; ++iat) |
Collaborator
There was a problem hiding this comment.
I recommend default(none) because it requires explicit variable scoping and avoids hidden parallel errors.
Author
There was a problem hiding this comment.
Thanks for the recommendation!😊
Author
二、代码修改详情修改总览
2.1
|
| 指标 | 优化前 | 优化后 | 变化 |
|---|---|---|---|
| 总时间 | 10.23 s | 6.28 s | -38.6% |
| Run_MD md_line | 9.14 s | 5.71 s | -37.5% |
| ESolver_DP runner | 2.60 s | 2.55 s | -1.9% |
| runner 单步平均 | 0.260 s | 0.255 s | -1.9% |
分析:
ESolver_DP::runner自身的耗时小幅下降(2.60s → 2.55s),因为坐标构建和力赋值的循环在 864 原子规模下本身开销有限- 总时间大幅缩短(10.23s → 6.28s)的主要原因:启用 OpenMP 后 MKL/BLAS 等数学库自动受益于多线程。
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced ia-it nested loops with flat iat loops using ucell.iat2it/iat2ia lookup arrays and added #pragma omp parallel for guarded by #ifdef _OPENMP in runner() coord building, runner() force assignment, and type_map() atype assignment.