Skip to content

Commit

Permalink
fix failing build?
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Hahn <[email protected]>
  • Loading branch information
quantumsteve committed Sep 15, 2023
1 parent 2898d5f commit 04db7cc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 59 deletions.
68 changes: 34 additions & 34 deletions src/QMCWaveFunctions/BsplineFactory/SplineC2RT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@


#include "Concurrency/OpenMP.h"
#include "SplineC2R.h"
#include "SplineC2RT.h"
#include "spline2/MultiBsplineEval.hpp"
#include "QMCWaveFunctions/BsplineFactory/contraction_helper.hpp"
#include "CPU/math.hpp"

namespace qmcplusplus
{
template<typename ST>
SplineC2R<ST>::SplineC2R(const SplineC2R& in) = default;
SplineC2RT<ST>::SplineC2RT(const SplineC2RT& in) = default;

template<typename ST>
inline void SplineC2R<ST>::set_spline(SingleSplineType* spline_r,
inline void SplineC2RT<ST>::set_spline(SingleSplineType* spline_r,
SingleSplineType* spline_i,
int twist,
int ispline,
Expand All @@ -37,39 +37,39 @@ inline void SplineC2R<ST>::set_spline(SingleSplineType* spline_r,
}

template<typename ST>
bool SplineC2R<ST>::read_splines(hdf_archive& h5f)
bool SplineC2RT<ST>::read_splines(hdf_archive& h5f)
{
std::ostringstream o;
o << "spline_" << MyIndex;
o << "spline_" << this->MyIndex;
einspline_engine<SplineType> bigtable(SplineInst->getSplinePtr());
return h5f.readEntry(bigtable, o.str().c_str()); //"spline_0");
}

template<typename ST>
bool SplineC2R<ST>::write_splines(hdf_archive& h5f)
bool SplineC2RT<ST>::write_splines(hdf_archive& h5f)
{
std::ostringstream o;
o << "spline_" << MyIndex;
o << "spline_" << this->MyIndex;
einspline_engine<SplineType> bigtable(SplineInst->getSplinePtr());
return h5f.writeEntry(bigtable, o.str().c_str()); //"spline_0");
}

template<typename ST>
inline void SplineC2R<ST>::assign_v(const PointType& r,
inline void SplineC2RT<ST>::assign_v(const PointType& r,
const vContainer_type& myV,
ValueVector& psi,
int first,
int last) const
{
// protect last
last = last > kPoints.size() ? kPoints.size() : last;
last = last > this->kPoints.size() ? this->kPoints.size() : last;

const ST x = r[0], y = r[1], z = r[2];
const ST* restrict kx = myKcart.data(0);
const ST* restrict ky = myKcart.data(1);
const ST* restrict kz = myKcart.data(2);

TT* restrict psi_s = psi.data() + first_spo;
TT* restrict psi_s = psi.data() + this->first_spo;
const size_t requested_orb_size = psi.size();
#pragma omp simd
for (size_t j = first; j < std::min(nComplexBands, last); j++)
Expand Down Expand Up @@ -100,7 +100,7 @@ inline void SplineC2R<ST>::assign_v(const PointType& r,
}

template<typename ST>
void SplineC2R<ST>::evaluateValue(const ParticleSet& P, const int iat, ValueVector& psi)
void SplineC2RT<ST>::evaluateValue(const ParticleSet& P, const int iat, ValueVector& psi)
{
const PointType& r = P.activeR(iat);
PointType ru(PrimLattice.toUnit_floor(r));
Expand All @@ -116,7 +116,7 @@ void SplineC2R<ST>::evaluateValue(const ParticleSet& P, const int iat, ValueVect
}

template<typename ST>
void SplineC2R<ST>::evaluateDetRatios(const VirtualParticleSet& VP,
void SplineC2RT<ST>::evaluateDetRatios(const VirtualParticleSet& VP,
ValueVector& psi,
const ValueVector& psiinv,
std::vector<TT>& ratios)
Expand All @@ -136,7 +136,7 @@ void SplineC2R<ST>::evaluateDetRatios(const VirtualParticleSet& VP,
int first, last;
FairDivideAligned(myV.size(), getAlignment<ST>(), omp_get_num_threads(), tid, first, last);
const int first_cplx = first / 2;
const int last_cplx = kPoints.size() < last / 2 ? kPoints.size() : last / 2;
const int last_cplx = this->kPoints.size() < last / 2 ? this->kPoints.size() : last / 2;

for (int iat = 0; iat < VP.getTotalNum(); ++iat)
{
Expand Down Expand Up @@ -164,15 +164,15 @@ void SplineC2R<ST>::evaluateDetRatios(const VirtualParticleSet& VP,
/** assign_vgl
*/
template<typename ST>
inline void SplineC2R<ST>::assign_vgl(const PointType& r,
inline void SplineC2RT<ST>::assign_vgl(const PointType& r,
ValueVector& psi,
GradVector& dpsi,
ValueVector& d2psi,
int first,
int last) const
{
// protect last
last = last > kPoints.size() ? kPoints.size() : last;
last = last > this->kPoints.size() ? this->kPoints.size() : last;

constexpr ST two(2);
const ST g00 = PrimLattice.G(0), g01 = PrimLattice.G(1), g02 = PrimLattice.G(2), g10 = PrimLattice.G(3),
Expand Down Expand Up @@ -246,7 +246,7 @@ inline void SplineC2R<ST>::assign_vgl(const PointType& r,
const ST lap_r = lcart_r + mKK[j] * val_r + two * (kX * dX_i + kY * dY_i + kZ * dZ_i);
const ST lap_i = lcart_i + mKK[j] * val_i - two * (kX * dX_r + kY * dY_r + kZ * dZ_r);

const size_t psiIndex = first_spo + jr;
const size_t psiIndex = this->first_spo + jr;
if (psiIndex < requested_orb_size)
{
psi[psiIndex] = c * val_r - s * val_i;
Expand Down Expand Up @@ -298,7 +298,7 @@ inline void SplineC2R<ST>::assign_vgl(const PointType& r,
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;

if (const size_t psiIndex = first_spo + nComplexBands + j; psiIndex < requested_orb_size)
if (const size_t psiIndex = this->first_spo + nComplexBands + j; psiIndex < requested_orb_size)
{
psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
Expand All @@ -317,7 +317,7 @@ inline void SplineC2R<ST>::assign_vgl(const PointType& r,
/** assign_vgl_from_l can be used when myL is precomputed and myV,myG,myL in cartesian
*/
template<typename ST>
inline void SplineC2R<ST>::assign_vgl_from_l(const PointType& r, ValueVector& psi, GradVector& dpsi, ValueVector& d2psi)
inline void SplineC2RT<ST>::assign_vgl_from_l(const PointType& r, ValueVector& psi, GradVector& dpsi, ValueVector& d2psi)
{
constexpr ST two(2);
const ST x = r[0], y = r[1], z = r[2];
Expand All @@ -336,7 +336,7 @@ inline void SplineC2R<ST>::assign_vgl_from_l(const PointType& r, ValueVector& ps
const ST* restrict g2 = myG.data(2);
ASSUME_ALIGNED(g2);

const size_t N = kPoints.size();
const size_t N = this->kPoints.size();

#pragma omp simd
for (size_t j = 0; j < nComplexBands; j++)
Expand Down Expand Up @@ -374,7 +374,7 @@ inline void SplineC2R<ST>::assign_vgl_from_l(const PointType& r, ValueVector& ps
const ST lap_r = myL[jr] + mKK[j] * val_r + two * (kX * dX_i + kY * dY_i + kZ * dZ_i);
const ST lap_i = myL[ji] + mKK[j] * val_i - two * (kX * dX_r + kY * dY_r + kZ * dZ_r);

const size_t psiIndex = first_spo + jr;
const size_t psiIndex = this->first_spo + jr;
psi[psiIndex] = c * val_r - s * val_i;
psi[psiIndex + 1] = c * val_i + s * val_r;
d2psi[psiIndex] = c * lap_r - s * lap_i;
Expand Down Expand Up @@ -419,7 +419,7 @@ inline void SplineC2R<ST>::assign_vgl_from_l(const PointType& r, ValueVector& ps
const ST gX_i = dX_i - val_r * kX;
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;
const size_t psiIndex = first_spo + nComplexBands + j;
const size_t psiIndex = this->first_spo + nComplexBands + j;
psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
dpsi[psiIndex][1] = c * gY_r - s * gY_i;
Expand All @@ -432,7 +432,7 @@ inline void SplineC2R<ST>::assign_vgl_from_l(const PointType& r, ValueVector& ps
}

template<typename ST>
void SplineC2R<ST>::evaluateVGL(const ParticleSet& P,
void SplineC2RT<ST>::evaluateVGL(const ParticleSet& P,
const int iat,
ValueVector& psi,
GradVector& dpsi,
Expand All @@ -452,15 +452,15 @@ void SplineC2R<ST>::evaluateVGL(const ParticleSet& P,
}

template<typename ST>
void SplineC2R<ST>::assign_vgh(const PointType& r,
void SplineC2RT<ST>::assign_vgh(const PointType& r,
ValueVector& psi,
GradVector& dpsi,
HessVector& grad_grad_psi,
int first,
int last) const
{
// protect last
last = last > kPoints.size() ? kPoints.size() : last;
last = last > this->kPoints.size() ? this->kPoints.size() : last;

const ST g00 = PrimLattice.G(0), g01 = PrimLattice.G(1), g02 = PrimLattice.G(2), g10 = PrimLattice.G(3),
g11 = PrimLattice.G(4), g12 = PrimLattice.G(5), g20 = PrimLattice.G(6), g21 = PrimLattice.G(7),
Expand Down Expand Up @@ -514,7 +514,7 @@ void SplineC2R<ST>::assign_vgh(const PointType& r,
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;

const size_t psiIndex = first_spo + jr;
const size_t psiIndex = this->first_spo + jr;

psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
Expand Down Expand Up @@ -618,7 +618,7 @@ void SplineC2R<ST>::assign_vgh(const PointType& r,
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;

const size_t psiIndex = first_spo + nComplexBands + j;
const size_t psiIndex = this->first_spo + nComplexBands + j;

psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
Expand Down Expand Up @@ -676,7 +676,7 @@ void SplineC2R<ST>::assign_vgh(const PointType& r,
}

template<typename ST>
void SplineC2R<ST>::evaluateVGH(const ParticleSet& P,
void SplineC2RT<ST>::evaluateVGH(const ParticleSet& P,
const int iat,
ValueVector& psi,
GradVector& dpsi,
Expand All @@ -695,7 +695,7 @@ void SplineC2R<ST>::evaluateVGH(const ParticleSet& P,
}

template<typename ST>
void SplineC2R<ST>::assign_vghgh(const PointType& r,
void SplineC2RT<ST>::assign_vghgh(const PointType& r,
ValueVector& psi,
GradVector& dpsi,
HessVector& grad_grad_psi,
Expand All @@ -704,7 +704,7 @@ void SplineC2R<ST>::assign_vghgh(const PointType& r,
int last) const
{
// protect last
last = last < 0 ? kPoints.size() : (last > kPoints.size() ? kPoints.size() : last);
last = last < 0 ? this->kPoints.size() : (last > this->kPoints.size() ? this->kPoints.size() : last);

const ST g00 = PrimLattice.G(0), g01 = PrimLattice.G(1), g02 = PrimLattice.G(2), g10 = PrimLattice.G(3),
g11 = PrimLattice.G(4), g12 = PrimLattice.G(5), g20 = PrimLattice.G(6), g21 = PrimLattice.G(7),
Expand Down Expand Up @@ -770,7 +770,7 @@ void SplineC2R<ST>::assign_vghgh(const PointType& r,
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;

const size_t psiIndex = first_spo + jr;
const size_t psiIndex = this->first_spo + jr;
psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
dpsi[psiIndex][1] = c * gY_r - s * gY_i;
Expand Down Expand Up @@ -1004,7 +1004,7 @@ void SplineC2R<ST>::assign_vghgh(const PointType& r,
const ST gY_i = dY_i - val_r * kY;
const ST gZ_i = dZ_i - val_r * kZ;

const size_t psiIndex = first_spo + nComplexBands + j;
const size_t psiIndex = this->first_spo + nComplexBands + j;
psi[psiIndex] = c * val_r - s * val_i;
dpsi[psiIndex][0] = c * gX_r - s * gX_i;
dpsi[psiIndex][1] = c * gY_r - s * gY_i;
Expand Down Expand Up @@ -1163,7 +1163,7 @@ void SplineC2R<ST>::assign_vghgh(const PointType& r,
}

template<typename ST>
void SplineC2R<ST>::evaluateVGHGH(const ParticleSet& P,
void SplineC2RT<ST>::evaluateVGHGH(const ParticleSet& P,
const int iat,
ValueVector& psi,
GradVector& dpsi,
Expand All @@ -1182,7 +1182,7 @@ void SplineC2R<ST>::evaluateVGHGH(const ParticleSet& P,
}
}

template class SplineC2R<float>;
template class SplineC2R<double>;
template class SplineC2RT<float>;
template class SplineC2RT<double>;

} // namespace qmcplusplus
48 changes: 23 additions & 25 deletions src/QMCWaveFunctions/BsplineFactory/SplineC2RT.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*
* class to handle complex splines to real orbitals with splines of arbitrary precision
*/
#ifndef QMCPLUSPLUS_SPLINE_C2R_H
#define QMCPLUSPLUS_SPLINE_C2R_H
#ifndef QMCPLUSPLUS_SPLINE_C2RT_H
#define QMCPLUSPLUS_SPLINE_C2RT_H

#include <memory>
#include "QMCWaveFunctions/BsplineFactory/BsplineSet.h"
#include "QMCWaveFunctions/BsplineFactory/BsplineSetT.h"
#include "OhmmsSoA/VectorSoaContainer.h"
#include "spline2/MultiBspline.hpp"
#include "Utilities/FairDivide.h"
Expand All @@ -39,7 +39,7 @@ namespace qmcplusplus
* All the output orbitals are real (C2R). The maximal number of output orbitals is OrbitalSetSize.
*/
template<typename ST>
class SplineC2R : public BsplineSet
class SplineC2RT : public BsplineSetT<ST>
{
public:
using SplineType = typename bspline_traits<ST, 3>::SplineType;
Expand All @@ -48,15 +48,16 @@ class SplineC2R : public BsplineSet
using PointType = TinyVector<ST, 3>;
using SingleSplineType = UBspline_3d_d;
// types for evaluation results
using TT = typename BsplineSet::ValueType;
using BsplineSet::GGGVector;
using BsplineSet::GradVector;
using BsplineSet::HessVector;
using BsplineSet::ValueVector;
using TT = typename BsplineSetT<ST>::ValueType;
using ValueVector = typename BsplineSetT<ST>::ValueVector;
using GGGVector = typename BsplineSetT<ST>::GGGVector;
using GradVector = typename BsplineSetT<ST>::GradVector;
using HessVector = typename BsplineSetT<ST>::HessVector;

using vContainer_type = Vector<ST, aligned_allocator<ST>>;
using gContainer_type = VectorSoaContainer<ST, 3>;
using hContainer_type = VectorSoaContainer<ST, 6>;

using ghContainer_type = VectorSoaContainer<ST, 10>;

private:
Expand Down Expand Up @@ -84,18 +85,18 @@ class SplineC2R : public BsplineSet
ghContainer_type mygH;

public:
SplineC2R(const std::string& my_name) : BsplineSet(my_name), nComplexBands(0) {}
SplineC2RT(const std::string& my_name) : BsplineSetT<ST>(my_name), nComplexBands(0) {}

SplineC2R(const SplineC2R& in);
SplineC2RT(const SplineC2RT& in);
virtual std::string getClassName() const override { return "SplineC2R"; }
virtual std::string getKeyword() const override { return "SplineC2R"; }
bool isComplex() const override { return true; };

std::unique_ptr<SPOSet> makeClone() const override { return std::make_unique<SplineC2R>(*this); }
std::unique_ptr<SPOSetT<ST>> makeClone() const override { return std::make_unique<SplineC2RT<ST>>(*this); }

inline void resizeStorage(size_t n, size_t nvals)
{
init_base(n);
this->init_base(n);
size_t npad = getAlignedSize<ST>(2 * n);
myV.resize(npad);
myG.resize(npad);
Expand All @@ -110,14 +111,14 @@ class SplineC2R : public BsplineSet
{
if (comm->size() == 1)
return;
const int Nbands = kPoints.size();
const int Nbands = this->kPoints.size();
const int Nbandgroups = comm->size();
offset.resize(Nbandgroups + 1, 0);
FairDivideLow(Nbands, Nbandgroups, offset);
this->offset.resize(Nbandgroups + 1, 0);
FairDivideLow(Nbands, Nbandgroups, this->offset);

for (size_t ib = 0; ib < offset.size(); ib++)
offset[ib] = offset[ib] * 2;
gatherv(comm, SplineInst->getSplinePtr(), SplineInst->getSplinePtr()->z_stride, offset);
for (size_t ib = 0; ib < this->offset.size(); ib++)
this->offset[ib] = this->offset[ib] * 2;
gatherv(comm, SplineInst->getSplinePtr(), SplineInst->getSplinePtr()->z_stride, this->offset);
}

template<typename GT, typename BCT>
Expand All @@ -137,13 +138,13 @@ class SplineC2R : public BsplineSet
inline void resize_kpoints()
{
nComplexBands = this->remap_kpoints();
const int nk = kPoints.size();
const int nk = this->kPoints.size();
mKK.resize(nk);
myKcart.resize(nk);
for (size_t i = 0; i < nk; ++i)
{
mKK[i] = -dot(kPoints[i], kPoints[i]);
myKcart(i) = kPoints[i];
mKK[i] = -dot(this->kPoints[i], this->kPoints[i]);
myKcart(i) = this->kPoints[i];
}
}

Expand Down Expand Up @@ -210,8 +211,5 @@ class SplineC2R : public BsplineSet
friend struct BsplineReaderBase;
};

extern template class SplineC2R<float>;
extern template class SplineC2R<double>;

} // namespace qmcplusplus
#endif

0 comments on commit 04db7cc

Please sign in to comment.