@@ -47,6 +47,14 @@ DiracDeterminant<PL, VT, FPVT>::DiracDeterminant(std::unique_ptr<SPOSet>&& spos,
4747 rot_spo->buildOptVariables (NumPtcls);
4848}
4949
50+ template <PlatformKind PL, typename VT, typename FPVT>
51+ DiracDeterminant<PL, VT, FPVT>::~DiracDeterminant ()
52+ {
53+ if (!psiM.isAttached ())
54+ accel_engine_.update_eng_ .releaseFromDeviceCopy (psiM);
55+ accel_engine_.update_eng_ .releaseFromDeviceCopy (psiM_temp);
56+ }
57+
5058template <PlatformKind PL, typename VT, typename FPVT>
5159void DiracDeterminant<PL, VT, FPVT>::invertPsiM(const ValueMatrix& logdetT, ValueMatrix& invMat)
5260{
@@ -115,6 +123,10 @@ void DiracDeterminant<PL, VT, FPVT>::resize(int nel, int morb)
115123 int norb = morb;
116124 if (norb <= 0 )
117125 norb = nel; // for morb == -1 (default)
126+
127+ accel_engine_.update_eng_ .releaseFromDeviceCopy (psiM);
128+ accel_engine_.update_eng_ .releaseFromDeviceCopy (psiM_temp);
129+
118130 accel_engine_.update_eng_ .resize (norb, ndelay_);
119131 psiM.resize (nel, norb);
120132 dpsiM.resize (nel, norb);
@@ -123,6 +135,9 @@ void DiracDeterminant<PL, VT, FPVT>::resize(int nel, int morb)
123135 invRow.resize (norb);
124136 psiM_temp.resize (nel, norb);
125137
138+ accel_engine_.update_eng_ .prepareForDeviceCopy (psiM);
139+ accel_engine_.update_eng_ .prepareForDeviceCopy (psiM_temp);
140+
126141 dpsiV.resize (NumOrbitals);
127142 dspin_psiV.resize (NumOrbitals);
128143 d2psiV.resize (NumOrbitals);
@@ -345,6 +360,7 @@ void DiracDeterminant<PL, VT, FPVT>::registerData(ParticleSet& P, WFBufferType&
345360 buf.add (d2psiM.first_address (), d2psiM.last_address ());
346361 Bytes_in_WFBuffer = buf.current () - Bytes_in_WFBuffer;
347362 // free local space
363+ accel_engine_.update_eng_ .releaseFromDeviceCopy (psiM);
348364 psiM.free ();
349365 dpsiM.free ();
350366 d2psiM.free ();
0 commit comments