QMCPACK
DiracDeterminantBatched< PL, VT, FPVT > Class Template Reference
+ Inheritance diagram for DiracDeterminantBatched< PL, VT, FPVT >:
+ Collaboration diagram for DiracDeterminantBatched< PL, VT, FPVT >:

Classes

struct  DiracDeterminantBatchedMultiWalkerResource
 

Public Types

using UpdateEngine = typename UpdateEngineSelector< PL, VT >::Engine
 
using DetInverter = typename DetInverterSelector< PL, FPVT >::Inverter
 
using WFT = WaveFunctionTypes< VT, FPVT >
 
using Value = typename WFT::Value
 
using FullPrecValue = typename WFT::FullPrecValue
 
using PsiValue = typename WFT::PsiValue
 
using LogValue = typename WFT::LogValue
 
using Grad = typename WFT::Grad
 
using Hess = typename WFT::Hess
 
using Real = typename WFT::Real
 
using FullPrecGrad = TinyVector< FullPrecValue, DIM >
 
template<typename DT >
using DualVector = Vector< DT, OffloadPinnedAllocator< DT > >
 
template<typename DT >
using DualMatrix = Matrix< DT, OffloadPinnedAllocator< DT > >
 
template<typename DT >
using OffloadMatrix = Matrix< DT, OffloadPinnedAllocator< DT > >
 
using DualVGLVector = VectorSoaContainer< Value, DIM+2, OffloadPinnedAllocator< Value > >
 
using OffloadMWVGLArray = typename SPOSet::OffloadMWVGLArray
 
- Public Types inherited from WaveFunctionComponent
enum  {
  ORB_PBYP_RATIO, ORB_PBYP_ALL, ORB_PBYP_PARTIAL, ORB_WALKER,
  ORB_ALLWALKER
}
 enum for a update mode More...
 
using Walker_t = ParticleSet::Walker_t
 
using WFBufferType = Walker_t::WFBuffer_t
 
using BufferType = Walker_t::Buffer_t
 
using RealMatrix_t = OrbitalSetTraits< RealType >::ValueMatrix
 
using ValueVector = OrbitalSetTraits< ValueType >::ValueVector
 
using ValueMatrix = OrbitalSetTraits< ValueType >::ValueMatrix
 
using GradMatrix = OrbitalSetTraits< ValueType >::GradMatrix
 
using HessType = OrbitalSetTraits< ValueType >::HessType
 
using HessVector = OrbitalSetTraits< ValueType >::HessVector
 
using LogValue = std::complex< QTFull::RealType >
 
using PsiValue = QTFull::ValueType
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 DiracDeterminantBatched (std::unique_ptr< SPOSet > &&spos, int first, int last, int ndelay=1, DetMatInvertor matrix_inverter_kind=DetMatInvertor::ACCEL)
 constructor More...
 
 DiracDeterminantBatched (const DiracDeterminantBatched &s)=delete
 
DiracDeterminantBatchedoperator= (const DiracDeterminantBatched &s)=delete
 
std::string getClassName () const override
 return class name More...
 
void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, Vector< Value > &dlogpsi, Vector< Value > &dhpsioverpsi) override
 
void evaluateDerivativesWF (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi) override
 Compute the derivatives of the log of the wavefunction with respect to optimizable parameters. More...
 
void registerData (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
 For particle-by-particle move. More...
 
void copyFromBuffer (ParticleSet &P, WFBufferType &buf) override
 For particle-by-particle move. More...
 
PsiValue ratio (ParticleSet &P, int iat) override
 return the ratio only for the iat-th partcle move More...
 
void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const override
 
void evaluateRatios (const VirtualParticleSet &VP, std::vector< Value > &ratios) override
 compute multiple ratios for a particle move More...
 
void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< Value > &ratios) override
 
void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< Value >> &ratios) const override
 
void evaluateDerivRatios (const VirtualParticleSet &VP, const opt_variables_type &optvars, std::vector< ValueType > &ratios, Matrix< ValueType > &dratios) override
 evaluate ratios to evaluate the non-local PP More...
 
PsiValue ratioGrad (ParticleSet &P, int iat, Grad &grad_iat) override
 
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< Grad > &grad_new) const override
 
void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< Grad > &grad_new, std::vector< ComplexType > &spingrad_new) const override
 
PsiValue ratioGradWithSpin (ParticleSet &P, int iat, Grad &grad_iat, ComplexType &spingrad) override
 
Grad evalGrad (ParticleSet &P, int iat) override
 return the current gradient for the iat-th particle More...
 
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< Grad > &grad_now) const override
 
Grad evalGradWithSpin (ParticleSet &P, int iat, ComplexType &spingrad) override
 return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< Grad > &grad_now, std::vector< ComplexType > &spingrad_now) const override
 
Grad evalGradSource (ParticleSet &P, ParticleSet &source, int iat) override
 
Grad evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad) override
 Adds the gradient w.r.t. More...
 
void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false) override
 move was accepted, update the real container More...
 
void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const override
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
void completeUpdates () override
 complete any left over determinant matrix updates. More...
 
void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
void restore (int iat) override
 move was rejected. More...
 
LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
 evaluate from scratch pretty much everything for this single walker determinant More...
 
void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const override
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
void recompute (const ParticleSet &P) override
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
void mw_recompute (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override
 Does a Phi->mw_evaluate_notranspose then mw_invertPsiM over a set of elements filtered based on the recompute mask. More...
 
LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const override
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi) override
 
void createResource (ResourceCollection &collection) const override
 initialize a shared resource and hand it to a collection More...
 
void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 acquire a shared resource from a collection More...
 
void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
 return a shared resource to a collection More...
 
void registerTWFFastDerivWrapper (const ParticleSet &P, TWFFastDerivWrapper &twf) const override
 Register the component with the TWFFastDerivWrapper wrapper. More...
 
std::unique_ptr< DiracDeterminantBasemakeCopy (std::unique_ptr< SPOSet > &&spo) const override
 cloning function More...
 
void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< Value > &ratios) override
 
const auto & get_psiMinv () const
 
- Public Member Functions inherited from DiracDeterminantBase
 DiracDeterminantBase (const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
 constructor More...
 
 ~DiracDeterminantBase () override
 default destructor More...
 
 DiracDeterminantBase (const DiracDeterminantBase &s)=delete
 
DiracDeterminantBaseoperator= (const DiracDeterminantBase &s)=delete
 
SPOSetPtr getPhi () const
 
int getFirstIndex () const
 
int getLastIndex () const
 
virtual ValueMatrixgetPsiMinv ()
 
bool isFermionic () const final
 true, if this component is fermionic More...
 
bool isOptimizable () const final
 if true, this contains optimizable components More...
 
void extractOptimizableObjectRefs (UniqueOptObjRefs &opt_obj_refs) final
 extract underlying OptimizableObject references More...
 
void checkOutVariables (const opt_variables_type &active) final
 check out variational optimizable variables More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &active, int offset, Matrix< RealType > &dlogpsi, Array< GradType, 3 > &dG, Matrix< RealType > &dL)
 
std::unique_ptr< WaveFunctionComponentmakeClone (ParticleSet &tqp) const final
 make clone More...
 
PsiValue ratioGradWithSpin (ParticleSet &P, int iat, GradType &grad_iat, ComplexType &spingrad) override
 evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin. More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
virtual LogValue evaluateGL (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch)
 compute gradients and laplacian of the TWF with respect to each particle. More...
 
virtual LogValue evaluateLog (const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L)=0
 evaluate the value of the WaveFunctionComponent from scratch More...
 
virtual void mw_evaluateGL (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list, bool fromscratch) const
 evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers More...
 
virtual void mw_evaluateLog (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const
 evaluate from scratch the same type WaveFunctionComponent of multiple walkers More...
 
virtual void recompute (const ParticleSet &P)
 recompute the value of the WaveFunctionComponents which require critical accuracy. More...
 
virtual void copyFromBuffer (ParticleSet &P, WFBufferType &buf)=0
 For particle-by-particle move. More...
 
virtual void registerData (ParticleSet &P, WFBufferType &buf)=0
 For particle-by-particle move. More...
 
virtual LogValue updateBuffer (ParticleSet &P, WFBufferType &buf, bool fromscratch=false)=0
 For particle-by-particle move. More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 acquire a shared resource from a collection More...
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 return a shared resource to a collection More...
 
virtual void acceptMove (ParticleSet &P, int iat, bool safe_to_delay=false)=0
 a move for iat-th particle is accepted. More...
 
virtual void completeUpdates ()
 complete all the delayed or asynchronous operations before leaving the p-by-p move region. More...
 
virtual GradType evalGrad (ParticleSet &P, int iat)
 return the current gradient for the iat-th particle More...
 
virtual void mw_accept_rejectMove (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, const std::vector< bool > &isAccepted, bool safe_to_delay=false) const
 moves of the iat-th particle on some walkers in a batch is accepted. More...
 
virtual void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
virtual void mw_completeUpdates (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const
 complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region. More...
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
template<CoordsType CT>
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
 
virtual void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual PsiValue ratio (ParticleSet &P, int iat)=0
 evaluate the ratio of the new to old WaveFunctionComponent value More...
 
virtual PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
virtual void restore (int iat)=0
 If a move for iat-th particle is rejected, restore to the content. More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat)
 return the logarithmic gradient for the iat-th particle of the source particleset More...
 
virtual GradType evalGradSource (ParticleSet &P, ParticleSet &source, int iat, TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &grad_grad, TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &lapl_grad)
 Adds the gradient w.r.t. More...
 
virtual void evaluateHessian (ParticleSet &P, HessVector &grad_grad_psi_all)
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
virtual void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
- Public Member Functions inherited from WaveFunctionComponent
const LogValueget_log_value () const
 
 WaveFunctionComponent (const std::string &obj_name="")
 default constructor More...
 
virtual ~WaveFunctionComponent ()
 default destructor More...
 
virtual void checkSanity () const
 Validate the internal consistency of the object. More...
 
const std::string & getName () const
 return object name More...
 
PsiValue getValue () const
 assembles the full value More...
 
virtual bool isMultiDet () const
 true, if this component is multi-determinant More...
 
virtual void prepareGroup (ParticleSet &P, int ig)
 Prepare internal data for updating WFC correspond to a particle group It should be called before moving particles of a given group. More...
 
virtual void mw_prepareGroup (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int ig) const
 
template<CoordsType CT>
void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const int iat, TWFGrads< CT > &grads_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_evalGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now) const
 compute the current gradients for the iat-th particle of multiple walkers More...
 
virtual PsiValue ratioGrad (ParticleSet &P, int iat, GradType &grad_iat)
 evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient More...
 
template<CoordsType CT>
void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, TWFGrads< CT > &grad_new) const
 
virtual void mw_ratioGrad (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers More...
 
virtual void mw_calcRatio (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const
 compute the ratio of the new to old WaveFunctionComponent value of multiple walkers More...
 
virtual RealType KECorrection ()
 Return the Chiesa kinetic energy correction. More...
 
virtual void evaluateDerivatives (ParticleSet &P, const opt_variables_type &optvars, Vector< ValueType > &dlogpsi, Vector< ValueType > &dhpsioverpsi)=0
 Compute the derivatives of both the log of the wavefunction and kinetic energy with respect to optimizable parameters. More...
 
virtual void evaluateGradDerivatives (const ParticleSet::ParticleGradient &G_in, std::vector< ValueType > &dgradlogpsi)
 Calculates the derivatives of $ \nabla \textnormal{log} \psi_f $ with respect to the optimizable parameters, and the dot product of this is then performed with the passed-in G_in gradient vector. More...
 
virtual void finalizeOptimization ()
 
virtual void evaluateRatiosAlltoOne (ParticleSet &P, std::vector< ValueType > &ratios)
 evaluate the ratios of one virtual move with respect to all the particles More...
 
virtual void evaluateRatios (const VirtualParticleSet &VP, std::vector< ValueType > &ratios)
 evaluate ratios to evaluate the non-local PP More...
 
virtual void evaluateSpinorRatios (const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< ValueType > &ratios)
 Used by SOECPComponent for faster SOC evaluation. More...
 
virtual void mw_evaluateRatios (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< ValueType >> &ratios) const
 evaluate ratios to evaluate the non-local PP multiple walkers More...
 
virtual void mw_evalGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< GradType > &grad_now, std::vector< ComplexType > &spingrad_now) const
 compute the current gradients and spin gradients for the iat-th particle of multiple walkers More...
 
virtual void mw_ratioGradWithSpin (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios, std::vector< GradType > &grad_new, std::vector< ComplexType > &spingrad_new) const
 compute the ratio of the new to old WaveFunctionComponent value and the new gradient/spingradient of multiple walkers More...
 

Private Member Functions

void resize (int nel, int morb)
 reset the size: with the number of particles and number of orbtials More...
 
void computeGL (ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
 compute G and L assuming psiMinv, dpsiM, d2psiM are ready for use More...
 
void invertPsiM (const DualMatrix< Value > &psiM, DualMatrix< Value > &psiMinv)
 single invert logdetT(psiM) as a side effect this->log_value_ gets the log determinant of logdetT More...
 
void resizeScratchObjectsForIonDerivs ()
 Resize all temporary arrays required for force computation. More...
 

Static Private Member Functions

static void mw_invertPsiM (const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVector< const DualMatrix< Value >> &logdetT_list, const RefVector< DualMatrix< Value >> &a_inv_lis)
 Inverts and finds log det for a batch of matrices. More...
 

Private Attributes

DualMatrix< ValuepsiMinv_
 
DualVGLVector psiM_vgl
 fused memory for psiM, dpsiM and d2psiM. [5][norb*norb] More...
 
DualMatrix< ValuepsiM_temp
 psiM(j,i) $= \psi_j({\bf r}_i)$. More...
 
Matrix< ValuepsiM_host
 
Matrix< GraddpsiM
 dpsiM(i,j) $= \nabla_i \psi_j({\bf r}_i)$. partial memory view of psiM_vgl More...
 
Matrix< Valued2psiM
 d2psiM(i,j) $= \nabla_i^2 \psi_j({\bf r}_i)$. partial memory view of psiM_vgl More...
 
Matrix< Gradgrad_source_psiM
 Used for force computations. More...
 
Matrix< Gradgrad_lapl_source_psiM
 
Matrix< Hessgrad_grad_source_psiM
 
Matrix< Gradphi_alpha_Minv
 
Matrix< Gradgrad_phi_Minv
 
Matrix< Valuelapl_phi_Minv
 
Matrix< Hessgrad_phi_alpha_Minv
 
DualVector< ValuepsiV
 value of single-particle orbital for particle-by-particle update More...
 
Vector< ValuepsiV_host_view
 
DualVector< GraddpsiV
 
Vector< GraddpsiV_host_view
 
DualVector< Valued2psiV
 
Vector< Valued2psiV_host_view
 
DualVector< Valuedspin_psiV
 
Vector< Valuedspin_psiV_host_view
 
PsiValue curRatio
 psi(r')/psi(r) during a PbyP move More...
 
ResourceHandle< DiracDeterminantBatchedMultiWalkerResourcemw_res_handle_
 
UpdateEngine det_engine_
 Delayed update engine 1 per walker. More...
 
DiracMatrix< FullPrecValuehost_inverter_
 slow but doesn't consume device memory More...
 
ResourceHandle< DetInverteraccel_inverter_
 matrix inversion engine this a crowd scope resource and only the leader engine gets it More...
 
const int ndelay_
 maximal number of delayed updates More...
 
const DetMatInvertor matrix_inverter_kind_
 selected scheme for inversion with walker batching More...
 
NewTimerD2HTimer
 timers More...
 
NewTimerH2DTimer
 

Additional Inherited Members

- Public Attributes inherited from WaveFunctionComponent
int UpdateMode
 current update mode More...
 
opt_variables_type myVars
 list of variables this WaveFunctionComponent handles More...
 
size_t Bytes_in_WFBuffer
 Bytes in WFBuffer. More...
 
- Static Protected Member Functions inherited from DiracDeterminantBase
static bool checkG (const GradType &g)
 
- Protected Attributes inherited from DiracDeterminantBase
NewTimerUpdateTimer
 Timers. More...
 
NewTimerRatioTimer
 
NewTimerInverseTimer
 
NewTimerBufferTimer
 
NewTimerSPOVTimer
 
NewTimerSPOVGLTimer
 
const std::unique_ptr< SPOSetPhi
 a set of single-particle orbitals used to fill in the values of the matrix More...
 
const int FirstIndex
 index of the first particle with respect to the particle set More...
 
const int LastIndex
 index of the last particle with respect to the particle set More...
 
const int NumOrbitals
 number of single-particle orbitals which belong to this Dirac determinant More...
 
const int NumPtcls
 number of particles which belong to this Dirac determinant More...
 
ValueMatrix dummy_vmt
 
- Protected Attributes inherited from WaveFunctionComponent
const std::string my_name_
 Name of the object It is required to be different for objects of the same derived type like multiple J1. More...
 
LogValue log_value_
 Current $\log\phi $. More...
 

Detailed Description

template<PlatformKind PL, typename VT, typename FPVT>
class qmcplusplus::DiracDeterminantBatched< PL, VT, FPVT >

Definition at line 75 of file DiracDeterminantBatched.h.

Member Typedef Documentation

◆ DetInverter

using DetInverter = typename DetInverterSelector<PL, FPVT>::Inverter

Definition at line 79 of file DiracDeterminantBatched.h.

◆ DualMatrix

Definition at line 94 of file DiracDeterminantBatched.h.

◆ DualVector

Definition at line 92 of file DiracDeterminantBatched.h.

◆ DualVGLVector

◆ FullPrecGrad

Definition at line 88 of file DiracDeterminantBatched.h.

◆ FullPrecValue

Definition at line 82 of file DiracDeterminantBatched.h.

◆ Grad

using Grad = typename WFT::Grad

Definition at line 85 of file DiracDeterminantBatched.h.

◆ Hess

using Hess = typename WFT::Hess

Definition at line 86 of file DiracDeterminantBatched.h.

◆ LogValue

using LogValue = typename WFT::LogValue

Definition at line 84 of file DiracDeterminantBatched.h.

◆ OffloadMatrix

Definition at line 96 of file DiracDeterminantBatched.h.

◆ OffloadMWVGLArray

Definition at line 99 of file DiracDeterminantBatched.h.

◆ PsiValue

using PsiValue = typename WFT::PsiValue

Definition at line 83 of file DiracDeterminantBatched.h.

◆ Real

using Real = typename WFT::Real

Definition at line 87 of file DiracDeterminantBatched.h.

◆ UpdateEngine

using UpdateEngine = typename UpdateEngineSelector<PL, VT>::Engine

Definition at line 78 of file DiracDeterminantBatched.h.

◆ Value

using Value = typename WFT::Value

Definition at line 81 of file DiracDeterminantBatched.h.

◆ WFT

using WFT = WaveFunctionTypes<VT, FPVT>

Definition at line 80 of file DiracDeterminantBatched.h.

Constructor & Destructor Documentation

◆ DiracDeterminantBatched() [1/2]

DiracDeterminantBatched ( std::unique_ptr< SPOSet > &&  spos,
int  first,
int  last,
int  ndelay = 1,
DetMatInvertor  matrix_inverter_kind = DetMatInvertor::ACCEL 
)

constructor

Parameters
sposthe single-particle orbital set
firstindex of the first particle
lastindex of last particle
ndelaydelayed update rank
sposthe single-particle orbital set
firstindex of the first particle

Definition at line 62 of file DiracDeterminantBatched.cpp.

References RotatedSPOs::buildOptVariables(), DiracDeterminantBase::NumPtcls, DiracDeterminantBase::Phi, and DiracDeterminantBatched< PL, VT, FPVT >::resize().

67  : DiracDeterminantBase("DiracDeterminantBatched", std::move(spos), first, last),
68  det_engine_(NumOrbitals, ndelay),
69  ndelay_(ndelay),
70  matrix_inverter_kind_(matrix_inverter_kind),
71  D2HTimer(createGlobalTimer("DiracDeterminantBatched::D2H", timer_level_fine)),
72  H2DTimer(createGlobalTimer("DiracDeterminantBatched::H2D", timer_level_fine))
73 {
74  static_assert(std::is_same<SPOSet::ValueType, typename UpdateEngine::Value>::value);
76 
77 #ifndef QMC_COMPLEX
78  RotatedSPOs* rot_spo = dynamic_cast<RotatedSPOs*>(Phi.get());
79  if (rot_spo)
80  rot_spo->buildOptVariables(NumPtcls);
81 #endif
82 }
const int ndelay_
maximal number of delayed updates
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion with walker batching
UpdateEngine det_engine_
Delayed update engine 1 per walker.
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
DiracDeterminantBase(const std::string &class_name, std::unique_ptr< SPOSet > &&spos, int first, int last)
constructor
const int NumPtcls
number of particles which belong to this Dirac determinant
void resize(int nel, int morb)
reset the size: with the number of particles and number of orbtials

◆ DiracDeterminantBatched() [2/2]

DiracDeterminantBatched ( const DiracDeterminantBatched< PL, VT, FPVT > &  s)
delete

Member Function Documentation

◆ acceptMove()

void acceptMove ( ParticleSet P,
int  iat,
bool  safe_to_delay = false 
)
overridevirtual

move was accepted, update the real container

Implements WaveFunctionComponent.

Definition at line 456 of file DiracDeterminantBatched.cpp.

References qmcplusplus::convertValueToLog(), and qmcplusplus::simd::copy().

457 {
458  if (curRatio == PsiValue(0))
459  {
460  std::ostringstream msg;
461  msg << "DiracDeterminantBatched::acceptMove curRatio is " << curRatio << "! Report a bug." << std::endl;
462  throw std::runtime_error(msg.str());
463  }
464  const int WorkingIndex = iat - FirstIndex;
466  {
467  ScopedTimer local_timer(UpdateTimer);
468  psiV.updateTo();
469  det_engine_.updateRow(psiMinv_, WorkingIndex, psiV, curRatio);
471  {
472  simd::copy(dpsiM[WorkingIndex], dpsiV.data(), NumOrbitals);
473  simd::copy(d2psiM[WorkingIndex], d2psiV.data(), NumOrbitals);
474  }
475  }
476  curRatio = 1.0;
477 }
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
void copy(T1 *restrict target, const T2 *restrict source, size_t n)
copy function using memcpy
Definition: algorithm.hpp:40
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
const int FirstIndex
index of the first particle with respect to the particle set
UpdateEngine det_engine_
Delayed update engine 1 per walker.
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
PsiValue curRatio
psi(r&#39;)/psi(r) during a PbyP move
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ acquireResource()

void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

acquire a shared resource from a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1228 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedLeader(), ResourceCollection::lendResource(), DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_, and DiracDeterminantBatched< PL, VT, FPVT >::DiracDeterminantBatchedMultiWalkerResource< PL, VT, FPVT >::psiMinv_refs.

1231 {
1232  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
1233  wfc_leader.mw_res_handle_ = collection.lendResource<DiracDeterminantBatchedMultiWalkerResource>();
1234  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
1235  mw_res.psiMinv_refs.reserve(wfc_list.size());
1236 
1237  RefVectorWithLeader<SPOSet> phi_list(*wfc_leader.Phi);
1238  for (WaveFunctionComponent& wfc : wfc_list)
1239  {
1240  auto& det = static_cast<DiracDeterminantBatched<PL, VT, FPVT>&>(wfc);
1241  phi_list.push_back(*det.Phi);
1242  mw_res.psiMinv_refs.push_back(det.psiMinv_);
1243  }
1244  wfc_leader.Phi->acquireResource(collection, phi_list);
1245  wfc_leader.accel_inverter_ = collection.lendResource<DetInverter>();
1246 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
typename DetInverterSelector< PL, FPVT >::Inverter DetInverter
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ completeUpdates()

void completeUpdates ( )
overridevirtual

complete any left over determinant matrix updates.

Usually this is the end of pbyp moves for a given spin of electrons The psiM, dpsiM, d2psiM should be up-to-date on both device and host sides.

Reimplemented from WaveFunctionComponent.

Definition at line 548 of file DiracDeterminantBatched.cpp.

549 {
550  ScopedTimer update(UpdateTimer);
552  {
553  // dpsiM, d2psiM on the device needs to be aligned as host.
554  auto* psiM_vgl_ptr = psiM_vgl.data();
555  // transfer host to device, total size 4, g(3) + l(1)
556  PRAGMA_OFFLOAD("omp target update to(psiM_vgl_ptr[psiM_vgl.capacity():psiM_vgl.capacity()*4])")
557  }
558 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]

◆ computeGL()

void computeGL ( ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
) const
private

compute G and L assuming psiMinv, dpsiM, d2psiM are ready for use

Definition at line 610 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot(), and qmcplusplus::dot().

612 {
613  for (size_t i = 0, iat = FirstIndex; i < NumPtcls; ++i, ++iat)
614  {
615  Grad rv = simd::dot(psiMinv_[i], dpsiM[i], NumOrbitals);
616  Value lap = simd::dot(psiMinv_[i], d2psiM[i], NumOrbitals);
617  G[iat] += rv;
618  L[iat] += lap - dot(rv, rv);
619  }
620 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
const int FirstIndex
index of the first particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
const int NumPtcls
number of particles which belong to this Dirac determinant
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ copyFromBuffer()

void copyFromBuffer ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Copy data or attach memory from a walker buffer to the objects of this class. The log value, P.G and P.L contribution from the objects of this class are also added.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 736 of file DiracDeterminantBatched.cpp.

References PooledMemory< T_scalar, Alloc >::get().

737 {
738  ScopedTimer local_timer(BufferTimer);
739  buf.get(psiMinv_.first_address(), psiMinv_.last_address());
740  buf.get(dpsiM.first_address(), dpsiM.last_address());
741  buf.get(d2psiM.first_address(), d2psiM.last_address());
742  psiMinv_.updateTo();
743  auto* psiM_vgl_ptr = psiM_vgl.data();
744  const size_t psiM_vgl_stride = psiM_vgl.capacity();
745  // transfer host to device, total size 4, g(3) + l(1)
746  PRAGMA_OFFLOAD("omp target update to(psiM_vgl_ptr[psiM_vgl_stride:psiM_vgl_stride*4])")
747  buf.get(log_value_);
748 }
size_type capacity() const
return the physical size
pointer last_address()
Definition: OhmmsMatrix.h:209
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
pointer first_address()
Definition: OhmmsMatrix.h:204
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ createResource()

void createResource ( ResourceCollection collection) const
overridevirtual

initialize a shared resource and hand it to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1220 of file DiracDeterminantBatched.cpp.

References ResourceCollection::addResource().

1221 {
1222  collection.addResource(std::make_unique<DiracDeterminantBatchedMultiWalkerResource>());
1223  Phi->createResource(collection);
1224  collection.addResource(std::make_unique<DetInverter>());
1225 }
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ evalGrad()

DiracDeterminantBatched< PL, VT, FPVT >::Grad evalGrad ( ParticleSet P,
int  iat 
)
overridevirtual

return the current gradient for the iat-th particle

Parameters
Pquantum particle set
iatparticle index
Returns
the gradient of the iat-th particle

Reimplemented from WaveFunctionComponent.

Definition at line 178 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

180 {
181  ScopedTimer local_timer(RatioTimer);
182  const int WorkingIndex = iat - FirstIndex;
183  Grad g = simd::dot(psiMinv_[WorkingIndex], dpsiM[WorkingIndex], NumOrbitals);
184  assert(checkG(g));
185  return g;
186 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
static bool checkG(const GradType &g)
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl

◆ evalGradSource() [1/2]

DiracDeterminantBatched< PL, VT, FPVT >::Grad evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat 
)
overridevirtual
Todo:
would be great to have docs.

Note: Can result in substantial CPU memory allocation on first call. 31 * n^2 * sizeof(Value) bytes per DDB

Reimplemented from WaveFunctionComponent.

Definition at line 928 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

932 {
933  Grad g(0.0);
934  if (Phi->hasIonDerivs())
935  {
937  Phi->evaluateGradSource(P, FirstIndex, LastIndex, source, iat, grad_source_psiM);
938  // psiMinv columns have padding but grad_source_psiM ones don't
939  for (int i = 0; i < psiMinv_.rows(); i++)
941  }
942 
943  return g;
944 }
void resizeScratchObjectsForIonDerivs()
Resize all temporary arrays required for force computation.
Matrix< Grad > grad_source_psiM
Used for force computations.
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ evalGradSource() [2/2]

DiracDeterminantBatched< PL, VT, FPVT >::Grad evalGradSource ( ParticleSet P,
ParticleSet source,
int  iat,
TinyVector< ParticleSet::ParticleGradient, OHMMS_DIM > &  grad_grad,
TinyVector< ParticleSet::ParticleLaplacian, OHMMS_DIM > &  lapl_grad 
)
overridevirtual

Adds the gradient w.r.t.

the iat-th particle of the source particleset (ions) of the logarithmic gradient and laplacian w.r.t. the target paritlceset (electrons).

Parameters
Pquantum particle set (electrons)
sourceclassical particle set (ions)
iatparticle index of source (ion)
theion gradient of the elctron gradient
theion gradient of the elctron laplacian.
Returns
the log gradient of psi w.r.t. the source particle iat

Reimplemented from WaveFunctionComponent.

Definition at line 974 of file DiracDeterminantBatched.cpp.

References OHMMS_DIM.

980 {
981  Grad gradPsi(0.0);
982  if (Phi->hasIonDerivs())
983  {
985  Phi->evaluateGradSource(P, FirstIndex, LastIndex, source, iat, grad_source_psiM, grad_grad_source_psiM,
987 
988  // Compute matrices
989  phi_alpha_Minv = 0.0;
990  grad_phi_Minv = 0.0;
991  lapl_phi_Minv = 0.0;
992  grad_phi_alpha_Minv = 0.0;
993  for (int i = 0; i < NumPtcls; i++)
994  for (int j = 0; j < NumOrbitals; j++)
995  {
996  lapl_phi_Minv(i, j) = 0.0;
997  for (int k = 0; k < NumOrbitals; k++)
998  lapl_phi_Minv(i, j) += d2psiM(i, k) * psiMinv_(j, k);
999  }
1000  for (int dim = 0; dim < OHMMS_DIM; dim++)
1001  {
1002  for (int i = 0; i < NumPtcls; i++)
1003  for (int j = 0; j < NumOrbitals; j++)
1004  {
1005  for (int k = 0; k < NumOrbitals; k++)
1006  {
1007  phi_alpha_Minv(i, j)[dim] += grad_source_psiM(i, k)[dim] * psiMinv_(j, k);
1008  grad_phi_Minv(i, j)[dim] += dpsiM(i, k)[dim] * psiMinv_(j, k);
1009  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
1010  grad_phi_alpha_Minv(i, j)(dim, dim_el) += grad_grad_source_psiM(i, k)(dim, dim_el) * psiMinv_(j, k);
1011  }
1012  }
1013  }
1014  for (int i = 0, iel = FirstIndex; i < NumPtcls; i++, iel++)
1015  {
1016  Hess dval(0.0);
1017  Grad d2val(0.0);
1018  for (int dim = 0; dim < OHMMS_DIM; dim++)
1019  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
1020  dval(dim, dim_el) = grad_phi_alpha_Minv(i, i)(dim, dim_el);
1021  for (int j = 0; j < NumOrbitals; j++)
1022  {
1023  gradPsi += grad_source_psiM(i, j) * psiMinv_(i, j);
1024  for (int dim = 0; dim < OHMMS_DIM; dim++)
1025  for (int k = 0; k < OHMMS_DIM; k++)
1026  dval(dim, k) -= phi_alpha_Minv(j, i)[dim] * grad_phi_Minv(i, j)[k];
1027  }
1028  for (int dim = 0; dim < OHMMS_DIM; dim++)
1029  {
1030  for (int k = 0; k < OHMMS_DIM; k++)
1031  grad_grad[dim][iel][k] += dval(dim, k);
1032  for (int j = 0; j < NumOrbitals; j++)
1033  {
1034  // First term, eq 9
1035  lapl_grad[dim][iel] += grad_lapl_source_psiM(i, j)[dim] * psiMinv_(i, j);
1036  // Second term, eq 9
1037  if (j == i)
1038  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
1039  lapl_grad[dim][iel] -= (Real)2.0 * grad_phi_alpha_Minv(j, i)(dim, dim_el) * grad_phi_Minv(i, j)[dim_el];
1040  // Third term, eq 9
1041  // First term, eq 10
1042  lapl_grad[dim][iel] -= phi_alpha_Minv(j, i)[dim] * lapl_phi_Minv(i, j);
1043  // Second term, eq 11
1044  for (int dim_el = 0; dim_el < OHMMS_DIM; dim_el++)
1045  lapl_grad[dim][iel] +=
1046  (Real)2.0 * phi_alpha_Minv(j, i)[dim] * grad_phi_Minv(i, i)[dim_el] * grad_phi_Minv(i, j)[dim_el];
1047  }
1048  }
1049  }
1050  }
1051  return gradPsi;
1052 }
void resizeScratchObjectsForIonDerivs()
Resize all temporary arrays required for force computation.
Matrix< Grad > grad_source_psiM
Used for force computations.
const int FirstIndex
index of the first particle with respect to the particle set
#define OHMMS_DIM
Definition: config.h:64
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
const int NumPtcls
number of particles which belong to this Dirac determinant
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ evalGradWithSpin()

DiracDeterminantBatched< PL, VT, FPVT >::Grad evalGradWithSpin ( ParticleSet P,
int  iat,
ComplexType spingrad 
)
overridevirtual

return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.

Parameters
Pquantum particle set
iatparticle index
Returns
the spin gradient of the iat-th particle

Reimplemented from DiracDeterminantBase.

Definition at line 224 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

228 {
229  Phi->evaluate_spin(P, iat, psiV_host_view, dspin_psiV_host_view);
230  ScopedTimer local_timer(RatioTimer);
231  const int WorkingIndex = iat - FirstIndex;
232  Grad g = simd::dot(psiMinv_[WorkingIndex], dpsiM[WorkingIndex], NumOrbitals);
233  ComplexType spin_g = simd::dot(psiMinv_[WorkingIndex], dspin_psiV.data(), NumOrbitals);
234  assert(checkG(g));
235  spingrad += spin_g;
236  return g;
237 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
QTBase::ComplexType ComplexType
Definition: Configuration.h:59
const int FirstIndex
index of the first particle with respect to the particle set
static bool checkG(const GradType &g)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl

◆ evaluateDerivatives()

void evaluateDerivatives ( ParticleSet P,
const opt_variables_type active,
Vector< Value > &  dlogpsi,
Vector< Value > &  dhpsioverpsi 
)
override

Definition at line 1188 of file DiracDeterminantBatched.cpp.

1192 {
1193  Phi->evaluateDerivatives(P, active, dlogpsi, dhpsioverpsi, FirstIndex, LastIndex);
1194 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set

◆ evaluateDerivativesWF()

void evaluateDerivativesWF ( ParticleSet P,
const opt_variables_type optvars,
Vector< ValueType > &  dlogpsi 
)
overridevirtual

Compute the derivatives of the log of the wavefunction with respect to optimizable parameters.

parameters

Parameters
Pparticle set
optvarsoptimizable parameters
dlogpsiarray of derivatives of the log of the wavefunction. Note: this function differs from the evaluateDerivatives function in the way that it only computes the derivative of the log of the wavefunction.

Reimplemented from DiracDeterminantBase.

Definition at line 1197 of file DiracDeterminantBatched.cpp.

1200 {
1201  Phi->evaluateDerivativesWF(P, active, dlogpsi, FirstIndex, LastIndex);
1202 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set

◆ evaluateDerivRatios()

void evaluateDerivRatios ( const VirtualParticleSet VP,
const opt_variables_type optvars,
std::vector< ValueType > &  ratios,
Matrix< ValueType > &  dratios 
)
overridevirtual

evaluate ratios to evaluate the non-local PP

Parameters
VPVirtualParticleSet
ratiosratios with new positions VP.R[k] the VP.refPtcl
dratiosNq x Num_param matrix. $\partial_{\alpha}(\ln \Psi ({\bf R}^{\prime}) - \ln \Psi ({\bf R})) $

Reimplemented from WaveFunctionComponent.

Definition at line 893 of file DiracDeterminantBatched.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

897 {
898  const int WorkingIndex = VP.refPtcl - FirstIndex;
899  assert(WorkingIndex >= 0);
900  std::copy_n(psiMinv_[WorkingIndex], d2psiV.size(), d2psiV.data());
901  Phi->evaluateDerivRatios(VP, optvars, psiV_host_view, d2psiV_host_view, ratios, dratios, FirstIndex, LastIndex);
902 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548

◆ evaluateGL()

DiracDeterminantBatched< PL, VT, FPVT >::LogValue evaluateGL ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L,
bool  fromscratch 
)
overridevirtual

compute gradients and laplacian of the TWF with respect to each particle.

Parameters
Pparticle set
GGradients, $\nabla\ln\Psi$
LLaplacians, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numeical error accumulation, all the internal data are recomputed from scratch.
Returns
log(psi)

Reimplemented from WaveFunctionComponent.

Definition at line 623 of file DiracDeterminantBatched.cpp.

628 {
629  if (fromscratch)
630  // this updates LogValue
631  evaluateLog(P, G, L);
632  else
633  {
634  if (UpdateMode == ORB_PBYP_RATIO)
635  { //need to compute dpsiM and d2psiM. Do not touch psiM!
636  ScopedTimer spo_timer(SPOVGLTimer);
637  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_host, dpsiM, d2psiM);
638  }
640  computeGL(G, L);
641  }
642  return log_value_;
643 }
void computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L assuming psiMinv, dpsiM, d2psiM are ready for use
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate from scratch pretty much everything for this single walker determinant
const int LastIndex
index of the last particle with respect to the particle set
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ evaluateHessian()

void evaluateHessian ( ParticleSet P,
HessVector grad_grad_psi 
)
overridevirtual

Reimplemented from WaveFunctionComponent.

Definition at line 947 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot(), and qmcplusplus::outerProduct().

948 {
949  // Hessian is not often used, so only resize/allocate if used
951  //IM A HACK. Assumes evaluateLog has already been executed.
952  Matrix<Value> psiM_temp_host(psiM_temp.data(), psiM_temp.rows(), psiM_temp.cols());
953  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_temp_host, dpsiM, grad_grad_source_psiM);
955 
956  phi_alpha_Minv = 0.0;
957  grad_phi_Minv = 0.0;
958  lapl_phi_Minv = 0.0;
959  grad_phi_alpha_Minv = 0.0;
960  //grad_grad_psi.resize(NumPtcls);
961 
962  for (int i = 0, iat = FirstIndex; i < NumPtcls; i++, iat++)
963  {
964  Grad rv = simd::dot(psiMinv_[i], dpsiM[i], NumOrbitals);
965  // HessType hess_tmp=simd::dot(psiMinv_[i],grad_grad_source_psiM[i],NumOrbitals);
966  Hess hess_tmp;
967  hess_tmp = 0.0;
969  grad_grad_psi[iat] = hess_tmp - outerProduct(rv, rv);
970  }
971 }
DualMatrix< Value > psiM_temp
psiM(j,i) .
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > outerProduct(const TinyVector< T1, D > &lhs, const TinyVector< T2, D > &rhs)
Definition: TinyVector.h:211
const int LastIndex
index of the last particle with respect to the particle set
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
void invertPsiM(const DualMatrix< Value > &psiM, DualMatrix< Value > &psiMinv)
single invert logdetT(psiM) as a side effect this->log_value_ gets the log determinant of logdetT ...
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ evaluateLog()

DiracDeterminantBatched< PL, VT, FPVT >::LogValue evaluateLog ( const ParticleSet P,
ParticleSet::ParticleGradient G,
ParticleSet::ParticleLaplacian L 
)
overridevirtual

evaluate from scratch pretty much everything for this single walker determinant

Calculate the log value of the Dirac determinant for particles.

return of the log of the dirac determinant is the least of what it does.

call to generate valid initial state for determinant and when you suspect psiMinv or other state variables may have picked up error.

Parameters
Pinput configuration containing N particles
Ga vector containing N gradients
La vector containing N laplacians
Returns
the complex value of the determinant

$ (first,first+nel). $ Add the gradient and laplacian contribution of the determinant to G(radient) and L(aplacian) for local energy calculations.

Implements WaveFunctionComponent.

Definition at line 1065 of file DiracDeterminantBatched.cpp.

1069 {
1070  recompute(P);
1071  computeGL(G, L);
1072  return log_value_;
1073 }
void computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L assuming psiMinv, dpsiM, d2psiM are ready for use
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.

◆ evaluateRatios()

void evaluateRatios ( const VirtualParticleSet VP,
std::vector< Value > &  ratios 
)
override

compute multiple ratios for a particle move

Definition at line 823 of file DiracDeterminantBatched.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

824 {
825  {
826  ScopedTimer local_timer(RatioTimer);
827  const int WorkingIndex = VP.refPtcl - FirstIndex;
828  std::copy_n(psiMinv_[WorkingIndex], d2psiV.size(), d2psiV.data());
829  }
830  {
831  ScopedTimer local_timer(SPOVTimer);
832  Phi->evaluateDetRatios(VP, psiV_host_view, d2psiV_host_view, ratios);
833  }
834 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548

◆ evaluateRatiosAlltoOne()

void evaluateRatiosAlltoOne ( ParticleSet P,
std::vector< Value > &  ratios 
)
override

Definition at line 905 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

906 {
907  {
908  ScopedTimer local_timer(SPOVTimer);
909  Phi->evaluateValue(P, -1, psiV_host_view);
910  }
911  for (int i = 0; i < psiMinv_.rows(); i++)
912  ratios[FirstIndex + i] = simd::dot(psiMinv_[i], psiV.data(), NumOrbitals);
913 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ evaluateSpinorRatios()

void evaluateSpinorRatios ( const VirtualParticleSet VP,
const std::pair< ValueVector, ValueVector > &  spinor_multiplier,
std::vector< Value > &  ratios 
)
override

Definition at line 837 of file DiracDeterminantBatched.cpp.

References qmcplusplus::syclBLAS::copy_n(), and VirtualParticleSet::refPtcl.

841 {
842  {
843  ScopedTimer local_timer(RatioTimer);
844  const int WorkingIndex = VP.refPtcl - FirstIndex;
845  std::copy_n(psiMinv_[WorkingIndex], d2psiV.size(), d2psiV.data());
846  }
847  {
848  ScopedTimer local_timer(SPOVTimer);
849  Phi->evaluateDetSpinorRatios(VP, psiV_host_view, spinor_multipler, d2psiV_host_view, ratios);
850  }
851 }
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
sycl::event copy_n(sycl::queue &aq, const T1 *restrict VA, size_t array_size, T2 *restrict VC, const std::vector< sycl::event > &events)
Definition: syclBLAS.cpp:548

◆ get_psiMinv()

const auto& get_psiMinv ( ) const
inline

◆ getClassName()

std::string getClassName ( ) const
inlineoverridevirtual

return class name

Implements WaveFunctionComponent.

Definition at line 117 of file DiracDeterminantBatched.h.

117 { return "DiracDeterminant"; }

◆ invertPsiM()

void invertPsiM ( const DualMatrix< Value > &  psiM,
DualMatrix< Value > &  psiMinv 
)
private

single invert logdetT(psiM) as a side effect this->log_value_ gets the log determinant of logdetT

Definition at line 85 of file DiracDeterminantBatched.cpp.

References Matrix< T, Alloc >::updateTo().

86 {
87  ScopedTimer inverse_timer(InverseTimer);
89  psiMinv.updateTo();
90 
91 #ifndef NDEBUG
92  // This is easily breakable in that it assumes this function gets psiMinv == det_engine_.psiMinv_
93  auto& engine_psiMinv = psiMinv_;
94  dummy_vmt.attachReference(engine_psiMinv.data(), engine_psiMinv.rows(), engine_psiMinv.cols());
95 #endif
96 }
DiracMatrix< FullPrecValue > host_inverter_
slow but doesn&#39;t consume device memory
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::enable_if_t< std::is_same< T_FP, TMAT >::value > invert_transpose(const Matrix< TMAT, ALLOC1 > &amat, Matrix< TMAT, ALLOC2 > &invMat, std::complex< TREAL > &LogDet)
compute the inverse of the transpose of matrix A and its determinant value in log when T_FP and TMAT ...
Definition: DiracMatrix.h:188

◆ makeCopy()

std::unique_ptr< DiracDeterminantBase > makeCopy ( std::unique_ptr< SPOSet > &&  spo) const
overridevirtual

cloning function

Parameters
tqptarget particleset
spospo set

This interface is exposed only to SlaterDet and its derived classes can overwrite to clone itself correctly.

Implements DiracDeterminantBase.

Definition at line 1212 of file DiracDeterminantBatched.cpp.

1214 {
1215  return std::make_unique<DiracDeterminantBatched<PL, VT, FPVT>>(std::move(spo), FirstIndex, LastIndex, ndelay_,
1217 }
const int ndelay_
maximal number of delayed updates
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion with walker batching
const int FirstIndex
index of the first particle with respect to the particle set
const int LastIndex
index of the last particle with respect to the particle set

◆ mw_accept_rejectMove()

void mw_accept_rejectMove ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
const std::vector< bool > &  isAccepted,
bool  safe_to_delay = false 
) const
overridevirtual

moves of the iat-th particle on some walkers in a batch is accepted.

Update the current content. Note that all the lists only include accepted walkers.

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
iatparticle index
safe_to_delayif true, delayed accept is safe.

Reimplemented from WaveFunctionComponent.

Definition at line 480 of file DiracDeterminantBatched.cpp.

References qmcplusplus::convertValueToLog(), qmcplusplus::det(), qmcplusplus::ewaldref::DIM, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

486 {
487  assert(this == &wfc_list.getLeader());
488  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
489  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
490  auto& phi_vgl_v = mw_res.phi_vgl_v;
491  auto& ratios_local = mw_res.ratios_local;
492 
493  ScopedTimer update(UpdateTimer);
494 
495  const int nw = wfc_list.size();
496  int count = 0;
497  for (int iw = 0; iw < nw; iw++)
498  if (isAccepted[iw])
499  count++;
500  const int n_accepted = count;
501 
502  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
503  engine_list.reserve(nw);
504  std::vector<Value*> psiM_g_dev_ptr_list(n_accepted, nullptr);
505  std::vector<Value*> psiM_l_dev_ptr_list(n_accepted, nullptr);
506 
507  const int WorkingIndex = iat - FirstIndex;
508  for (int iw = 0, count = 0; iw < nw; iw++)
509  {
510  // This can be auto but some debuggers can't figure the type out.
511  DiracDeterminantBatched<PL, VT, FPVT>& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
512  engine_list.push_back(det.det_engine_);
513  if (isAccepted[iw])
514  {
515  psiM_g_dev_ptr_list[count] = det.psiM_vgl.device_data() + psiM_vgl.capacity() + NumOrbitals * WorkingIndex * DIM;
516  psiM_l_dev_ptr_list[count] = det.psiM_vgl.device_data() + psiM_vgl.capacity() * 4 + NumOrbitals * WorkingIndex;
517  if (det.curRatio == PsiValue(0))
518 
519  {
520  std::ostringstream msg;
521  msg << "DiracDeterminantBatched::mw_accept_rejectMove det.curRatio is " << det.curRatio << "! Report a bug."
522  << std::endl;
523  throw std::runtime_error(msg.str());
524  }
525  det.log_value_ += convertValueToLog(det.curRatio);
526  count++;
527  }
528  det.curRatio = 1.0;
529  }
530 
531  UpdateEngine::mw_accept_rejectRow(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc,
532  mw_res.psiMinv_refs, WorkingIndex, psiM_g_dev_ptr_list, psiM_l_dev_ptr_list,
533  isAccepted, phi_vgl_v, ratios_local);
534 
535  if (!safe_to_delay)
536  UpdateEngine::mw_updateInvMat(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc, mw_res.psiMinv_refs);
537 }
size_type capacity() const
return the physical size
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
std::complex< T > convertValueToLog(const std::complex< T > &logpsi)
evaluate log(psi) as log(|psi|) and phase
const int FirstIndex
index of the first particle with respect to the particle set
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_calcRatio()

void mw_calcRatio ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios 
) const
override

Definition at line 772 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

776 {
777  assert(this == &wfc_list.getLeader());
778  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
779  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
780  auto& phi_vgl_v = mw_res.phi_vgl_v;
781  auto& ratios_local = mw_res.ratios_local;
782  auto& grad_new_local = mw_res.grad_new_local;
783 
784  {
785  ScopedTimer local_timer(SPOVTimer);
786  RefVectorWithLeader<SPOSet> phi_list(*Phi);
787  phi_list.reserve(wfc_list.size());
788  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
789  engine_list.reserve(wfc_list.size());
790 
791  const int WorkingIndex = iat - FirstIndex;
792  for (int iw = 0; iw < wfc_list.size(); iw++)
793  {
794  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
795  phi_list.push_back(*det.Phi);
796  engine_list.push_back(det.det_engine_);
797  }
798 
799  auto psiMinv_row_dev_ptr_list =
800  UpdateEngine::mw_getInvRow(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc, mw_res.psiMinv_refs,
801  WorkingIndex, !Phi->isOMPoffload());
802 
803  phi_vgl_v.resize(DIM_VGL, wfc_list.size(), NumOrbitals);
804  ratios_local.resize(wfc_list.size());
805  grad_new_local.resize(wfc_list.size());
806 
807  // calling Phi->mw_evaluateVGLandDetRatioGrads is a temporary workaround.
808  // We may implement mw_evaluateVandDetRatio in the future.
809  wfc_leader.Phi->mw_evaluateVGLandDetRatioGrads(phi_list, p_list, iat, psiMinv_row_dev_ptr_list, phi_vgl_v,
810  ratios_local, grad_new_local);
811  }
812 
813  wfc_leader.UpdateMode = ORB_PBYP_RATIO;
814  for (int iw = 0; iw < wfc_list.size(); iw++)
815  {
816  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
817  det.UpdateMode = ORB_PBYP_RATIO;
818  ratios[iw] = det.curRatio = ratios_local[iw];
819  }
820 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_completeUpdates()

void mw_completeUpdates ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list) const
overridevirtual

complete all the delayed or asynchronous operations for all the walkers in a batch before leaving the p-by-p move region.

Reimplemented from WaveFunctionComponent.

Definition at line 561 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_, and qmcplusplus::queue.

563 {
564  assert(this == &wfc_list.getLeader());
565  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
566  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
567  const auto nw = wfc_list.size();
568  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
569  engine_list.reserve(nw);
570  for (int iw = 0; iw < nw; iw++)
571  {
572  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
573  engine_list.push_back(det.det_engine_);
574  }
575 
576  {
577  ScopedTimer update(UpdateTimer);
578  UpdateEngine::mw_updateInvMat(engine_list, mw_res.engine_rsc, mw_res.psiMinv_refs);
579  }
580 
581  { // transfer dpsiM, d2psiM, psiMinv to host
582  ScopedTimer d2h(D2HTimer);
583 
584  // this call also completes all the device copying of dpsiM, d2psiM before the target update
585  UpdateEngine::mw_transferAinv_D2H(engine_list, mw_res.engine_rsc, mw_res.psiMinv_refs);
586 
588  {
589  RefVector<DualVGLVector> psiM_vgl_list;
590  psiM_vgl_list.reserve(nw);
591  for (int iw = 0; iw < nw; iw++)
592  {
593  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
594  psiM_vgl_list.push_back(det.psiM_vgl);
595  }
596 
597  auto& queue = mw_res.engine_rsc.queue;
598  for (DualVGLVector& psiM_vgl : psiM_vgl_list)
599  {
600  const size_t stride = psiM_vgl.capacity();
601  // transfer device to host, total size 4, g(3) + l(1), skipping v
602  queue.enqueueD2H(psiM_vgl, stride * 4, stride);
603  }
604  queue.sync();
605  }
606  }
607 }
size_type capacity() const
return the physical size
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
VectorSoaContainer< Value, DIM+2, OffloadPinnedAllocator< Value > > DualVGLVector
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]

◆ mw_evalGrad()

void mw_evalGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< Grad > &  grad_now 
) const
override

Definition at line 189 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), qmcplusplus::ewaldref::DIM, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

193 {
194  assert(this == &wfc_list.getLeader());
195  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
196  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
197  ScopedTimer local_timer(RatioTimer);
198 
199  const int nw = wfc_list.size();
200  std::vector<const Value*> dpsiM_row_list(nw, nullptr);
201  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
202  engine_list.reserve(nw);
203 
204  const int WorkingIndex = iat - FirstIndex;
205  for (int iw = 0; iw < nw; iw++)
206  {
207  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
208  // capacity is the size of each vector in the VGL so this advances us to the g then makes
209  // an offset into the gradients
210  dpsiM_row_list[iw] = det.psiM_vgl.device_data() + psiM_vgl.capacity() + NumOrbitals * WorkingIndex * DIM;
211  engine_list.push_back(det.det_engine_);
212  }
213 
214  UpdateEngine::mw_evalGrad(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc, mw_res.psiMinv_refs,
215  dpsiM_row_list, WorkingIndex, grad_now);
216 
217 #ifndef NDEBUG
218  for (int iw = 0; iw < nw; iw++)
219  checkG(grad_now[iw]);
220 #endif
221 }
size_type capacity() const
return the physical size
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
static bool checkG(const GradType &g)
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_evalGradWithSpin()

void mw_evalGradWithSpin ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< Grad > &  grad_now,
std::vector< ComplexType > &  spingrad_now 
) const
override

Definition at line 240 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), qmcplusplus::ewaldref::DIM, RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), SPOSet::mw_evaluateVGLWithSpin(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

246 {
247  assert(this == &wfc_list.getLeader());
248  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
249  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
250  auto& mw_dspin = mw_res.mw_dspin;
251  ScopedTimer local_timer(RatioTimer);
252 
253  const int nw = wfc_list.size();
254  const int num_orbitals = wfc_leader.Phi->size();
255  mw_dspin.resize(nw, num_orbitals);
256 
257  //Here, we are just always recomputing the spin gradients from the SPOSet for simplicity.
258  //If we stored and modified the accept/reject to include updating stored spin gradients, we could the
259  //mw_evaluateVGLWithSpin call below and just use the stored spin gradients.
260  //May revisit this in the future.
261  RefVectorWithLeader<SPOSet> phi_list(*Phi);
262  RefVector<SPOSet::ValueVector> psi_v_list, lap_v_list;
263  RefVector<SPOSet::GradVector> grad_v_list;
264  for (int iw = 0; iw < wfc_list.size(); iw++)
265  {
266  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
267  phi_list.push_back(*det.Phi);
268  psi_v_list.push_back(det.psiV_host_view);
269  grad_v_list.push_back(det.dpsiV_host_view);
270  lap_v_list.push_back(det.d2psiV_host_view);
271  }
272 
273  auto& phi_leader = phi_list.getLeader();
274  phi_leader.mw_evaluateVGLWithSpin(phi_list, p_list, iat, psi_v_list, grad_v_list, lap_v_list, mw_dspin);
275 
276  std::vector<const Value*> dpsiM_row_list(nw, nullptr);
277  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
278  engine_list.reserve(nw);
279 
280  const int WorkingIndex = iat - FirstIndex;
281  for (int iw = 0; iw < nw; iw++)
282  {
283  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
284  // capacity is the size of each vector in the VGL so this advances us to the g then makes
285  // an offset into the gradients
286  dpsiM_row_list[iw] = det.psiM_vgl.device_data() + psiM_vgl.capacity() + NumOrbitals * WorkingIndex * DIM;
287  engine_list.push_back(det.det_engine_);
288  }
289 
290  UpdateEngine::mw_evalGradWithSpin(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc,
291  mw_res.psiMinv_refs, dpsiM_row_list, mw_dspin, WorkingIndex, grad_now,
292  spingrad_now);
293 
294 #ifndef NDEBUG
295  for (int iw = 0; iw < nw; iw++)
296  checkG(grad_now[iw]);
297 #endif
298 }
size_type capacity() const
return the physical size
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
static bool checkG(const GradType &g)
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_evaluateGL()

void mw_evaluateGL ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const RefVector< ParticleSet::ParticleGradient > &  G_list,
const RefVector< ParticleSet::ParticleLaplacian > &  L_list,
bool  fromscratch 
) const
overridevirtual

evaluate gradients and laplacian of the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
fromscratchif true and this WFC is sensitive to numerical error accumulation, all the internal data are recomputed from scratch.

Reimplemented from WaveFunctionComponent.

Definition at line 646 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), and RefVectorWithLeader< T >::getLeader().

651 {
652  assert(this == &wfc_list.getLeader());
653  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
654  if (fromscratch)
655  mw_evaluateLog(wfc_list, p_list, G_list, L_list);
656  else
657  {
658  const auto nw = wfc_list.size();
659  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
660  engine_list.reserve(nw);
661 
662  if (UpdateMode == ORB_PBYP_RATIO)
663  { //need to compute dpsiM and d2psiM. psiMinv is not touched!
664  ScopedTimer spo_timer(SPOVGLTimer);
665 
666  RefVectorWithLeader<SPOSet> phi_list(*Phi);
667  RefVector<Matrix<Value>> psiM_temp_list;
668  RefVector<Matrix<Grad>> dpsiM_list;
669  RefVector<Matrix<Value>> d2psiM_list;
670  phi_list.reserve(wfc_list.size());
671  psiM_temp_list.reserve(nw);
672  dpsiM_list.reserve(nw);
673  d2psiM_list.reserve(nw);
674 
675  for (int iw = 0; iw < nw; iw++)
676  {
677  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
678  engine_list.push_back(det.det_engine_);
679  phi_list.push_back(*det.Phi);
680  psiM_temp_list.push_back(det.psiM_host);
681  dpsiM_list.push_back(det.dpsiM);
682  d2psiM_list.push_back(det.d2psiM);
683  }
684 
685  Phi->mw_evaluate_notranspose(phi_list, p_list, FirstIndex, LastIndex, psiM_temp_list, dpsiM_list, d2psiM_list);
686  }
687 
688  for (int iw = 0; iw < nw; iw++)
689  {
690  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
691 
692 #ifndef NDEBUG
693  // at this point, host and device should have exactly the same G and L values.
694  GradMatrix dpsiM_from_device = det.dpsiM;
695  Matrix<Value> d2psiM_from_device = det.d2psiM;
696 
697  auto& my_psiM_vgl = det.psiM_vgl;
698  auto* psiM_vgl_ptr = my_psiM_vgl.data();
699  // transfer device to host, total size 4, g(3) + l(1)
700  PRAGMA_OFFLOAD("omp target update from(psiM_vgl_ptr[my_psiM_vgl.capacity():my_psiM_vgl.capacity()*4])")
701  assert(dpsiM_from_device == det.dpsiM);
702  assert(d2psiM_from_device == det.d2psiM);
703 #endif
704 
705  det.UpdateMode = ORB_WALKER;
706  det.computeGL(G_list[iw], L_list[iw]);
707  }
708  }
709 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
void mw_evaluateLog(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const RefVector< ParticleSet::ParticleGradient > &G_list, const RefVector< ParticleSet::ParticleLaplacian > &L_list) const override
evaluate from scratch the same type WaveFunctionComponent of multiple walkers
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ mw_evaluateLog()

void mw_evaluateLog ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const RefVector< ParticleSet::ParticleGradient > &  G_list,
const RefVector< ParticleSet::ParticleLaplacian > &  L_list 
) const
overridevirtual

evaluate from scratch the same type WaveFunctionComponent of multiple walkers

Parameters
wfc_listthe list of WaveFunctionComponent pointers of the same component in a walker batch
p_listthe list of ParticleSet pointers in a walker batch
G_listthe list of Gradients pointers in a walker batch, $\nabla\ln\Psi$
L_listthe list of Laplacians pointers in a walker batch, $\nabla^2\ln\Psi$
valuesthe log WF values of walkers in a batch

Reimplemented from WaveFunctionComponent.

Definition at line 1076 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), and RefVectorWithLeader< T >::getLeader().

1081 {
1082  assert(this == &wfc_list.getLeader());
1083  const std::vector<bool> recompute_all(wfc_list.size(), true);
1084  mw_recompute(wfc_list, p_list, recompute_all);
1085 
1086  for (int iw = 0; iw < wfc_list.size(); iw++)
1087  {
1088  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
1089  det.computeGL(G_list[iw], L_list[iw]);
1090  }
1091 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
void mw_recompute(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const override
Does a Phi->mw_evaluate_notranspose then mw_invertPsiM over a set of elements filtered based on the r...

◆ mw_evaluateRatios()

void mw_evaluateRatios ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< const VirtualParticleSet > &  vp_list,
std::vector< std::vector< Value >> &  ratios 
) const
override

Definition at line 854 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), and RefVectorWithLeader< T >::getLeader().

858 {
859  assert(this == &wfc_list.getLeader());
860  const size_t nw = wfc_list.size();
861 
862  RefVectorWithLeader<SPOSet> phi_list(*Phi);
863  RefVector<Vector<Value>> psiV_list;
864  std::vector<const Value*> invRow_ptr_list;
865  phi_list.reserve(nw);
866  psiV_list.reserve(nw);
867  invRow_ptr_list.reserve(nw);
868 
869  {
870  ScopedTimer local_timer(RatioTimer);
871  for (size_t iw = 0; iw < nw; iw++)
872  {
873  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
874  const VirtualParticleSet& vp(vp_list[iw]);
875  const int WorkingIndex = vp.refPtcl - FirstIndex;
876  // build lists
877  phi_list.push_back(*det.Phi);
878  psiV_list.push_back(det.psiV_host_view);
879  if (Phi->isOMPoffload())
880  invRow_ptr_list.push_back(det.psiMinv_.device_data() + WorkingIndex * psiMinv_.cols());
881  else
882  invRow_ptr_list.push_back(det.psiMinv_[WorkingIndex]);
883  }
884  }
885 
886  {
887  ScopedTimer local_timer(SPOVTimer);
888  Phi->mw_evaluateDetRatios(phi_list, vp_list, psiV_list, invRow_ptr_list, ratios);
889  }
890 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ mw_invertPsiM()

void mw_invertPsiM ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVector< const DualMatrix< Value >> &  logdetT_list,
const RefVector< DualMatrix< Value >> &  a_inv_lis 
)
staticprivate

Inverts and finds log det for a batch of matrices.

Right now this takes filtered lists and the full recompute mask. It passes all these elements down to the det_engine_. This allows minimal change for implementation code while establishing the API I'd prefer for direct inversion. I think the det_engine_ mw method should receive the complete list of walker elements and the implementation should decide what to do re the compute mask. See future PR for those changes, or drop of compute_mask argument.

Definition at line 99 of file DiracDeterminantBatched.cpp.

References qmcplusplus::ACCEL, DiracDeterminantBatched< PL, VT, FPVT >::accel_inverter_, qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), ResourceHandle< RS >::getResource(), DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_, and DiracDeterminantBatched< PL, VT, FPVT >::resize().

102 {
103  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
104  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
105  ScopedTimer inverse_timer(wfc_leader.InverseTimer);
106  const auto nw = wfc_list.size();
107 
108  if (wfc_leader.matrix_inverter_kind_ == DetMatInvertor::ACCEL)
109  {
110  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
111  engine_list.reserve(nw);
112 
113  mw_res.log_values.resize(nw);
114 
115  for (int iw = 0; iw < nw; iw++)
116  {
117  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
118  engine_list.push_back(det.det_engine_);
119  mw_res.log_values[iw] = {0.0, 0.0};
120  }
121 
122  wfc_leader.accel_inverter_.getResource().mw_invertTranspose(mw_res.engine_rsc.queue, logdetT_list, a_inv_list,
123  mw_res.log_values);
124 
125  for (int iw = 0; iw < nw; ++iw)
126  {
127  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
128  det.log_value_ = mw_res.log_values[iw];
129  }
130  }
131  else
132  {
133  for (int iw = 0; iw < nw; iw++)
134  {
135  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
136  DualMatrix<Value>& psiMinv = a_inv_list[iw];
137  det.host_inverter_.invert_transpose(logdetT_list[iw].get(), psiMinv, det.log_value_);
138  psiMinv.updateTo();
139  }
140  }
141 
142 #ifndef NDEBUG
143  for (int iw = 0; iw < nw; ++iw)
144  {
145  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
146  auto& engine_psiMinv = det.psiMinv_;
147  det.dummy_vmt.attachReference(engine_psiMinv.data(), engine_psiMinv.rows(), engine_psiMinv.cols());
148  }
149 #endif
150 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257

◆ mw_ratioGrad()

void mw_ratioGrad ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< Grad > &  grad_new 
) const
override

Definition at line 324 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

329 {
330  assert(this == &wfc_list.getLeader());
331  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
332  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
333  auto& phi_vgl_v = mw_res.phi_vgl_v;
334  auto& ratios_local = mw_res.ratios_local;
335  auto& grad_new_local = mw_res.grad_new_local;
336  {
337  ScopedTimer local_timer(SPOVGLTimer);
338  RefVectorWithLeader<SPOSet> phi_list(*Phi);
339  phi_list.reserve(wfc_list.size());
340  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
341  engine_list.reserve(wfc_list.size());
342  const int WorkingIndex = iat - FirstIndex;
343  for (int iw = 0; iw < wfc_list.size(); iw++)
344  {
345  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
346  phi_list.push_back(*det.Phi);
347  engine_list.push_back(det.det_engine_);
348  }
349 
350  auto psiMinv_row_dev_ptr_list =
351  UpdateEngine::mw_getInvRow(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc, mw_res.psiMinv_refs,
352  WorkingIndex, !Phi->isOMPoffload());
353 
354  phi_vgl_v.resize(DIM_VGL, wfc_list.size(), NumOrbitals);
355  ratios_local.resize(wfc_list.size());
356  grad_new_local.resize(wfc_list.size());
357 
358  wfc_leader.Phi->mw_evaluateVGLandDetRatioGrads(phi_list, p_list, iat, psiMinv_row_dev_ptr_list, phi_vgl_v,
359  ratios_local, grad_new_local);
360  }
361 
362  wfc_leader.UpdateMode = ORB_PBYP_PARTIAL;
363  for (int iw = 0; iw < wfc_list.size(); iw++)
364  {
365  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
366  det.UpdateMode = ORB_PBYP_PARTIAL;
367  ratios[iw] = det.curRatio = ratios_local[iw];
368  grad_new[iw] += grad_new_local[iw];
369  }
370 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_ratioGradWithSpin()

void mw_ratioGradWithSpin ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
int  iat,
std::vector< PsiValue > &  ratios,
std::vector< Grad > &  grad_new,
std::vector< ComplexType > &  spingrad_new 
) const
override

Definition at line 373 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_.

380 {
381  assert(this == &wfc_list.getLeader());
382  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
383  auto& mw_res = wfc_leader.mw_res_handle_.getResource();
384  auto& phi_vgl_v = mw_res.phi_vgl_v;
385  auto& ratios_local = mw_res.ratios_local;
386  auto& grad_new_local = mw_res.grad_new_local;
387  auto& spingrad_new_local = mw_res.spingrad_new_local;
388  {
389  ScopedTimer local_timer(SPOVGLTimer);
390  RefVectorWithLeader<SPOSet> phi_list(*Phi);
391  phi_list.reserve(wfc_list.size());
392  RefVectorWithLeader<UpdateEngine> engine_list(wfc_leader.det_engine_);
393  engine_list.reserve(wfc_list.size());
394  const int WorkingIndex = iat - FirstIndex;
395  for (int iw = 0; iw < wfc_list.size(); iw++)
396  {
397  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
398  phi_list.push_back(*det.Phi);
399  engine_list.push_back(det.det_engine_);
400  }
401 
402  auto psiMinv_row_dev_ptr_list =
403  UpdateEngine::mw_getInvRow(engine_list, wfc_leader.mw_res_handle_.getResource().engine_rsc, mw_res.psiMinv_refs,
404  WorkingIndex, !Phi->isOMPoffload());
405 
406  phi_vgl_v.resize(DIM_VGL, wfc_list.size(), NumOrbitals);
407  ratios_local.resize(wfc_list.size());
408  grad_new_local.resize(wfc_list.size());
409  spingrad_new_local.resize(wfc_list.size());
410 
411  wfc_leader.Phi->mw_evaluateVGLandDetRatioGradsWithSpin(phi_list, p_list, iat, psiMinv_row_dev_ptr_list, phi_vgl_v,
412  ratios_local, grad_new_local, spingrad_new_local);
413  }
414 
415  wfc_leader.UpdateMode = ORB_PBYP_PARTIAL;
416  for (int iw = 0; iw < wfc_list.size(); iw++)
417  {
418  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
419  det.UpdateMode = ORB_PBYP_PARTIAL;
420  ratios[iw] = det.curRatio = ratios_local[iw];
421  grad_new[iw] += grad_new_local[iw];
422  spingrad_new[iw] += spingrad_new_local[iw];
423  }
424 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant

◆ mw_recompute()

void mw_recompute ( const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< bool > &  recompute 
) const
overridevirtual

Does a Phi->mw_evaluate_notranspose then mw_invertPsiM over a set of elements filtered based on the recompute mask.

Reimplemented from WaveFunctionComponent.

Definition at line 1109 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedElement(), RefVectorWithLeader< T >::getCastedLeader(), RefVectorWithLeader< T >::getLeader(), and qmcplusplus::queue.

1112 {
1113  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
1114  const auto nw = wfc_list.size();
1115 
1116  RefVectorWithLeader<WaveFunctionComponent> wfc_filtered_list(wfc_list.getLeader());
1117  RefVectorWithLeader<ParticleSet> p_filtered_list(p_list.getLeader());
1118  RefVectorWithLeader<SPOSet> phi_list(*wfc_leader.Phi);
1119  std::vector<Matrix<Value>> psiM_host_views;
1120  RefVector<const DualMatrix<Value>> psiM_temp_list;
1121  RefVector<Matrix<Value>> psiM_host_list;
1122  RefVector<Matrix<Grad>> dpsiM_list;
1123  RefVector<Matrix<Value>> d2psiM_list;
1124  RefVector<DualMatrix<Value>> psiMinv_list;
1125 
1126  wfc_filtered_list.reserve(nw);
1127  p_filtered_list.reserve(nw);
1128  phi_list.reserve(nw);
1129  psiM_host_views.reserve(nw);
1130  psiM_temp_list.reserve(nw);
1131  dpsiM_list.reserve(nw);
1132  d2psiM_list.reserve(nw);
1133  psiMinv_list.reserve(nw);
1134 
1135  for (int iw = 0; iw < nw; iw++)
1136  if (recompute[iw])
1137  {
1138  wfc_filtered_list.push_back(wfc_list[iw]);
1139  p_filtered_list.push_back(p_list[iw]);
1140 
1141  auto& det = wfc_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
1142  phi_list.push_back(*det.Phi);
1143  psiM_temp_list.push_back(det.psiM_temp);
1144  psiM_host_list.push_back(det.psiM_host);
1145  dpsiM_list.push_back(det.dpsiM);
1146  d2psiM_list.push_back(det.d2psiM);
1147  psiMinv_list.push_back(det.psiMinv_);
1148  }
1149 
1150  if (!wfc_filtered_list.size())
1151  return;
1152 
1153  {
1154  ScopedTimer spo_timer(wfc_leader.SPOVGLTimer);
1155  // I think through the magic of OMPtarget psiM_host_list actually results in psiM_temp being updated
1156  // on the device. For dspiM_list, d2psiM_list I think they are calculated on CPU and this is not true
1157  // This is the reason for the strange look omp target update to below.
1158  wfc_leader.Phi->mw_evaluate_notranspose(phi_list, p_filtered_list, wfc_leader.FirstIndex, wfc_leader.LastIndex,
1159  psiM_host_list, dpsiM_list, d2psiM_list);
1160  }
1161 
1162  mw_invertPsiM(wfc_filtered_list, psiM_temp_list, psiMinv_list);
1163 
1164  { // transfer dpsiM, d2psiM, psiMinv to device
1165  ScopedTimer d2h(H2DTimer);
1166 
1167  RefVector<DualVGLVector> psiM_vgl_list;
1168  psiM_vgl_list.reserve(nw);
1169  for (int iw = 0; iw < wfc_filtered_list.size(); iw++)
1170  {
1171  auto& det = wfc_filtered_list.getCastedElement<DiracDeterminantBatched<PL, VT, FPVT>>(iw);
1172  psiM_vgl_list.push_back(det.psiM_vgl);
1173  det.UpdateMode = ORB_WALKER;
1174  }
1175 
1176  auto& queue = wfc_leader.mw_res_handle_.getResource().engine_rsc.queue;
1177  for (DualVGLVector& psiM_vgl : psiM_vgl_list)
1178  {
1179  const size_t stride = psiM_vgl.capacity();
1180  // transfer host to device, total size 4, g(3) + l(1), skipping v
1181  queue.enqueueH2D(psiM_vgl, stride * 4, stride);
1182  }
1183  queue.sync();
1184  }
1185 }
size_type capacity() const
return the physical size
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
static void mw_invertPsiM(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVector< const DualMatrix< Value >> &logdetT_list, const RefVector< DualMatrix< Value >> &a_inv_lis)
Inverts and finds log det for a batch of matrices.
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
VectorSoaContainer< Value, DIM+2, OffloadPinnedAllocator< Value > > DualVGLVector
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]

◆ operator=()

DiracDeterminantBatched& operator= ( const DiracDeterminantBatched< PL, VT, FPVT > &  s)
delete

◆ ratio()

DiracDeterminantBatched< PL, VT, FPVT >::PsiValue ratio ( ParticleSet P,
int  iat 
)
overridevirtual

return the ratio only for the iat-th partcle move

Parameters
Pcurrent configuration
iatthe particle thas is being moved

Implements WaveFunctionComponent.

Definition at line 755 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

757 {
759  const int WorkingIndex = iat - FirstIndex;
760  {
761  ScopedTimer local_timer(SPOVTimer);
762  Phi->evaluateValue(P, iat, psiV_host_view);
763  }
764  {
765  ScopedTimer local_timer(RatioTimer);
766  curRatio = simd::dot(psiMinv_[WorkingIndex], psiV.data(), NumOrbitals);
767  }
768  return curRatio;
769 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
PsiValue curRatio
psi(r&#39;)/psi(r) during a PbyP move

◆ ratioGrad()

DiracDeterminantBatched< PL, VT, FPVT >::PsiValue ratioGrad ( ParticleSet P,
int  iat,
Grad grad_iat 
)
override

Definition at line 301 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

305 {
307 
308  {
309  ScopedTimer local_timer(SPOVGLTimer);
310  Phi->evaluateVGL(P, iat, psiV_host_view, dpsiV_host_view, d2psiV_host_view);
311  }
312 
313  {
314  ScopedTimer local_timer(RatioTimer);
315  const int WorkingIndex = iat - FirstIndex;
316  curRatio = simd::dot(psiMinv_[WorkingIndex], psiV.data(), NumOrbitals);
317  grad_iat += static_cast<Value>(static_cast<PsiValue>(1.0) / curRatio) *
318  simd::dot(psiMinv_[WorkingIndex], dpsiV.data(), NumOrbitals);
319  }
320  return curRatio;
321 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
PsiValue curRatio
psi(r&#39;)/psi(r) during a PbyP move

◆ ratioGradWithSpin()

DiracDeterminantBatched< PL, VT, FPVT >::PsiValue ratioGradWithSpin ( ParticleSet P,
int  iat,
Grad grad_iat,
ComplexType spingrad 
)
override

Definition at line 427 of file DiracDeterminantBatched.cpp.

References qmcplusplus::simd::dot().

432 {
434 
435  {
436  ScopedTimer local_timer(SPOVGLTimer);
438  }
439 
440  {
441  ScopedTimer local_timer(RatioTimer);
442  const int WorkingIndex = iat - FirstIndex;
443  curRatio = simd::dot(psiMinv_[WorkingIndex], psiV.data(), NumOrbitals);
444  grad_iat += static_cast<Value>(static_cast<PsiValue>(1.0) / curRatio) *
445  simd::dot(psiMinv_[WorkingIndex], dpsiV.data(), NumOrbitals);
446  spingrad_iat += static_cast<Value>(static_cast<PsiValue>(1.0) / curRatio) *
447  simd::dot(psiMinv_[WorkingIndex], dspin_psiV.data(), NumOrbitals);
448  }
449  return curRatio;
450 }
T dot(const T *restrict a, const T *restrict b, int n, TRES res=TRES())
dot product
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
PsiValue curRatio
psi(r&#39;)/psi(r) during a PbyP move

◆ recompute()

void recompute ( const ParticleSet P)
overridevirtual

recompute the value of the WaveFunctionComponents which require critical accuracy.

needed for Slater Determinants but not needed for most types of WaveFunctionComponents

Reimplemented from WaveFunctionComponent.

Definition at line 1094 of file DiracDeterminantBatched.cpp.

1095 {
1096  {
1097  ScopedTimer spo_timer(SPOVGLTimer);
1098 
1100  Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_host, dpsiM, d2psiM);
1101  auto* psiM_vgl_ptr = psiM_vgl.data();
1102  // transfer host to device, total size 4, g(3) + l(1)
1103  PRAGMA_OFFLOAD("omp target update to(psiM_vgl_ptr[psiM_vgl.capacity():psiM_vgl.capacity()*4])")
1104  }
1106 }
DualMatrix< Value > psiM_temp
psiM(j,i) .
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix
const int LastIndex
index of the last particle with respect to the particle set
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
void invertPsiM(const DualMatrix< Value > &psiM, DualMatrix< Value > &psiMinv)
single invert logdetT(psiM) as a side effect this->log_value_ gets the log determinant of logdetT ...
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ registerData()

void registerData ( ParticleSet P,
WFBufferType buf 
)
overridevirtual

For particle-by-particle move.

Requests space in the buffer based on the data type sizes of the objects in this class.

Parameters
Pparticle set
bufAnonymous storage

Implements WaveFunctionComponent.

Definition at line 712 of file DiracDeterminantBatched.cpp.

References PooledMemory< T_scalar, Alloc >::add().

713 {
714  buf.add(psiMinv_.first_address(), psiMinv_.last_address());
715  buf.add(dpsiM.first_address(), dpsiM.last_address());
716  buf.add(d2psiM.first_address(), d2psiM.last_address());
717  buf.add(log_value_);
718 }
pointer last_address()
Definition: OhmmsMatrix.h:209
pointer first_address()
Definition: OhmmsMatrix.h:204
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ registerTWFFastDerivWrapper()

void registerTWFFastDerivWrapper ( const ParticleSet P,
TWFFastDerivWrapper twf 
) const
overridevirtual

Register the component with the TWFFastDerivWrapper wrapper.

Reimplemented from DiracDeterminantBase.

Definition at line 1205 of file DiracDeterminantBatched.cpp.

References ParticleSet::getGroupID(), and qmcplusplus::twf.

1207 {
1208  twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get());
1209 }
const int FirstIndex
index of the first particle with respect to the particle set
const std::unique_ptr< SPOSet > Phi
a set of single-particle orbitals used to fill in the values of the matrix

◆ releaseResource()

void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< WaveFunctionComponent > &  wfc_list 
) const
overridevirtual

return a shared resource to a collection

Reimplemented from WaveFunctionComponent.

Definition at line 1249 of file DiracDeterminantBatched.cpp.

References qmcplusplus::det(), RefVectorWithLeader< T >::getCastedLeader(), DiracDeterminantBatched< PL, VT, FPVT >::mw_res_handle_, and ResourceCollection::takebackResource().

1252 {
1253  auto& wfc_leader = wfc_list.getCastedLeader<DiracDeterminantBatched<PL, VT, FPVT>>();
1254  wfc_leader.mw_res_handle_.getResource().psiMinv_refs.clear();
1255  collection.takebackResource(wfc_leader.mw_res_handle_);
1256  RefVectorWithLeader<SPOSet> phi_list(*wfc_leader.Phi);
1257  for (WaveFunctionComponent& wfc : wfc_list)
1258  {
1259  auto& det = static_cast<DiracDeterminantBatched<PL, VT, FPVT>&>(wfc);
1260  phi_list.push_back(*det.Phi);
1261  }
1262  wfc_leader.Phi->releaseResource(collection, phi_list);
1263  collection.takebackResource(wfc_leader.accel_inverter_);
1264 }
Tensor< T, D >::Type_t det(const Tensor< T, D > &a)
Definition: TensorOps.h:838
WaveFunctionComponent(const std::string &obj_name="")
default constructor

◆ resize()

void resize ( int  nel,
int  morb 
)
private

reset the size: with the number of particles and number of orbtials

Definition at line 154 of file DiracDeterminantBatched.cpp.

Referenced by DiracDeterminantBatched< PL, VT, FPVT >::DiracDeterminantBatched(), and DiracDeterminantBatched< PL, VT, FPVT >::mw_invertPsiM().

155 {
156  int norb = morb;
157  if (norb <= 0)
158  norb = nel; // for morb == -1 (default)
159  psiMinv_.resize(norb, getAlignedSize<Value>(norb));
160  psiM_vgl.resize(nel * norb);
161  // attach pointers VGL
162  psiM_temp.attachReference(psiM_vgl, psiM_vgl.data(0), nel, norb);
163  psiM_host.attachReference(psiM_vgl.data(0), nel, norb);
164  dpsiM.attachReference(reinterpret_cast<Grad*>(psiM_vgl.data(1)), nel, norb);
165  d2psiM.attachReference(psiM_vgl.data(4), nel, norb);
166 
167  psiV.resize(NumOrbitals);
169  dpsiV.resize(NumOrbitals);
171  d2psiV.resize(NumOrbitals);
173  dspin_psiV.resize(NumOrbitals);
175 }
DualMatrix< Value > psiM_temp
psiM(j,i) .
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
void attachReference(T *ref, size_type n)
Definition: OhmmsVector.h:131
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
void attachReference(T *ref)
Definition: OhmmsMatrix.h:113
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
void resize(size_type n)
resize myData
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

◆ resizeScratchObjectsForIonDerivs()

void resizeScratchObjectsForIonDerivs ( )
private

Resize all temporary arrays required for force computation.

Definition at line 916 of file DiracDeterminantBatched.cpp.

917 {
925 }
Matrix< Grad > grad_source_psiM
Used for force computations.
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
const int NumOrbitals
number of single-particle orbitals which belong to this Dirac determinant
const int NumPtcls
number of particles which belong to this Dirac determinant

◆ restore()

void restore ( int  iat)
overridevirtual

move was rejected.

copy the real container to the temporary to move on

Implements WaveFunctionComponent.

Definition at line 542 of file DiracDeterminantBatched.cpp.

543 {
544  curRatio = 1.0;
545 }
PsiValue curRatio
psi(r&#39;)/psi(r) during a PbyP move

◆ updateBuffer()

DiracDeterminantBatched< PL, VT, FPVT >::LogValue updateBuffer ( ParticleSet P,
WFBufferType buf,
bool  fromscratch = false 
)
overridevirtual

For particle-by-particle move.

Put the objects of this class in the walker buffer or forward the memory cursor.

Parameters
Pparticle set
bufAnonymous storage
fromscratchrequest recomputing the precision critical pieces of wavefunction from scratch
Returns
log value of the wavefunction.

Implements WaveFunctionComponent.

Definition at line 721 of file DiracDeterminantBatched.cpp.

References ParticleSet::G, ParticleSet::L, and PooledMemory< T_scalar, Alloc >::put().

725 {
726  evaluateGL(P, P.G, P.L, fromscratch);
727  ScopedTimer local_timer(BufferTimer);
728  buf.put(psiMinv_.first_address(), psiMinv_.last_address());
729  buf.put(dpsiM.first_address(), dpsiM.last_address());
730  buf.put(d2psiM.first_address(), d2psiM.last_address());
731  buf.put(log_value_);
732  return log_value_;
733 }
LogValue evaluateGL(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L, bool fromscratch) override
compute gradients and laplacian of the TWF with respect to each particle.
pointer last_address()
Definition: OhmmsMatrix.h:209
ScopeGuard< NewTimer > ScopedTimer
Definition: NewTimer.h:257
pointer first_address()
Definition: OhmmsMatrix.h:204
Matrix< Grad > dpsiM
dpsiM(i,j) . partial memory view of psiM_vgl
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl

Member Data Documentation

◆ accel_inverter_

ResourceHandle<DetInverter> accel_inverter_
private

matrix inversion engine this a crowd scope resource and only the leader engine gets it

Definition at line 349 of file DiracDeterminantBatched.h.

Referenced by DiracDeterminantBatched< PL, VT, FPVT >::mw_invertPsiM().

◆ D2HTimer

NewTimer& D2HTimer
private

timers

Definition at line 382 of file DiracDeterminantBatched.h.

◆ det_engine_

UpdateEngine det_engine_
private

Delayed update engine 1 per walker.

Definition at line 343 of file DiracDeterminantBatched.h.

◆ H2DTimer

NewTimer & H2DTimer
private

Definition at line 382 of file DiracDeterminantBatched.h.

◆ host_inverter_

DiracMatrix<FullPrecValue> host_inverter_
private

slow but doesn't consume device memory

Definition at line 346 of file DiracDeterminantBatched.h.

◆ matrix_inverter_kind_

const DetMatInvertor matrix_inverter_kind_
private

selected scheme for inversion with walker batching

Definition at line 379 of file DiracDeterminantBatched.h.

◆ mw_res_handle_

◆ ndelay_

const int ndelay_
private

maximal number of delayed updates

Definition at line 376 of file DiracDeterminantBatched.h.


The documentation for this class was generated from the following files: