Fixed memory issues when cusparseSolver is disabled by unsupported blocksize

This commit is contained in:
T.D. (Tongdong) Qiu
2020-03-19 14:09:42 +01:00
parent 04fe46a9da
commit 947f419ef8
2 changed files with 28 additions and 25 deletions

View File

@@ -128,6 +128,7 @@ void BdaBridge::solve_system(BridgeMatrix *mat OPM_UNUSED, BridgeVector &b OPM_U
if (dim != 3) { if (dim != 3) {
OpmLog::warning("cusparseSolver only accepts blocksize = 3 at this time, will use Dune for the remainder of the program"); OpmLog::warning("cusparseSolver only accepts blocksize = 3 at this time, will use Dune for the remainder of the program");
use_gpu = false; use_gpu = false;
return;
} }
if (h_rows.capacity() == 0) { if (h_rows.capacity() == 0) {

View File

@@ -256,33 +256,35 @@ namespace Opm
} // end initialize() } // end initialize()
void cusparseSolverBackend::finalize() { void cusparseSolverBackend::finalize() {
cudaFree(d_x); if (initialized) {
cudaFree(d_b); cudaFree(d_x);
cudaFree(d_r); cudaFree(d_b);
cudaFree(d_rw); cudaFree(d_r);
cudaFree(d_p); cudaFree(d_rw);
cudaFree(d_pw); cudaFree(d_p);
cudaFree(d_s); cudaFree(d_pw);
cudaFree(d_t); cudaFree(d_s);
cudaFree(d_v); cudaFree(d_t);
cudaFree(d_mVals); cudaFree(d_v);
cudaFree(d_bVals); cudaFree(d_mVals);
cudaFree(d_bCols); cudaFree(d_bVals);
cudaFree(d_bRows); cudaFree(d_bCols);
cudaFree(d_buffer); cudaFree(d_bRows);
cusparseDestroyBsrilu02Info(info_M); cudaFree(d_buffer);
cusparseDestroyBsrsv2Info(info_L); cusparseDestroyBsrilu02Info(info_M);
cusparseDestroyBsrsv2Info(info_U); cusparseDestroyBsrsv2Info(info_L);
cusparseDestroyMatDescr(descr_B); cusparseDestroyBsrsv2Info(info_U);
cusparseDestroyMatDescr(descr_M); cusparseDestroyMatDescr(descr_B);
cusparseDestroyMatDescr(descr_L); cusparseDestroyMatDescr(descr_M);
cusparseDestroyMatDescr(descr_U); cusparseDestroyMatDescr(descr_L);
cusparseDestroy(cusparseHandle); cusparseDestroyMatDescr(descr_U);
cublasDestroy(cublasHandle); cusparseDestroy(cusparseHandle);
cublasDestroy(cublasHandle);
#if COPY_ROW_BY_ROW #if COPY_ROW_BY_ROW
cudaFreeHost(vals_contiguous); cudaFreeHost(vals_contiguous);
#endif #endif
cudaStreamDestroy(stream); cudaStreamDestroy(stream);
}
} // end finalize() } // end finalize()