diff --git a/src/Containers/OhmmsSoA/VectorSoaContainer.h b/src/Containers/OhmmsSoA/VectorSoaContainer.h index 40f0021139..86aad416c5 100644 --- a/src/Containers/OhmmsSoA/VectorSoaContainer.h +++ b/src/Containers/OhmmsSoA/VectorSoaContainer.h @@ -62,7 +62,8 @@ struct VectorSoaContainer { if (myData != in.myData) { - resize(in.nLocal); + if (nLocal != in.nLocal) + resize(in.nLocal); std::copy_n(in.myData, nGhosts * D, myData); } return *this; diff --git a/src/QMCWaveFunctions/Jastrow/J2OMPTarget.cpp b/src/QMCWaveFunctions/Jastrow/J2OMPTarget.cpp index 61fad92901..1ca950b601 100644 --- a/src/QMCWaveFunctions/Jastrow/J2OMPTarget.cpp +++ b/src/QMCWaveFunctions/Jastrow/J2OMPTarget.cpp @@ -69,12 +69,23 @@ void J2OMPTarget::acquireResource(ResourceCollection& collection, mw_allUat.resize(N_padded * (DIM + 2) * nw); for (size_t iw = 0; iw < nw; iw++) { - size_t offset = N_padded * (DIM + 2) * iw; - auto& wfc = wfc_list.getCastedElement>(iw); + // copy per walker Uat, dUat, d2Uat to shared buffer and attach buffer + auto& wfc = wfc_list.getCastedElement>(iw); + + Vector> Uat_view(mw_allUat.data() + iw * N_padded, N); + Uat_view = wfc.Uat; wfc.Uat.free(); wfc.Uat.attachReference(mw_allUat.data() + iw * N_padded, N); + + VectorSoaContainer> dUat_view(mw_allUat.data() + nw * N_padded + + iw * N_padded * DIM, + N, N_padded); + dUat_view = wfc.dUat; wfc.dUat.free(); wfc.dUat.attachReference(N, N_padded, mw_allUat.data() + nw * N_padded + iw * N_padded * DIM); + + Vector> d2Uat_view(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N); + d2Uat_view = wfc.d2Uat; wfc.d2Uat.free(); wfc.d2Uat.attachReference(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N); } @@ -86,14 +97,31 @@ void J2OMPTarget::releaseResource(ResourceCollection& collection, const RefVectorWithLeader& wfc_list) const { auto& wfc_leader = wfc_list.getCastedLeader>(); - collection.takebackResource(std::move(wfc_leader.mw_mem_)); - for (size_t iw = 0; iw < wfc_list.size(); iw++) + const size_t nw = wfc_list.size(); + auto& mw_allUat = wfc_leader.mw_mem_->mw_allUat; + for (size_t iw = 0; iw < nw; iw++) { + // detach buffer and copy per walker Uat, dUat, d2Uat from shared buffer auto& wfc = wfc_list.getCastedElement>(iw); + + Vector> Uat_view(mw_allUat.data() + iw * N_padded, N); wfc.Uat.free(); + wfc.Uat.resize(N); + wfc.Uat = Uat_view; + + VectorSoaContainer> dUat_view(mw_allUat.data() + nw * N_padded + + iw * N_padded * DIM, + N, N_padded); wfc.dUat.free(); + wfc.dUat.resize(N); + wfc.dUat = dUat_view; + + Vector> d2Uat_view(mw_allUat.data() + nw * N_padded * (DIM + 1) + iw * N_padded, N); wfc.d2Uat.free(); + wfc.d2Uat.resize(N); + wfc.d2Uat = d2Uat_view; } + collection.takebackResource(std::move(wfc_leader.mw_mem_)); } template @@ -674,7 +702,8 @@ void J2OMPTarget::mw_recompute(const RefVectorWithLeadermw_allUat.updateTo(); } @@ -738,7 +767,7 @@ void J2OMPTarget::mw_evaluateGL(const RefVectorWithLeader>(iw); + auto& wfc = wfc_list.getCastedElement>(iw); wfc.log_value_ = wfc.computeGL(G_list[iw], L_list[iw]); } }