Commit 54d9582c authored by peastman's avatar peastman
Browse files

Merge pull request #564 from peastman/master

Fixed error when running in double precision
parents 41f518e8 75f0401f
...@@ -1642,8 +1642,12 @@ bool CudaCalcAmoebaMultipoleForceKernel::iterateDipolesByDIIS(int iteration) { ...@@ -1642,8 +1642,12 @@ bool CudaCalcAmoebaMultipoleForceKernel::iterateDipolesByDIIS(int iteration) {
void* buildMatrixArgs[] = {&prevErrors->getDevicePointer(), &iteration, &diisMatrix->getDevicePointer()}; void* buildMatrixArgs[] = {&prevErrors->getDevicePointer(), &iteration, &diisMatrix->getDevicePointer()};
int threadBlocks = min(numPrev, cu.getNumThreadBlocks()); int threadBlocks = min(numPrev, cu.getNumThreadBlocks());
cu.executeKernel(buildMatrixKernel, buildMatrixArgs, threadBlocks*128, 128, 128*elementSize); cu.executeKernel(buildMatrixKernel, buildMatrixArgs, threadBlocks*128, 128, 128*elementSize);
vector<float> matrix; vector<float> matrixf;
vector<double> matrix;
if (cu.getUseDoublePrecision())
diisMatrix->download(matrix); diisMatrix->download(matrix);
else
diisMatrix->download(matrixf);
// Determine whether the iteration has converged. // Determine whether the iteration has converged.
...@@ -1666,9 +1670,16 @@ bool CudaCalcAmoebaMultipoleForceKernel::iterateDipolesByDIIS(int iteration) { ...@@ -1666,9 +1670,16 @@ bool CudaCalcAmoebaMultipoleForceKernel::iterateDipolesByDIIS(int iteration) {
b[0][0] = 0; b[0][0] = 0;
for (int i = 1; i < rank; i++) for (int i = 1; i < rank; i++)
b[i][0] = b[0][i] = -1; b[i][0] = b[0][i] = -1;
if (cu.getUseDoublePrecision()) {
for (int i = 0; i < numPrev; i++) for (int i = 0; i < numPrev; i++)
for (int j = 0; j < numPrev; j++) for (int j = 0; j < numPrev; j++)
b[i+1][j+1] = matrix[i*MaxPrevDIISDipoles+j]; b[i+1][j+1] = matrix[i*MaxPrevDIISDipoles+j];
}
else {
for (int i = 0; i < numPrev; i++)
for (int j = 0; j < numPrev; j++)
b[i+1][j+1] = matrixf[i*MaxPrevDIISDipoles+j];
}
// Solve using SVD. Since the right hand side is (-1, 0, 0, 0, ...), this is simpler than the general case. // Solve using SVD. Since the right hand side is (-1, 0, 0, 0, ...), this is simpler than the general case.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment