Skip to content

Commit

Permalink
Merged in mixingPerfFix (pull request #550)
Browse files Browse the repository at this point in the history
Quadrature mixing performance fix

Approved-by: Sambit Das
Approved-by: Phani Motamarri
  • Loading branch information
knikhil1995 authored and dsambit committed Dec 20, 2023
2 parents 9e8bf2d + af310a9 commit 0e1e8f5
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions src/dft/dft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4831,11 +4831,9 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
rhoValuesVector[iElem * numQuadPoints + iQuad] =
(*rhoValues)[cell->id()][iQuad];
}
std::memcpy(rhoValuesVector.data() + iElem * numQuadPoints,
(*rhoValues)[cell->id()].data(),
numQuadPoints * sizeof(double));
iElem++;
}
}
Expand Down Expand Up @@ -4871,11 +4869,9 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
(*rhoValues)[cell->id()][iQuad] =
rhoValuesVector[iElem * numQuadPoints + iQuad];
}
std::memcpy((*rhoValues)[cell->id()].data(),
rhoValuesVector.data() + iElem * numQuadPoints,
numQuadPoints * sizeof(double));
iElem++;
}
}
Expand Down Expand Up @@ -4915,11 +4911,9 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
gradRhoValuesVector[iElem * numQuadPoints + iQuad] =
(*gradRhoValues)[cell->id()][iQuad];
}
std::memcpy(gradRhoValuesVector.data() + iElem * numQuadPoints,
(*gradRhoValues)[cell->id()].data(),
numQuadPoints * sizeof(double));
iElem++;
}
}
Expand Down Expand Up @@ -4956,11 +4950,9 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
(*gradRhoValues)[cell->id()][iQuad] =
gradRhoValuesVector[iElem * numQuadPoints + iQuad];
}
std::memcpy((*gradRhoValues)[cell->id()].data(),
gradRhoValuesVector.data() + iElem * numQuadPoints,
numQuadPoints * sizeof(double));
iElem++;
}
}
Expand Down Expand Up @@ -4992,11 +4984,11 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
auto rho = (*rhoValues)[cell->id()];
auto rhoSpin = (*rhoSpinValues)[cell->id()];
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
(*rhoValues)[cell->id()][iQuad] =
(*rhoSpinValues)[cell->id()][2 * iQuad + 0] +
(*rhoSpinValues)[cell->id()][2 * iQuad + 1];
rho[iQuad] = rhoSpin[2 * iQuad + 0] + rhoSpin[2 * iQuad + 1];
}
iElem++;
}
Expand Down Expand Up @@ -5030,17 +5022,16 @@ namespace dftfe
{
if (cell->is_locally_owned())
{
auto gradRho = (*gradRhoValues)[cell->id()];
auto gradRhoSpin = (*gradRhoSpinValues)[cell->id()];
for (unsigned int iQuad = 0; iQuad < numQuadPoints; iQuad++)
{
((*gradRhoValues)[cell->id()][3 * iQuad + 0]) =
((*gradRhoSpinValues)[cell->id()][6 * iQuad + 0]) +
((*gradRhoSpinValues)[cell->id()][6 * iQuad + 3]);
((*gradRhoValues)[cell->id()][3 * iQuad + 1]) =
((*gradRhoSpinValues)[cell->id()][6 * iQuad + 1]) +
((*gradRhoInValuesSpinPolarized)[cell->id()][6 * iQuad + 4]);
((*gradRhoValues)[cell->id()][3 * iQuad + 2]) =
((*gradRhoSpinValues)[cell->id()][6 * iQuad + 2]) +
((*gradRhoSpinValues)[cell->id()][6 * iQuad + 5]);
gradRho[3 * iQuad + 0] =
(gradRhoSpin[6 * iQuad + 0]) + (gradRhoSpin[6 * iQuad + 3]);
gradRho[3 * iQuad + 1] =
(gradRhoSpin[6 * iQuad + 1]) + (gradRhoSpin[6 * iQuad + 4]);
gradRho[3 * iQuad + 2] =
(gradRhoSpin[6 * iQuad + 2]) + (gradRhoSpin[6 * iQuad + 5]);
}
iElem++;
}
Expand Down

0 comments on commit 0e1e8f5

Please sign in to comment.