Skip to content
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

Specialize createSPOSetBuilder #29

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
33f675d
Implement SPOSetT template class
williamfgc Jul 24, 2023
8c0fdfe
Mark todo for purely virtual functions
williamfgc Jul 24, 2023
bcb3953
Add FakeSPOT class
quantumsteve Aug 4, 2023
9938da5
Revert test_RotatedSPOs.cpp
williamfgc Aug 18, 2023
e7a8e37
Reorder specialized function definitions to appease OMP target compil…
PhilipFackler Aug 18, 2023
9d74169
Add ConstantSPOSetT
williamfgc Aug 18, 2023
2e8d5b4
Refactor BsplineSet and SplineC2C
williamfgc Aug 22, 2023
b1b6bf2
PWOribitalSetT and PWBasisT
PhilipFackler Aug 16, 2023
63b4a3b
Add templated class LCAOrbitalSetT
quantumsteve Aug 17, 2023
94c5994
Add templated class LCAOrbitalSetWithCorrectionT
quantumsteve Aug 24, 2023
507c141
Fix LCAOrbitalSetWithCorrectionT. Add SPOSetBuilderT and SoaCuspCorre…
quantumsteve Aug 24, 2023
bd500bf
Add SHOSetBuilderT
quantumsteve Aug 24, 2023
eb6bb73
Fix PWOrbitalSet alias types
williamfgc Aug 25, 2023
0f2c097
Implement CompositeSPOSetT class
PhilipFackler Aug 4, 2023
5421350
Specialize functions in RotatedSPOsT
williamfgc Aug 28, 2023
0eef653
Change order of definition
williamfgc Aug 30, 2023
47bc03b
Implement SPOSetBuilderFactoryT and most required builders
PhilipFackler Aug 25, 2023
f78c3b0
Add missing implementation to SPOSetBuilderT
quantumsteve Aug 30, 2023
c03543c
Fix failing complex build
quantumsteve Aug 30, 2023
944f95b
Add CI to WIP refactoring branch
williamfgc Sep 6, 2023
ddda09d
Specialize createSPOSetBuilder
williamfgc Sep 6, 2023
2369dde
Specialize SPOSetScannerT functions
williamfgc Sep 6, 2023
0b31daa
Remove QMC_COMPLEX from include
williamfgc Sep 6, 2023
628caf2
Specialize createSPOSetFromXML
williamfgc Sep 6, 2023
cdac7d7
Add missing header
williamfgc Sep 6, 2023
7dc911a
Add Soa template classes and types
williamfgc Sep 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
branches:
- develop
- main
- ref-add-SPOSetT
pull_request:
branches:
- develop
- main
- ref-add-SPOSetT

jobs:
linux:
Expand Down
1 change: 1 addition & 0 deletions src/Numerics/GaussianBasisSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct GaussianCombo
// but maybe it can be different precision
// Possibly one of these types is the full precision and the other reduced precision
using real_type = T;
using ValueType = real_type;
real_type Y, dY, d2Y, d3Y;

struct BasicGaussian
Expand Down
1 change: 1 addition & 0 deletions src/Numerics/SlaterBasisSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct SlaterCombo
{
static_assert(std::is_floating_point<T>::value, "T must be a float point type");
using real_type = T;
using ValueType = real_type;
using Component_t = GenericSTO<T>;

int L;
Expand Down
5 changes: 2 additions & 3 deletions src/QMCWaveFunctions/BasisSetBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ struct SoaBasisSetBase
using vgl_type = VectorSoaContainer<T, OHMMS_DIM + 2>;
using vgh_type = VectorSoaContainer<T, 10>;
using vghgh_type = VectorSoaContainer<T, 20>;
using ValueType = QMCTraits::ValueType;
using OffloadMWVGLArray = Array<ValueType, 3, OffloadPinnedAllocator<ValueType>>; // [VGL, walker, Orbs]
using OffloadMWVArray = Array<ValueType, 2, OffloadPinnedAllocator<ValueType>>; // [walker, Orbs]
using OffloadMWVGLArray = Array<T, 3, OffloadPinnedAllocator<T>>; // [VGL, walker, Orbs]
using OffloadMWVArray = Array<T, 2, OffloadPinnedAllocator<T>>; // [walker, Orbs]

///size of the basis set
int BasisSetSize;
Expand Down
249 changes: 249 additions & 0 deletions src/QMCWaveFunctions/BsplineFactory/BsplineSetT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
//////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2019 QMCPACK developers.
//
// File developed by: Jeremy McMinnis, [email protected], University of Illinois at Urbana-Champaign
// Jaron T. Krogel, [email protected], Oak Ridge National Laboratory
// Jeongnim Kim, [email protected], University of Illinois at Urbana-Champaign
// Mark A. Berrill, [email protected], Oak Ridge National Laboratory
// Ye Luo, [email protected], Argonne National Laboratory
//
// File created by: Jeongnim Kim, [email protected], University of Illinois at Urbana-Champaign
//////////////////////////////////////////////////////////////////////////////////////


/** @file BsplineSetT.h
*
* BsplineSet is a SPOSet derived class and serves as a base class for B-spline SPO C2C/C2R/R2R implementation
*/
#ifndef QMCPLUSPLUS_BSPLINESETT_H
#define QMCPLUSPLUS_BSPLINESETT_H

#include "QMCWaveFunctions/SPOSetT.h"
#include "spline/einspline_engine.hpp"
#include "spline/einspline_util.hpp"

namespace qmcplusplus
{
/** BsplineSet is the base class for SplineC2C, SplineC2R, SplineR2R.
* Its derived template classes manage the storage and evaluation at given precision.
* BsplineSet also implements a few fallback routines in case optimized implementation is not necessary in the derived class.
*/
template<class T>
class BsplineSetT : public SPOSetT<T>
{
public:
using PosType = typename SPOSetT<T>::PosType;
using ValueVector = typename SPOSetT<T>::ValueVector;
using GradVector = typename SPOSetT<T>::GradVector;
using HessVector = typename SPOSetT<T>::HessVector;
using GGGVector = typename SPOSetT<T>::GGGVector;
using ValueMatrix = typename SPOSetT<T>::ValueMatrix;
using GradMatrix = typename SPOSetT<T>::GradMatrix;
using HessMatrix = typename SPOSetT<T>::HessMatrix;
using GGGMatrix = typename SPOSetT<T>::GGGMatrix;

using value_type = typename SPOSetT<T>::ValueMatrix::value_type;
using grad_type = typename SPOSetT<T>::GradMatrix::value_type;

// used in derived classes
using RealType = typename SPOSetT<T>::RealType;
using ValueType = typename SPOSetT<T>::ValueType;

BsplineSetT(const std::string& my_name) : SPOSetT<T>(my_name), MyIndex(0), first_spo(0), last_spo(0) {}

virtual bool isComplex() const = 0;
virtual std::string getKeyword() const = 0;

auto& getHalfG() const { return HalfG; }

inline void init_base(int n)
{
kPoints.resize(n);
MakeTwoCopies.resize(n);
BandIndexMap.resize(n);
for (int i = 0; i < n; i++)
BandIndexMap[i] = i;
}

///remap kpoints to group general kpoints & special kpoints
int remap_kpoints()
{
std::vector<PosType> k_copy(kPoints);
const int nk = kPoints.size();
int nCB = 0;
//two pass
for (int i = 0; i < nk; ++i)
{
if (MakeTwoCopies[i])
{
kPoints[nCB] = k_copy[i];
BandIndexMap[nCB++] = i;
}
}
int nRealBands = nCB;
for (int i = 0; i < nk; ++i)
{
if (!MakeTwoCopies[i])
{
kPoints[nRealBands] = k_copy[i];
BandIndexMap[nRealBands++] = i;
}
}
return nCB; //return the number of complex bands
}

std::unique_ptr<SPOSetT<T>> makeClone() const override = 0;

void setOrbitalSetSize(int norbs) override { this->OrbitalSetSize = norbs; }

void evaluate_notranspose(const ParticleSet& P,
int first,
int last,
ValueMatrix& logdet,
GradMatrix& dlogdet,
ValueMatrix& d2logdet) override
{
for (int iat = first, i = 0; iat < last; ++iat, ++i)
{
ValueVector v(logdet[i], logdet.cols());
GradVector g(dlogdet[i], dlogdet.cols());
ValueVector l(d2logdet[i], d2logdet.cols());
this->evaluateVGL(P, iat, v, g, l);
}
}

void mw_evaluate_notranspose(const RefVectorWithLeader<SPOSetT<T>>& spo_list,
const RefVectorWithLeader<ParticleSet>& P_list,
int first,
int last,
const RefVector<ValueMatrix>& logdet_list,
const RefVector<GradMatrix>& dlogdet_list,
const RefVector<ValueMatrix>& d2logdet_list) const override
{
assert(this == &spo_list.getLeader());
const size_t nw = spo_list.size();
std::vector<ValueVector> mw_psi_v;
std::vector<GradVector> mw_dpsi_v;
std::vector<ValueVector> mw_d2psi_v;
RefVector<ValueVector> psi_v_list;
RefVector<GradVector> dpsi_v_list;
RefVector<ValueVector> d2psi_v_list;
mw_psi_v.reserve(nw);
mw_dpsi_v.reserve(nw);
mw_d2psi_v.reserve(nw);
psi_v_list.reserve(nw);
dpsi_v_list.reserve(nw);
d2psi_v_list.reserve(nw);

for (int iat = first, i = 0; iat < last; ++iat, ++i)
{
mw_psi_v.clear();
mw_dpsi_v.clear();
mw_d2psi_v.clear();
psi_v_list.clear();
dpsi_v_list.clear();
d2psi_v_list.clear();

for (int iw = 0; iw < nw; iw++)
{
mw_psi_v.emplace_back(logdet_list[iw].get()[i], logdet_list[iw].get().cols());
mw_dpsi_v.emplace_back(dlogdet_list[iw].get()[i], dlogdet_list[iw].get().cols());
mw_d2psi_v.emplace_back(d2logdet_list[iw].get()[i], d2logdet_list[iw].get().cols());
psi_v_list.push_back(mw_psi_v.back());
dpsi_v_list.push_back(mw_dpsi_v.back());
d2psi_v_list.push_back(mw_d2psi_v.back());
}

this->mw_evaluateVGL(spo_list, P_list, iat, psi_v_list, dpsi_v_list, d2psi_v_list);
}
}

void evaluate_notranspose(const ParticleSet& P,
int first,
int last,
ValueMatrix& logdet,
GradMatrix& dlogdet,
HessMatrix& grad_grad_logdet) override
{
for (int iat = first, i = 0; iat < last; ++iat, ++i)
{
ValueVector v(logdet[i], logdet.cols());
GradVector g(dlogdet[i], dlogdet.cols());
HessVector h(grad_grad_logdet[i], grad_grad_logdet.cols());
this->evaluateVGH(P, iat, v, g, h);
}
}

void evaluate_notranspose(const ParticleSet& P,
int first,
int last,
ValueMatrix& logdet,
GradMatrix& dlogdet,
HessMatrix& grad_grad_logdet,
GGGMatrix& grad_grad_grad_logdet) override
{
for (int iat = first, i = 0; iat < last; ++iat, ++i)
{
ValueVector v(logdet[i], logdet.cols());
GradVector g(dlogdet[i], dlogdet.cols());
HessVector h(grad_grad_logdet[i], grad_grad_logdet.cols());
GGGVector gh(grad_grad_grad_logdet[i], grad_grad_grad_logdet.cols());
this->evaluateVGHGH(P, iat, v, g, h, gh);
}
}

void evaluateGradSource(const ParticleSet& P,
int first,
int last,
const ParticleSet& source,
int iat_src,
GradMatrix& gradphi) override
{
//Do nothing, since Einsplines don't explicitly depend on ion positions.
}

void evaluateGradSource(const ParticleSet& P,
int first,
int last,
const ParticleSet& source,
int iat_src,
GradMatrix& grad_phi,
HessMatrix& grad_grad_phi,
GradMatrix& grad_lapl_phi) override
{
//Do nothing, since Einsplines don't explicitly depend on ion positions.
}

template<class BSPLINESPO>
friend struct SplineSetReader;
friend struct BsplineReaderBase;


protected:
static const int D = QMCTraits::DIM;
///Index of this adoptor, when multiple adoptors are used for NUMA or distributed cases
size_t MyIndex;
///first index of the SPOs this Spline handles
size_t first_spo;
///last index of the SPOs this Spline handles
size_t last_spo;
///sign bits at the G/2 boundaries
TinyVector<int, D> HalfG;
///flags to unpack sin/cos
std::vector<bool> MakeTwoCopies;
/** kpoints for each unique orbitals.
* Note: for historic reason, this sign is opposite to what was used in DFT when orbitals were generated.
* Changing the sign requires updating all the evaluation code.
*/
std::vector<PosType> kPoints;
///remap splines to orbitals
aligned_vector<int> BandIndexMap;
///band offsets used for communication
std::vector<int> offset;
};

} // namespace qmcplusplus
#endif
Loading