-
Notifications
You must be signed in to change notification settings - Fork 139
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
Initial LCAO vgl batched implementation using GEMM #4407
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7aa3e32
addining initial lcao mw function from spo
amandadumi 2d53994
comment framework, build vgl temp matrix
amandadumi 04b0615
Add blas call and block diagonal MO coeffs
shivupa 1fb2dc9
adding vglanddetratiosgrads function and notes
amandadumi b6078dd
Add impl2 and move transpose of data there
shivupa 069bdb1
Format and delete comments
shivupa 8cd6b4c
cleaning functions of extra comments and declarations
amandadumi a2e10c3
Adding mw_evaluateVGL to SoaLocalizedBasis
shivupa 9439898
resolving compilation errors
amandadumi 1fa8711
rough gemm information
amandadumi e5a8413
Fix compilation
shivupa 3ec7f15
test mw start
amandadumi 523c670
lcao_vgl_mw from Amanda
kgasperich 9fca749
resized some vectors and added a few reference values
kgasperich a0e58cf
added second walker to test
kgasperich e5b485b
added larger test and fixed gemm call
kgasperich 1a51180
fixed array size (AO/MO problem)
kgasperich 2737c07
fixed grad copy
kgasperich 5ea35e7
minor cleaning
kgasperich d25acfb
renaming
kgasperich 0e0fa6b
clang-format
kgasperich 32758f7
add GTO test
kgasperich bebebcf
Merge pull request #13 from kgasperich/lcao_vgl_offload_3
amandadumi ddb042f
comment removal and impl2 -> mw_impl function rename
amandadumi 2b170bf
Merge branch 'develop' into lcao_vgl_offload
ye-luo 838af8d
Remove temp_vgl
ye-luo 602599f
Simplify LCAOrbitalSet::mw_evaluateVGLImplGEMM
ye-luo e35086d
Replace xmlChar with castCharToXMLChar
ye-luo c4b54d6
Remove typedef MWVGLArray in SPOSet.
ye-luo c43f8f3
Flip if case and reduce lines.
ye-luo 7f96fa1
Merge branch 'develop' into lcao_vgl_offload
prckent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,6 +346,67 @@ void LCAOrbitalSet::evaluateVGL(const ParticleSet& P, int iat, ValueVector& psi, | |
} | ||
} | ||
|
||
void LCAOrbitalSet::mw_evaluateVGL(const RefVectorWithLeader<SPOSet>& spo_list, | ||
const RefVectorWithLeader<ParticleSet>& P_list, | ||
int iat, | ||
const RefVector<ValueVector>& psi_v_list, | ||
const RefVector<GradVector>& dpsi_v_list, | ||
const RefVector<ValueVector>& d2psi_v_list) const | ||
{ | ||
OffloadMWVGLArray phi_vgl_v; | ||
phi_vgl_v.resize(DIM_VGL, spo_list.size(), OrbitalSetSize); | ||
mw_evaluateVGLImplGEMM(spo_list, P_list, iat, phi_vgl_v); | ||
|
||
const size_t output_size = phi_vgl_v.size(2); | ||
const size_t nw = phi_vgl_v.size(1); | ||
|
||
//TODO: make this cleaner? | ||
for (int iw = 0; iw < nw; iw++) | ||
{ | ||
std::copy_n(phi_vgl_v.data_at(0, iw, 0), output_size, psi_v_list[iw].get().data()); | ||
std::copy_n(phi_vgl_v.data_at(4, iw, 0), output_size, d2psi_v_list[iw].get().data()); | ||
// grads are [dim, walker, orb] in phi_vgl_v | ||
// [walker][orb, dim] in dpsi_v_list | ||
for (size_t idim = 0; idim < DIM; idim++) | ||
BLAS::copy(output_size, phi_vgl_v.data_at(idim + 1, iw, 0), 1, &dpsi_v_list[iw].get().data()[0][idim], DIM); | ||
} | ||
} | ||
|
||
void LCAOrbitalSet::mw_evaluateVGLImplGEMM(const RefVectorWithLeader<SPOSet>& spo_list, | ||
const RefVectorWithLeader<ParticleSet>& P_list, | ||
int iat, | ||
OffloadMWVGLArray& phi_vgl_v) const | ||
{ | ||
// [5][NW][NumAO] | ||
OffloadMWVGLArray basis_mw; | ||
PDoakORNL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
basis_mw.resize(DIM_VGL, spo_list.size(), BasisSetSize); | ||
|
||
if (Identity) | ||
{ | ||
myBasisSet->mw_evaluateVGL(P_list, iat, basis_mw); | ||
// output_size can be smaller than BasisSetSize | ||
const size_t output_size = phi_vgl_v.size(2); | ||
const size_t nw = phi_vgl_v.size(1); | ||
|
||
for (size_t idim = 0; idim < DIM_VGL; idim++) | ||
for (int iw = 0; iw < nw; iw++) | ||
std::copy_n(basis_mw.data_at(idim, iw, 0), output_size, phi_vgl_v.data_at(idim, iw, 0)); | ||
} | ||
else | ||
{ | ||
const size_t requested_orb_size = phi_vgl_v.size(2); | ||
assert(requested_orb_size <= OrbitalSetSize); | ||
ValueMatrix C_partial_view(C->data(), requested_orb_size, BasisSetSize); | ||
myBasisSet->mw_evaluateVGL(P_list, iat, basis_mw); | ||
BLAS::gemm('T', 'N', | ||
requested_orb_size, // MOs | ||
spo_list.size() * DIM_VGL, // walkers * DIM_VGL | ||
BasisSetSize, // AOs | ||
1, C_partial_view.data(), BasisSetSize, basis_mw.data(), BasisSetSize, 0, phi_vgl_v.data(), | ||
requested_orb_size); | ||
} | ||
} | ||
|
||
void LCAOrbitalSet::evaluateDetRatios(const VirtualParticleSet& VP, | ||
ValueVector& psi, | ||
const ValueVector& psiinv, | ||
|
@@ -365,6 +426,34 @@ void LCAOrbitalSet::evaluateDetRatios(const VirtualParticleSet& VP, | |
} | ||
} | ||
|
||
void LCAOrbitalSet::mw_evaluateVGLandDetRatioGrads(const RefVectorWithLeader<SPOSet>& spo_list, | ||
const RefVectorWithLeader<ParticleSet>& P_list, | ||
int iat, | ||
const std::vector<const ValueType*>& invRow_ptr_list, | ||
OffloadMWVGLArray& phi_vgl_v, | ||
std::vector<ValueType>& ratios, | ||
std::vector<GradType>& grads) const | ||
{ | ||
assert(this == &spo_list.getLeader()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs test coverage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add once I have the shared resource set up. |
||
assert(phi_vgl_v.size(0) == DIM_VGL); | ||
assert(phi_vgl_v.size(1) == spo_list.size()); | ||
|
||
mw_evaluateVGLImplGEMM(spo_list, P_list, iat, phi_vgl_v); | ||
// Device data of phi_vgl_v must be up-to-date upon return | ||
phi_vgl_v.updateTo(); | ||
|
||
const size_t nw = spo_list.size(); | ||
const size_t norb_requested = phi_vgl_v.size(2); | ||
for (int iw = 0; iw < nw; iw++) | ||
{ | ||
ratios[iw] = simd::dot(invRow_ptr_list[iw], phi_vgl_v.data_at(0, iw, 0), norb_requested); | ||
GradType dphi; | ||
for (size_t idim = 0; idim < DIM; idim++) | ||
dphi[idim] = simd::dot(invRow_ptr_list[iw], phi_vgl_v.data_at(idim + 1, iw, 0), norb_requested) / ratios[iw]; | ||
grads[iw] = dphi; | ||
} | ||
} | ||
|
||
void LCAOrbitalSet::evaluateVGH(const ParticleSet& P, int iat, ValueVector& psi, GradVector& dpsi, HessVector& dhpsi) | ||
{ | ||
//TAKE CARE OF IDENTITY | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Type
and_type
are redundant here the naming convention is types are leading capital mixed case so:Value
implies a type already.Other types here would be properly named
Value
Vgl
,Vgh
,Vghgh
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 guess there SoaBasisSetBase::value_type being used. Need to do renaming outside this PR.