18 #ifndef QMCPLUSPLUS_SPLINE_C2R_OMPTARGET_H 19 #define QMCPLUSPLUS_SPLINE_C2R_OMPTARGET_H 24 #include "spline2/MultiBspline.hpp" 47 using SplineType =
typename bspline_traits<ST, 3>::SplineType;
48 using BCType =
typename bspline_traits<ST, 3>::BCType;
81 std::shared_ptr<OffloadVector<ST>>
mKK;
82 std::shared_ptr<OffloadPosVector<ST>>
myKcart;
125 virtual std::string
getClassName()
const override {
return "SplineC2ROMPTarget"; }
126 virtual std::string
getKeyword()
const override {
return "SplineC2R"; }
149 std::unique_ptr<SPOSet>
makeClone()
const override {
return std::make_unique<SplineC2ROMPTarget>(*this); }
154 size_t npad = getAlignedSize<ST>(2 *
n);
168 const int Nbands =
kPoints.size();
169 const int Nbandgroups =
comm->
size();
170 offset.resize(Nbandgroups + 1, 0);
173 for (
size_t ib = 0; ib <
offset.size(); ib++)
178 template<
typename GT,
typename BCT>
185 app_log() <<
"MEMORY " <<
SplineInst->sizeInByte() / (1 << 20) <<
" MB allocated " 186 <<
"for the coefficients in 3D spline orbital representation" << std::endl;
193 auto* MultiSpline =
SplineInst->getSplinePtr();
194 auto* restrict coefs = MultiSpline->coefs;
196 PRAGMA_OFFLOAD(
"omp target map(always, to: MultiSpline[0:1], coefs[0:MultiSpline->coefs_size])")
198 MultiSpline->coefs = coefs;
202 auto* mKK_ptr =
mKK->data();
203 PRAGMA_OFFLOAD(
"omp target update to(mKK_ptr[0:mKK->size()])")
204 auto* myKcart_ptr =
myKcart->data();
205 PRAGMA_OFFLOAD(
"omp target update to(myKcart_ptr[0:myKcart->capacity()*3])")
206 for (uint32_t i = 0; i < 9; i++)
208 (*GGt_offload)[i] =
GGt[i];
212 PRAGMA_OFFLOAD(
"omp target update to(PrimLattice_G_ptr[0:9])")
214 PRAGMA_OFFLOAD(
"omp target update to(GGt_ptr[0:9])")
224 mKK = std::make_shared<OffloadVector<ST>>(nk);
225 myKcart = std::make_shared<OffloadPosVector<ST>>(nk);
226 for (
size_t i = 0; i < nk; ++i)
246 std::vector<ValueType>& ratios)
override;
251 const std::vector<const ValueType*>& invRow_ptr_list,
252 std::vector<std::vector<ValueType>>& ratios_list)
const override;
274 const std::vector<const ValueType*>& invRow_ptr_list,
276 std::vector<ValueType>& ratios,
277 std::vector<GradType>& grads)
const override;
298 int last = -1)
const;
314 template<
class BSPLINESPO>
void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
acquire a shared resource from collection
void resize(size_type n, Type_t val=Type_t())
Resize the container.
OrbitalSetTraits< ValueType >::HessVector HessVector
Vector< ST, OffloadPinnedAllocator< ST > > multi_pos_copy
position scratch space, used to avoid allocation on the fly and faster transfer
Matrix< TT, OffloadPinnedAllocator< TT > > ratios_private
team private ratios for reduction, numVP x numTeams
size_t addResource(std::unique_ptr< Resource > &&res, bool noprint=false)
void takebackResource(ResourceHandle< RS > &res_handle)
Vector< ST, aligned_allocator< ST > > vContainer_type
helper functions for EinsplineSetBuilder
BsplineSet is the base class for SplineC2C, SplineC2R, SplineR2R.
std::shared_ptr< OffloadVector< ST > > PrimLattice_G_offload
std::shared_ptr< OffloadVector< ST > > GGt_offload
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...
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
Vector< TT, OffloadPinnedAllocator< TT > > results_scratch
result scratch space, dynamically resized to the maximal need
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 ...
ResourceHandle manages the temporary resource referenced from a collection.
CrystalLattice< ST, 3 > PrimLattice
primitive cell
A ParticleSet that handles virtual moves of a selected particle of a given physical ParticleSet Virtu...
Soa Container for D-dim vectors.
OrbitalSetTraits< ValueType >::ValueMatrix ValueMatrix
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
Timer accumulates time and call counts.
int nComplexBands
number of complex bands
std::shared_ptr< OffloadPosVector< ST > > myKcart
Tensor_t G
Reciprocal unit vectors. G(j,i) i=vector and j=x,y,z.
void finalizeConstruction() override
this routine can not be called from threaded region
OrbitalSetTraits< ValueType >::ValueVector ValueVector
int size() const
return the number of tasks
bool read_splines(hdf_archive &h5f)
void evaluateVGLMultiPos(const Vector< ST, OffloadPinnedAllocator< ST >> &multi_pos_copy, Vector< ST, OffloadPinnedAllocator< ST >> &offload_scratch, Vector< TT, OffloadPinnedAllocator< TT >> &results_scratch, const RefVector< ValueVector > &psi_v_list, const RefVector< GradVector > &dpsi_v_list, const RefVector< ValueVector > &d2psi_v_list) const
Tensor< ST, 3 > GGt
, transformation for tensor in LatticeUnit to CartesianUnit, e.g. Hessian
void FairDivideLow(int ntot, int npart, IV &adist)
partition ntot elements among npart
OrbitalSetTraits< ValueType >::GradMatrix GradMatrix
Wrapping information on parallelism.
void assign_vgh(const PointType &r, ValueVector &psi, GradVector &dpsi, HessVector &grad_grad_psi, int first, int last) const
void bcast_tables(Communicate *comm)
Each SplineC2X needs a reader derived from BsplineReader.
Specialized paritlce class for atomistic simulations.
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
General SplineSetReader to handle any unitcell.
void assign_v(const PointType &r, const vContainer_type &myV, ValueVector &psi, int first, int last) const
std::vector< int > offset
band offsets used for communication
vContainer_type myV
intermediate result vectors
A collection of functions for dividing fairly.
size_type size() const
return the current size
class to match std::complex<ST> spline with BsplineSet::ValueType (real) SPOs with OpenMP offload ...
Array< ValueType, 3, OffloadPinnedAllocator< ValueType > > OffloadMWVGLArray
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 write_splines(hdf_archive &h5f)
QTBase::ValueType ValueType
bool isComplex() const override
ResourceHandle< SplineOMPTargetMultiWalkerMem< ST, TT > > mw_mem_handle_
void create_spline(GT &xyz_g, BCT &xyz_bc)
OrbitalSetTraits< ValueType >::ValueVector ValueVector
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
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
std::unique_ptr< SPOSet > makeClone() const override
make a clone of itself every derived class must implement this to have threading working correctly...
typename bspline_traits< ST, 3 >::BCType BCType
virtual std::string getKeyword() const override
BsplineSet is a SPOSet derived class and serves as a base class for B-spline SPO C2C/C2R/R2R implemen...
UBspline_3d_d SingleSplineType
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 ...
std::shared_ptr< OffloadVector< ST > > mKK
OMPallocator is an allocator with fused device and dualspace allocator functionality.
Vector< ST, OffloadPinnedAllocator< ST > > offload_scratch
offload scratch space, dynamically resized to the maximal need
void createResource(ResourceCollection &collection) const override
initialize a shared resource and hand it to collection
std::vector< std::reference_wrapper< T > > RefVector
Vector< TT, OffloadPinnedAllocator< TT > > psiinv_pos_copy
psiinv and position scratch space, used to avoid allocation on the fly and faster transfer ...
CASTTYPE & getCastedLeader() const
void gather_tables(Communicate *comm)
virtual bool isOMPoffload() const override
Query if this SPOSet uses OpenMP offload.
void set_spline(SingleSplineType *spline_r, SingleSplineType *spline_i, int twist, int ispline, int level)
OrbitalSetTraits< ValueType >::GradHessVector GGGVector
OrbitalSetTraits< ValueType >::GradVector GradVector
typename BsplineSet::ValueType TT
Tensor< typename BinaryReturn< T1, T2, OpMultiply >::Type_t, D > dot(const AntiSymTensor< T1, D > &lhs, const AntiSymTensor< T2, D > &rhs)
ResourceHandle< RS > lendResource()
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...
void resize_kpoints()
remap kPoints to pack the double copy
void resize(size_type n)
resize myData
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 ...
SplineC2ROMPTarget(const std::string &my_name)
void gatherv(T *sb, T *rb, int n, IT &counts, IT &displ, int dest)
void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< SPOSet > &spo_list) const override
return a shared resource to collection
int remap_kpoints()
remap kpoints to group general kpoints & special kpoints
virtual void evaluateValue(const ParticleSet &P, const int iat, ValueVector &psi) override
evaluate the values of this single-particle orbital set
void resizeStorage(size_t n, size_t nvals)
std::shared_ptr< MultiBspline< ST, OffloadAllocator< ST >, OffloadAllocator< SplineType > > > SplineInst
multi bspline set
TinyVector< ST, 3 > PointType
typename bspline_traits< ST, 3 >::SplineType SplineType
std::vector< SPOSet::PosType > kPoints
kpoints for each unique orbitals.
virtual std::string getClassName() const override
return class name