18 #ifndef QMCPLUSPLUS_SPLINE_C2C_OMPTARGET_H 19 #define QMCPLUSPLUS_SPLINE_C2C_OMPTARGET_H 24 #include "spline2/MultiBspline.hpp" 44 using SplineType =
typename bspline_traits<ST, 3>::SplineType;
45 using BCType =
typename bspline_traits<ST, 3>::BCType;
76 std::shared_ptr<OffloadVector<ST>>
mKK;
77 std::shared_ptr<OffloadPosVector<ST>>
myKcart;
119 virtual std::string
getClassName()
const override {
return "SplineC2COMPTarget"; }
120 virtual std::string
getKeyword()
const override {
return "SplineC2C"; }
143 std::unique_ptr<SPOSet>
makeClone()
const override {
return std::make_unique<SplineC2COMPTarget>(*this); }
148 size_t npad = getAlignedSize<ST>(2 *
n);
162 const int Nbands =
kPoints.size();
163 const int Nbandgroups =
comm->
size();
164 offset.resize(Nbandgroups + 1, 0);
167 for (
size_t ib = 0; ib <
offset.size(); ib++)
172 template<
typename GT,
typename BCT>
179 app_log() <<
"MEMORY " <<
SplineInst->sizeInByte() / (1 << 20) <<
" MB allocated " 180 <<
"for the coefficients in 3D spline orbital representation" << std::endl;
187 auto* MultiSpline =
SplineInst->getSplinePtr();
188 auto* restrict coefs = MultiSpline->coefs;
190 PRAGMA_OFFLOAD(
"omp target map(always, to: MultiSpline[0:1], coefs[0:MultiSpline->coefs_size])")
192 MultiSpline->coefs = coefs;
196 auto* mKK_ptr =
mKK->data();
197 PRAGMA_OFFLOAD(
"omp target update to(mKK_ptr[0:mKK->size()])")
198 auto* myKcart_ptr =
myKcart->data();
199 PRAGMA_OFFLOAD(
"omp target update to(myKcart_ptr[0:myKcart->capacity()*3])")
200 for (uint32_t i = 0; i < 9; i++)
202 (*GGt_offload)[i] =
GGt[i];
206 PRAGMA_OFFLOAD(
"omp target update to(PrimLattice_G_ptr[0:9])")
208 PRAGMA_OFFLOAD(
"omp target update to(GGt_ptr[0:9])")
216 const size_t nk =
kPoints.size();
217 mKK = std::make_shared<OffloadVector<ST>>(nk);
218 myKcart = std::make_shared<OffloadPosVector<ST>>(nk);
219 for (
size_t i = 0; i < nk; ++i)
239 std::vector<ValueType>& ratios)
override;
244 const std::vector<const ValueType*>& invRow_ptr_list,
245 std::vector<std::vector<ValueType>>& ratios_list)
const override;
267 const std::vector<const ValueType*>& invRow_ptr_list,
269 std::vector<ValueType>& ratios,
270 std::vector<GradType>& grads)
const override;
291 int last = -1)
const;
307 template<
class BSPLINESPO>
void resize(size_type n, Type_t val=Type_t())
Resize the container.
OrbitalSetTraits< ValueType >::HessVector HessVector
void create_spline(GT &xyz_g, BCT &xyz_bc)
virtual void evaluateVGL(const ParticleSet &P, const int iat, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi) override
evaluate the values, gradients and laplacians of this single-particle orbital set ...
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
void takebackResource(ResourceHandle< RS > &res_handle)
helper functions for EinsplineSetBuilder
BsplineSet is the base class for SplineC2C, SplineC2R, SplineR2R.
virtual void evaluateValue(const ParticleSet &P, const int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
void gather_tables(Communicate *comm)
ResourceHandle< SplineOMPTargetMultiWalkerMem< ST, ComplexT > > mw_mem_handle_
ResourceHandle manages the temporary resource referenced from a collection.
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
Soa Container for D-dim vectors.
Matrix< ComplexT, OffloadPinnedAllocator< ComplexT > > ratios_private
team private ratios for reduction, numVP x numTeams
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
virtual std::string getClassName() const override
return class name
bool write_splines(hdf_archive &h5f)
Timer accumulates time and call counts.
Tensor_t G
Reciprocal unit vectors. G(j,i) i=vector and j=x,y,z.
void resizeStorage(size_t n, size_t nvals)
virtual void evaluateVGH(const ParticleSet &P, const int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi) override
evaluate the values, gradients and hessians of this single-particle orbital set
OrbitalSetTraits< ValueType >::ValueVector ValueVector
int size() const
return the number of tasks
class to match std::complex<ST> spline with BsplineSet::ValueType (complex) SPOs with OpenMP offload ...
std::shared_ptr< MultiBspline< ST, OffloadAllocator< ST >, OffloadAllocator< SplineType > > > SplineInst
multi bspline set
void FairDivideLow(int ntot, int npart, IV &adist)
partition ntot elements among npart
virtual void mw_evaluateVGLandDetRatioGrads(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const std::vector< const ValueType *> &invRow_ptr_list, OffloadMWVGLArray &phi_vgl_v, std::vector< ValueType > &ratios, std::vector< GradType > &grads) const override
evaluate the values, gradients and laplacians of this single-particle orbital sets and determinant ra...
void evaluateVGLMultiPos(const Vector< ST, OffloadPinnedAllocator< ST >> &multi_pos_copy, Vector< ST, OffloadPinnedAllocator< ST >> &offload_scratch, Vector< ComplexT, OffloadPinnedAllocator< ComplexT >> &results_scratch, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list) const
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Wrapping information on parallelism.
Each SplineC2X needs a reader derived from BsplineReader.
Specialized paritlce class for atomistic simulations.
General SplineSetReader to handle any unitcell.
std::shared_ptr< OffloadVector< ST > > PrimLattice_G_offload
std::vector< int > offset
band offsets used for communication
typename bspline_traits< ST, 3 >::SplineType SplineType
A collection of functions for dividing fairly.
size_type size() const
return the current size
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
SplineC2COMPTarget(const std::string &my_name)
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to collection
QTBase::ValueType ValueType
std::shared_ptr< OffloadVector< ST > > GGt_offload
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
return a shared resource to collection
Vector< ComplexT, OffloadPinnedAllocator< ComplexT > > psiinv_pos_copy
psiinv and position scratch space, used to avoid allocation on the fly and faster transfer ...
std::shared_ptr< OffloadVector< ST > > mKK
OrbitalSetTraits< ValueType >::ValueVector ValueVector
virtual void mw_evaluateDetRatios(const RefVectorWithLeader< SPOSet > &spo_list, const RefVectorWithLeader< const VirtualParticleSet > &vp_list, const RefVector< ValueVector > &psi_list, const std::vector< const ValueType *> &invRow_ptr_list, std::vector< std::vector< ValueType >> &ratios_list) const override
evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP, of multiple walkers ...
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
void assign_vgh(const PointType &r, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, int first, int last) const
BsplineSet is a SPOSet derived class and serves as a base class for B-spline SPO C2C/C2R/R2R implemen...
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
acquire a shared resource from collection
void assign_vghgh(const PointType &r, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, GGGVector &grad_grad_grad_psi, int first=0, int last=-1) const
OMPallocator is an allocator with fused device and dualspace allocator functionality.
Vector< ST, aligned_allocator< ST > > vContainer_type
typename BsplineSet::ValueType ComplexT
CrystalLattice< ST, 3 > PrimLattice
primitive cell
void assign_v(const PointType &r, const vContainer_type &myV, ValueVector &psi, int first, int last) const
virtual bool isOMPoffload() const override
Query if this SPOSet uses OpenMP offload.
virtual void evaluate_notranspose(const ParticleSet &P, int first, int last, ValueMatrix &logdet, GradMatrix &dlogdet, ValueMatrix &d2logdet) override
evaluate the values, gradients and laplacians of this single-particle orbital for [first...
vContainer_type myV
intermediate result vectors
std::vector< std::reference_wrapper< T > > RefVector
virtual void mw_evaluateVGL(const RefVectorWithLeader< SPOSet > &sa_list, const RefVectorWithLeader< ParticleSet > &P_list, int iat, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list) const override
evaluate the values, gradients and laplacians of this single-particle orbital sets of multiple walker...
bool read_splines(hdf_archive &h5f)
bool isComplex() const override
CASTTYPE & getCastedLeader() const
std::shared_ptr< OffloadPosVector< ST > > myKcart
OrbitalSetTraits< ValueType >::GradHessVector GGGVector
OrbitalSetTraits< ValueType >::GradVector GradVector
void assign_vgl_from_l(const PointType &r, ValueVector &psi, GradVector &dpsi, ValueVector &d2psi)
assign_vgl_from_l can be used when myL is precomputed and myV,myG,myL in cartesian ...
NewTimer & offload_timer_
timer for offload portion
std::unique_ptr< SPOSet > makeClone() const override
make a clone of itself every derived class must implement this to have threading working correctly...
virtual void evaluateDetRatios(const VirtualParticleSet &VP, ValueVector &psi, const ValueVector &psiinv, std::vector< ValueType > &ratios) override
evaluate determinant ratios for virtual moves, e.g., sphere move for nonlocalPP
TinyVector< ST, 3 > PointType
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
virtual void evaluateVGHGH(const ParticleSet &P, const int iat, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, GGGVector &grad_grad_grad_psi) override
evaluate the values, gradients, hessians, and grad hessians of this single-particle orbital set ...
ResourceHandle< RS > lendResource()
Vector< ST, OffloadPinnedAllocator< ST > > multi_pos_copy
position scratch space, used to avoid allocation on the fly and faster transfer
void resize(size_type n)
resize myData
Vector< ST, OffloadPinnedAllocator< ST > > offload_scratch
offload scratch space, dynamically resized to the maximal need
void resize_kpoints()
remap kPoints to pack the double copy
typename bspline_traits< ST, 3 >::BCType BCType
void gatherv(T *sb, T *rb, int n, IT &counts, IT &displ, int dest)
Tensor< ST, 3 > GGt
, transformation for tensor in LatticeUnit to CartesianUnit, e.g. Hessian
void set_spline(SingleSplineType *spline_r, SingleSplineType *spline_i, int twist, int ispline, int level)
void finalizeConstruction() override
this routine can not be called from threaded region
Vector< ComplexT, OffloadPinnedAllocator< ComplexT > > results_scratch
result scratch space, dynamically resized to the maximal need
void bcast_tables(Communicate *comm)
std::vector< SPOSet::PosType > kPoints
kpoints for each unique orbitals.
UBspline_3d_d SingleSplineType
virtual std::string getKeyword() const override