17 #ifndef QMCPLUSPLUS_DIRACDETERMINANTBATCHED_H 18 #define QMCPLUSPLUS_DIRACDETERMINANTBATCHED_H 24 #if defined(ENABLE_CUDA) && defined(ENABLE_OFFLOAD) 33 class TWFFastDerivWrapper;
35 template<PlatformKind PL,
typename VT>
44 #if defined(ENABLE_CUDA) && defined(ENABLE_OFFLOAD) 52 #if defined(ENABLE_SYCL) && defined(ENABLE_OFFLOAD) 56 using Engine = DelayedUpdateBatched<PlatformKind::SYCL, VT>;
60 template<PlatformKind UEPL,
typename FPVT>
66 #if defined(ENABLE_CUDA) && defined(ENABLE_OFFLOAD) 67 template<
typename FPVT>
74 template<PlatformKind PL,
typename VT,
typename FPVT>
117 std::string
getClassName()
const override {
return "DiracDeterminant"; }
141 std::vector<PsiValue>& ratios)
const override;
148 const std::pair<ValueVector, ValueVector>& spinor_multiplier,
149 std::vector<Value>& ratios)
override;
153 std::vector<std::vector<Value>>& ratios)
const override;
157 std::vector<ValueType>& ratios,
165 std::vector<PsiValue>& ratios,
166 std::vector<Grad>& grad_new)
const override;
171 std::vector<PsiValue>& ratios,
172 std::vector<Grad>& grad_new,
173 std::vector<ComplexType>& spingrad_new)
const override;
182 std::vector<Grad>& grad_now)
const override;
189 std::vector<Grad>& grad_now,
190 std::vector<ComplexType>& spingrad_now)
const override;
211 const std::vector<bool>& isAccepted,
212 bool safe_to_delay =
false)
const override;
224 void restore(
int iat)
override;
250 const std::vector<bool>&
recompute)
const override;
255 bool fromscratch)
override;
261 bool fromscratch)
const override;
279 std::unique_ptr<DiracDeterminantBase>
makeCopy(std::unique_ptr<SPOSet>&& spo)
const override;
340 void resize(
int nel,
int morb);
388 #if defined(ENABLE_CUDA) && defined(ENABLE_OFFLOAD) 391 #if defined(ENABLE_SYCL) && defined(ENABLE_OFFLOAD) DualMatrix< Value > psiM_temp
psiM(j,i) .
void copyFromBuffer(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Declaration of DiracDeterminantBase with a S(ingle)P(article)O(rbital)Set.
DiracDeterminantBatched & operator=(const DiracDeterminantBatched &s)=delete
implements dirac matrix delayed update using OpenMP offload and CUDA.
typename WFT::Value Value
void resizeScratchObjectsForIonDerivs()
Resize all temporary arrays required for force computation.
DiracMatrixComputeOMPTarget< FPVT > Inverter
Matrix< Grad > grad_phi_Minv
Vector< Value > psiV_host_view
DiracMatrix< FullPrecValue > host_inverter_
slow but doesn't consume device memory
const int ndelay_
maximal number of delayed updates
WaveFunctionComponent::PsiValue PsiValue
Vector< Value > dspin_psiV_host_view
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.
helper functions for EinsplineSetBuilder
Matrix< Grad > grad_source_psiM
Used for force computations.
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
class to compute matrix inversion and the log value of determinant of a batch of DiracMatrixes.
DualVector< Value > dspin_psiV
void restore(int iat) override
move was rejected.
void computeGL(ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) const
compute G and L assuming psiMinv, dpsiM, d2psiM are ready for use
Matrix< Hess > grad_grad_source_psiM
typename WFT::LogValue LogValue
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
acquire a shared resource from a collection
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...
const DetMatInvertor matrix_inverter_kind_
selected scheme for inversion with walker batching
ResourceHandle manages the temporary resource referenced from a collection.
Walker_t::WFBuffer_t WFBufferType
DetMatInvertor
determinant matrix inverter select
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
Consistent way to get the set of types used in the QMCWaveFunction module, without resorting to ifdef...
TinyVector< Value, OHMMS_DIM > Grad
typename DetInverterSelector< PL, FPVT >::Inverter DetInverter
DualVector< Value > d2psiV
typename UpdateEngineSelector< PL, VT >::Engine UpdateEngine
Grad evalGradWithSpin(ParticleSet &P, int iat, ComplexType &spingrad) override
return the current spin gradient for the iat-th particle Default implementation assumes that WaveFunc...
DualVector< Value > psiV
value of single-particle orbital for particle-by-particle update
void mw_evalGrad(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< Grad > &grad_now) const override
void evaluateHessian(ParticleSet &P, HessVector &grad_grad_psi) override
Timer accumulates time and call counts.
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.
std::string getClassName() const override
return class name
Attaches a unit to a Vector for IO.
TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level acc...
Grad evalGrad(ParticleSet &P, int iat) override
return the current gradient for the iat-th particle
void recompute(const ParticleSet &P) override
recompute the value of the WaveFunctionComponents which require critical accuracy.
PsiValue ratioGradWithSpin(ParticleSet &P, int iat, Grad &grad_iat, ComplexType &spingrad) override
void evaluateRatios(const VirtualParticleSet &VP, std::vector< Value > &ratios) override
compute multiple ratios for a particle move
void mw_calcRatio(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< ParticleSet > &p_list, int iat, std::vector< PsiValue > &ratios) const override
Matrix< Grad > phi_alpha_Minv
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...
Matrix< Hess > grad_phi_alpha_Minv
UpdateEngine det_engine_
Delayed update engine 1 per walker.
Specialized paritlce class for atomistic simulations.
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
void mw_evaluateRatios(const RefVectorWithLeader< WaveFunctionComponent > &wfc_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, std::vector< std::vector< Value >> &ratios) const override
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 ...
typename WFT::PsiValue PsiValue
QTBase::ValueType ValueType
NewTimer & D2HTimer
timers
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to a collection
Grad evalGradSource(ParticleSet &P, ParticleSet &source, int iat) override
Matrix< Value > lapl_phi_Minv
Vector< Grad > dpsiV_host_view
LogValue evaluateLog(const ParticleSet &P, ParticleSet::ParticleGradient &G, ParticleSet::ParticleLaplacian &L) override
evaluate from scratch pretty much everything for this single walker determinant
class to handle a set of variables that can be modified during optimizations
DualVGLVector psiM_vgl
fused memory for psiM, dpsiM and d2psiM. [5][norb*norb]
void evaluateSpinorRatios(const VirtualParticleSet &VP, const std::pair< ValueVector, ValueVector > &spinor_multiplier, std::vector< Value > &ratios) override
PsiValue ratioGrad(ParticleSet &P, int iat, Grad &grad_iat) override
Vector< Value > d2psiV_host_view
std::complex< FullPrecReal > LogValue
const auto & get_psiMinv() const
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
typename SPOSet::OffloadMWVGLArray OffloadMWVGLArray
std::vector< std::reference_wrapper< T > > RefVector
void registerTWFFastDerivWrapper(const ParticleSet &P, TWFFastDerivWrapper &twf) const override
Register the component with the TWFFastDerivWrapper wrapper.
class defining a compute and memory resource to compute matrix inversion and the log determinants of ...
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 > psiM_host
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...
void acceptMove(ParticleSet &P, int iat, bool safe_to_delay=false) override
move was accepted, update the real container
QMCTraits::ComplexType ComplexType
OrbitalSetTraits< ValueType >::HessVector HessVector
Matrix< Grad > grad_lapl_source_psiM
std::complex< double > LogValue
void completeUpdates() override
complete any left over determinant matrix updates.
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< WaveFunctionComponent > &wfc_list) const override
return a shared resource to a collection
typename WFT::FullPrecValue FullPrecValue
Tensor< Value, OHMMS_DIM > Hess
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
LogValue updateBuffer(ParticleSet &P, WFBufferType &buf, bool fromscratch=false) override
For particle-by-particle move.
void evaluateDerivatives(ParticleSet &P, const opt_variables_type &active, Vector< Value > &dlogpsi, Vector< Value > &dhpsioverpsi) override
ResourceHandle< DiracDeterminantBatchedMultiWalkerResource > mw_res_handle_
void resize(int nel, int morb)
reset the size: with the number of particles and number of orbtials
DiracDeterminantBatched(std::unique_ptr< SPOSet > &&spos, int first, int last, int ndelay=1, DetMatInvertor matrix_inverter_kind=DetMatInvertor::ACCEL)
constructor
std::unique_ptr< DiracDeterminantBase > makeCopy(std::unique_ptr< SPOSet > &&spo) const override
cloning function
DualMatrix< Value > psiMinv_
PsiValue curRatio
psi(r')/psi(r) during a PbyP move
void evaluateRatiosAlltoOne(ParticleSet &P, std::vector< Value > &ratios) override
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.
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
void registerData(ParticleSet &P, WFBufferType &buf) override
For particle-by-particle move.
Matrix< Value > d2psiM
d2psiM(i,j) . partial memory view of psiM_vgl
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
ResourceHandle< DetInverter > accel_inverter_
matrix inversion engine this a crowd scope resource and only the leader engine gets it ...
PsiValue ratio(ParticleSet &P, int iat) override
return the ratio only for the iat-th partcle move