-
Notifications
You must be signed in to change notification settings - Fork 434
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
Move incore/OOC decision logic for DPD sorting into a separate function #2717
base: master
Are you sure you want to change the base?
Conversation
Can you elaborate on what you mean by "the main scope of the function is quite polluted"? |
Certainly. Polluted might have been too harsh, cluttered may be a more appropriate word for it. All variables are currently declared at the beginning of the function. Depending on the type of sort requested, some of them may never be initialized/used, but because they are declared at the top they are always visible and mutable inside the switch cases, loops, etc. This makes debugging more challenging than it has to be, as it is not possible to tell at a glance which of the variables with suspicious (negative or power-of-two) values are just uninitialized, as seen in the stack trace in #2261 (comment) In general variables should enter scope when they are needed and go out of scope when they are no longer required, and be |
All fair criticisms, and that clears it up. The code was originally pure C and later modified to fit (nominally) within a C++ framework, hence the structure of the variable declarations. |
f4e109c
to
9ae437b
Compare
9ae437b
to
964f9ce
Compare
964f9ce
to
42970ed
Compare
42970ed
to
0f466dd
Compare
0f466dd
to
cd8b798
Compare
cd8b798
to
ec9ff3f
Compare
Description
DPD::buf4_sort(...)
has some problems, the main scope of the function is quitepollutedcluttered and it is a behemoth of a function.This PR attempts to improve that by moving the incore/out-of-core decision logic into a separate function and file.
DPD::buf4_sort_axpy(...)
had the same code duplicated.The new function uses
const
wherever possible, its integers are nowint64_t
(with the exception of irrep numbers - having >2 billion irreps seems unlikely) and theincore
variable is now abool
.Todos
DPD::buf4_sort(...)
andDPD::buf4_sort_axpy(...)
are slightly easier to read and debugDPD::buf4_sort(...)
andDPD::buf4_sort_axpy(...)
is reducedint
overflow risk viaint64_t
Checklist
Status