use unique_ptr consistently for delayed instantiation

This commit is contained in:
Tobias Meyer Andersen committed 2024-06-26 15:31:52 +02:00
1 parent 82ff782d5f
commit d6f8678617
2 files changed
+8 -10

No files matched your search

+6 -9
View File
@@ -78,7 +78,7 @@ createReorderedMatrix(const M& naturalMatrix,
} }
} }
reorderedGpuMat.reset(new auto(Opm::cuistl::CuSparseMatrix<field_type>::fromMatrix(reorderedMatrix, true))); reorderedGpuMat.reset(new auto (GPUM::fromMatrix(reorderedMatrix, true)));
} }
template <class M, class field_type, class GPUM> template <class M, class field_type, class GPUM>
@@ -108,8 +108,8 @@ extractLowerAndUpperMatrices(const M& naturalMatrix,
} }
} }
lower.reset(new auto(Opm::cuistl::CuSparseMatrix<field_type>::fromMatrix(reorderedLower, true))); lower.reset(new auto (GPUM::fromMatrix(reorderedLower, true)));
upper.reset(new auto(Opm::cuistl::CuSparseMatrix<field_type>::fromMatrix(reorderedUpper, true))); upper.reset(new auto (GPUM::fromMatrix(reorderedUpper, true)));
return; return;
} }
@@ -125,9 +125,6 @@ CuDILU<M, X, Y, l>::CuDILU(const M& A, bool split_matrix)
, m_reorderedToNatural(createReorderedToNatural(m_levelSets)) , m_reorderedToNatural(createReorderedToNatural(m_levelSets))
, m_naturalToReordered(createNaturalToReordered(m_levelSets)) , m_naturalToReordered(createNaturalToReordered(m_levelSets))
, m_gpuMatrix(CuSparseMatrix<field_type>::fromMatrix(m_cpuMatrix, true)) , m_gpuMatrix(CuSparseMatrix<field_type>::fromMatrix(m_cpuMatrix, true))
, m_gpuMatrixReordered(nullptr)
, m_gpuMatrixReorderedLower(nullptr)
, m_gpuMatrixReorderedUpper(nullptr)
, m_gpuNaturalToReorder(m_naturalToReordered) , m_gpuNaturalToReorder(m_naturalToReordered)
, m_gpuReorderToNatural(m_reorderedToNatural) , m_gpuReorderToNatural(m_reorderedToNatural)
, m_gpuDInv(m_gpuMatrix.N() * m_gpuMatrix.blockSize() * m_gpuMatrix.blockSize()) , m_gpuDInv(m_gpuMatrix.N() * m_gpuMatrix.blockSize() * m_gpuMatrix.blockSize())
@@ -151,7 +148,7 @@ CuDILU<M, X, Y, l>::CuDILU(const M& A, bool split_matrix)
m_gpuMatrix.nonzeroes(), m_gpuMatrix.nonzeroes(),
A.nonzeroes())); A.nonzeroes()));
if (m_split_matrix) { if (m_split_matrix) {
m_gpuMatrixReorderedDiag.emplace(CuVector<field_type>(blocksize_ * blocksize_ * m_cpuMatrix.N())); m_gpuMatrixReorderedDiag.reset(new auto(CuVector<field_type>(blocksize_ * blocksize_ * m_cpuMatrix.N())));
extractLowerAndUpperMatrices<M, field_type, CuSparseMatrix<field_type>>( extractLowerAndUpperMatrices<M, field_type, CuSparseMatrix<field_type>>(
m_cpuMatrix, m_reorderedToNatural, m_gpuMatrixReorderedLower, m_gpuMatrixReorderedUpper); m_cpuMatrix, m_reorderedToNatural, m_gpuMatrixReorderedLower, m_gpuMatrixReorderedUpper);
} else { } else {
@@ -272,7 +269,7 @@ CuDILU<M, X, Y, l>::computeDiagAndMoveReorderedData()
m_gpuMatrixReorderedLower->getRowIndices().data(), m_gpuMatrixReorderedLower->getRowIndices().data(),
m_gpuMatrixReorderedUpper->getNonZeroValues().data(), m_gpuMatrixReorderedUpper->getNonZeroValues().data(),
m_gpuMatrixReorderedUpper->getRowIndices().data(), m_gpuMatrixReorderedUpper->getRowIndices().data(),
m_gpuMatrixReorderedDiag.value().data(), m_gpuMatrixReorderedDiag->data(),
m_gpuNaturalToReorder.data(), m_gpuNaturalToReorder.data(),
m_gpuMatrixReorderedLower->N()); m_gpuMatrixReorderedLower->N());
} else { } else {
@@ -295,7 +292,7 @@ CuDILU<M, X, Y, l>::computeDiagAndMoveReorderedData()
m_gpuMatrixReorderedUpper->getNonZeroValues().data(), m_gpuMatrixReorderedUpper->getNonZeroValues().data(),
m_gpuMatrixReorderedUpper->getRowIndices().data(), m_gpuMatrixReorderedUpper->getRowIndices().data(),
m_gpuMatrixReorderedUpper->getColumnIndices().data(), m_gpuMatrixReorderedUpper->getColumnIndices().data(),
m_gpuMatrixReorderedDiag.value().data(), m_gpuMatrixReorderedDiag->data(),
m_gpuReorderToNatural.data(), m_gpuReorderToNatural.data(),
m_gpuNaturalToReorder.data(), m_gpuNaturalToReorder.data(),
levelStartIdx, levelStartIdx,
+2 -1
View File
@@ -115,12 +115,13 @@ private:
std::vector<int> m_naturalToReordered; std::vector<int> m_naturalToReordered;
//! \brief The A matrix stored on the gpu, and its reordred version //! \brief The A matrix stored on the gpu, and its reordred version
CuMat m_gpuMatrix; CuMat m_gpuMatrix;
//! \brief Stores the matrix in its entirety reordered. Optional in case splitting is used
std::unique_ptr<CuMat> m_gpuMatrixReordered; std::unique_ptr<CuMat> m_gpuMatrixReordered;
//! \brief If matrix splitting is enabled, then we store the lower and upper part separately //! \brief If matrix splitting is enabled, then we store the lower and upper part separately
std::unique_ptr<CuMat> m_gpuMatrixReorderedLower; std::unique_ptr<CuMat> m_gpuMatrixReorderedLower;
std::unique_ptr<CuMat> m_gpuMatrixReorderedUpper; std::unique_ptr<CuMat> m_gpuMatrixReorderedUpper;
//! \brief If matrix splitting is enabled, we also store the diagonal separately //! \brief If matrix splitting is enabled, we also store the diagonal separately
std::optional<CuVector<field_type>> m_gpuMatrixReorderedDiag; std::unique_ptr<CuVector<field_type>> m_gpuMatrixReorderedDiag;
//! row conversion from natural to reordered matrix indices stored on the GPU //! row conversion from natural to reordered matrix indices stored on the GPU
CuVector<int> m_gpuNaturalToReorder; CuVector<int> m_gpuNaturalToReorder;
//! row conversion from reordered to natural matrix indices stored on the GPU //! row conversion from reordered to natural matrix indices stored on the GPU