Skip to content

Commit 916d3bc

Browse files
authored
Fix solve_impl() mixups args and cusolverSpScsrcholBufferInfoHost() call with wrong values (#10)
* fix wrong argument order in solve_impl call solve_impl(n, x.ptr(), b.ptr()); // WRONG! The signature is solve_impl(int n, Real* b, Real* x), but x and b are swapped. This means the solver writes the solution to the wrong buffer. Should be: solve_impl(n, b.ptr(), x.ptr()); * fix Wrong buffer used for CPU float path checksolver(cusolverSpScsrcholBufferInfoHost( handle, rows, nnz, descr, device_values, hRow, hCol, ...)); This uses device_values instead of hValues (unlike the double version at line 124). This would access invalid memory when running on CPU with float precision.
1 parent 4d5a61b commit 916d3bc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/SofaCUDALinearSolver/CUDACholeksySparseSolver.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void CUDASparseCholeskySolver<TMatrix, TVector>::setWorkspace()
126126
}
127127
else
128128
{
129-
checksolver(cusolverSpScsrcholBufferInfoHost( handle, rows, nnz, descr, device_values, hRow, hCol,
129+
checksolver(cusolverSpScsrcholBufferInfoHost( handle, rows, nnz, descr, hValues, hRow, hCol,
130130
host_info, &size_internal, &size_work ));
131131
}
132132
}
@@ -434,7 +434,7 @@ void CUDASparseCholeskySolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vect
434434
// LL^t y = Pb
435435
sofa::helper::ScopedAdvancedTimer solveTimer("Solve");
436436

437-
solve_impl(n, x.ptr(), b.ptr());
437+
solve_impl(n, b.ptr(), x.ptr());
438438
checkCudaErrors(cudaStreamSynchronize(stream));
439439
}
440440

0 commit comments

Comments
 (0)