-
Notifications
You must be signed in to change notification settings - Fork 436
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
atomic quadrature grid blocking [part 1] #2336
Conversation
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 don't know the DFT infrastructure at all, so can you give me a big picture overview of what this PR is doing? I know that DFT relies on numerical integration, and I know that a block contains numerical integration points, but I don't know what a block is used for.
I have some structural concerns with this PR, but I don't want to suggest something without knowing more about what this PR is trying to accomplish.
psi4/src/psi4/libfock/cubature.h
Outdated
@@ -399,6 +417,10 @@ class BlockOPoints { | |||
size_t index() const { return index_; } | |||
/// Print a trace of this BlockOPoints | |||
void print(std::string out_fname = "outfile", int print = 2); | |||
/// set parent atom for the current block |
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.
/// set parent atom for the current block | |
/// Set parent atom for the current block |
psi4/src/psi4/libfock/cubature.h
Outdated
@@ -399,6 +417,10 @@ class BlockOPoints { | |||
size_t index() const { return index_; } | |||
/// Print a trace of this BlockOPoints | |||
void print(std::string out_fname = "outfile", int print = 2); | |||
/// set parent atom for the current block | |||
void set_parent_atom(size_t atom) {parent_atom_ = atom;}; | |||
/// parent atom if the current block |
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.
/// parent atom if the current block | |
/// Parent atom if the current block |
psi4/src/psi4/libfock/cubature.h
Outdated
@@ -377,6 +392,9 @@ class BlockOPoints { | |||
/// Bounding radius of the BlockOPoints | |||
double R_; | |||
|
|||
/// parent atom of this BlockOPoints | |||
size_t parent_atom_; |
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.
Why are you adding this function, and the associated getters/setters? The only place this is used is for printing in your test.
Are all BlockOPoints
atom-centered?
psi4/src/psi4/libfock/cubature.cc
Outdated
checkBrian(); | ||
} | ||
} | ||
#endif | ||
|
||
npoints_ = 0; | ||
for (int i = 0; i < grid.size(); ++i) { | ||
npoints_ += grid[i].size(); | ||
for (int i = 0; i < atomic_grids_.size(); ++i) { |
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.
Replace this with a range-based for loop.
psi4/src/psi4/libfock/cubature.cc
Outdated
y_[grid_vector_index] = atomic_grids_[i][j].y; | ||
z_[grid_vector_index] = atomic_grids_[i][j].z; | ||
w_[grid_vector_index] = atomic_grids_[i][j].w; | ||
index_[i] = grid_vector_index; // TODO: It's not used and wrong->remove. |
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.
If index_
isn't used, get rid of it now and use range-based for loops.
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 stand corrected. octree
uses it for debug printing. I still think it is wrong, though, or I just don't understand it.
psi4/src/psi4/libfock/cubature.cc
Outdated
mp.w *= nuc.computeNuclearWeight(mp, A, stratmannCutoff); // This ain't gonna fly. Must abate this | ||
// mickey mouse a most rikky tikki tavi. |
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.
While I'm glad that Rob Parrish had fun, I have no clue what he's talking about. Remove this comment.
mp.w *= nuc.computeNuclearWeight(mp, A, stratmannCutoff); // This ain't gonna fly. Must abate this | |
// mickey mouse a most rikky tikki tavi. | |
mp.w *= nuc.computeNuclearWeight(mp, A, stratmannCutoff); |
psi4/src/psi4/libfock/cubature.cc
Outdated
@@ -3836,7 +3841,9 @@ void MolecularGrid::buildGridFromOptions(MolecularGridOptions const &opt) { | |||
mp.w *= nuc.computeNuclearWeight( | |||
mp, A, | |||
stratmannCutoff); // This ain't gonna fly. Must abate this mickey mouse a most rikky tikki tavi. |
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.
stratmannCutoff); // This ain't gonna fly. Must abate this mickey mouse a most rikky tikki tavi. | |
stratmannCutoff); |
psi4/src/psi4/libfock/cubature.cc
Outdated
postProcess(extents, max_points, min_points, max_radius); | ||
} | ||
|
||
// REFACTOR NOTE: PS grids are not used. Incomplete use of MolecularGridOptions. |
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 do not understand the second sentence.
Instead of making a loop over all grid points that calculates basis function values and XC contributions one by one , the points are grouped together into blocks for efficiency reasons. This feature is needed for algorithms or methods that look at contributions from atoms when looping over the grid points. Right now, those new things are not needed, and thus not used anywhere, but they will be used for COSX and ddCOSMO. So you might want to access for a given atom all blocks of grid points, where a block has only grid points from that atom. This is what This is part 1 to get it the basics out faster and allow COSX and ddCOSMO development to continue. cubature.cc still needs a big cleanup, but that has to wait. |
It's also needed for generalized Pipek-Mezey, which is a better localization method than what is currently implemented in Psi4. |
The other point I missed the first time was when you said For future, it's clearer to put the unambiguous statement of the primary feature before technical notes (like on |
psi4/src/psi4/libfock/cubature.cc
Outdated
opt.bench = full_int_options["BENCH"]; | ||
|
||
// Until the subroutine is fixed we need to disable the screening for atomic blocking | ||
// Otherwise there is little reason to distable it. |
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.
// Otherwise there is little reason to distable it. |
The comment above is clear enough that we can re-enable it when some bug is fixed.
psi4/src/psi4/libfock/cubature.cc
Outdated
"PRINT", | ||
"DEBUG", | ||
"BENCH", | ||
"DFT_REMOVE_DISTANT_POINTS"}; |
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.
debug
, bench
, and dft_remove_distant_points
should be bool rather than int. The first two were existing keywords, so I can agree to not convert those until a future PR. But dft_remove_distant_points
should be made a bool now.
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'll make DFT_REMOVE_DISTANT_POINTS
a global options for now. Eventually all grid options should become build-specific. For this one would need to add double and bool std::maps
to the grid constructor. A more universal option would be better. I added a note in the code:
// below segfaults, cannot use grids_ directly. | ||
// auto bop =std::make_shared<BlockOPoints>(block_index, n, &grids_[i][grid_index].x, | ||
// &grids_[i][grid_index].y, &grids_[i][grid_index].z, &grids_[i][grid_index].w, extents_); | ||
if (bop->local_nbf()) { |
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.
What would it even mean for this to be zero?
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 took this from the octree
code. I think there is a chance that no significant basis functions remain after screening within the BlockOPoints
.
psi4/src/psi4/libfock/gridblocker.h
Outdated
@@ -55,6 +56,8 @@ class GridBlocker { | |||
double const* z_ref_; | |||
double const* w_ref_; | |||
int const* index_ref_; | |||
std::vector<std::vector<MassPoint>> grids_; |
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.
Members that are only needed by one subclass should only be defined for that subclass.
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 seem to need it in the base class for this blocker->set_atomic_grids(atomic_grids_);
here because blocker
is not actually the subclass object. (as far as I understand the compiler)
f24757a
to
bfea8b4
Compare
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.
This looks much better. I have a few comments before I can approve this. 👍 for getting rid of index_
and index_ref_
.
…r distant point removal
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.
As somebody new to the DFT code, LGTM. Thanks for the PR! It looks like this will enable some useful things.
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.
This looks good!
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.
LGTM. 👍 for the tests!
Description
This PR introduces an atomic blocking scheme for quadrature grid points. All grid points in a
BlockOPoints
object belong to a singular parent atom.Part 1 contains just the basic feature to get it our for people depending on it. Optimization for speed is yet to come.
New options:
DFT_BLOCK_SCHEME = ATOMIC
(unique blocks of grid points for each atom)DFT_REMOVE_DISTANT_POINTS
(new flag for existing functionality)primary C++ feature:
grid->atomic_blocks()[N_ATOM][N_BLOCKS]
additionally togrid->blocks()[N_BLOCKS]
# provides all grid points for an atomblock->parent_atom()
# atom the current block belongs to.fixes
index
vectornote
clang-format
made unrelated changes.Questions
BlockOPoints
object. I'd like advice how to handle this better.Checklist
Status
Usage
Normal loop structure
Looping over atoms and their blocks.