mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 12:47:42 -06:00
use std::size_t
This commit is contained in:
1 parent
9078737780
commit
6ea5d6cc2b
3 files changed
+51
-50
No files matched your search
@@ -18,18 +18,19 @@
|
||||
*/
|
||||
#ifndef OPM_GPUSPARSEMATRIX_HPP
|
||||
#define OPM_GPUSPARSEMATRIX_HPP
|
||||
#include <cusparse.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixGeneric.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/CuMatrixDescription.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/CuSparseHandle.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/safe_conversion.hpp>
|
||||
#include <vector>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixGeneric.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cusparse.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Opm::gpuistl
|
||||
{
|
||||
@@ -87,9 +88,9 @@ public:
|
||||
GpuSparseMatrix(const T* nonZeroElements,
|
||||
const int* rowIndices,
|
||||
const int* columnIndices,
|
||||
size_t numberOfNonzeroBlocks,
|
||||
size_t blockSize,
|
||||
size_t numberOfRows);
|
||||
std::size_t numberOfNonzeroBlocks,
|
||||
std::size_t blockSize,
|
||||
std::size_t numberOfRows);
|
||||
|
||||
//! Create a sparse matrix by copying the sparsity structure of another matrix, not filling in the values
|
||||
//!
|
||||
@@ -103,7 +104,7 @@ public:
|
||||
//! restrictions in the current version of cusparse. This might change in future versions.
|
||||
GpuSparseMatrix(const GpuVector<int>& rowIndices,
|
||||
const GpuVector<int>& columnIndices,
|
||||
size_t blockSize);
|
||||
std::size_t blockSize);
|
||||
|
||||
GpuSparseMatrix(const GpuSparseMatrix&);
|
||||
|
||||
@@ -149,7 +150,7 @@ public:
|
||||
/**
|
||||
* @brief N returns the number of rows (which is equal to the number of columns)
|
||||
*/
|
||||
size_t N() const
|
||||
std::size_t N() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -163,7 +164,7 @@ public:
|
||||
* @brief nonzeroes behaves as the Dune::BCRSMatrix::nonzeros() function and returns the number of non zero blocks
|
||||
* @return number of non zero blocks.
|
||||
*/
|
||||
size_t nonzeroes() const
|
||||
std::size_t nonzeroes() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -257,7 +258,7 @@ public:
|
||||
* This is equivalent to matrix.N() * matrix.blockSize()
|
||||
* @return matrix.N() * matrix.blockSize()
|
||||
*/
|
||||
size_t dim() const
|
||||
std::size_t dim() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -270,7 +271,7 @@ public:
|
||||
/**
|
||||
* @brief blockSize size of the blocks
|
||||
*/
|
||||
size_t blockSize() const
|
||||
std::size_t blockSize() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -396,5 +397,7 @@ private:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Opm::gpuistl
|
||||
|
||||
#endif
|
||||
@@ -20,22 +20,19 @@
|
||||
#define OPM_GPUSPARSEMATRIXGENERIC_HPP
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuBuffer.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/CuSparseHandle.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/cusparse_safe_call.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/gpusparse_matrix_utilities.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/safe_conversion.hpp>
|
||||
|
||||
#include <cusparse.h>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuBuffer.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cusparse.h>
|
||||
|
||||
namespace Opm::gpuistl
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The GpuSparseMatrixGeneric class uses cuSPARSE Generic API for sparse matrix operations.
|
||||
*
|
||||
@@ -74,9 +71,9 @@ public:
|
||||
GpuSparseMatrixGeneric(const T* nonZeroElements,
|
||||
const int* rowIndices,
|
||||
const int* columnIndices,
|
||||
size_t numberOfNonzeroBlocks,
|
||||
size_t blockSize,
|
||||
size_t numberOfRows);
|
||||
std::size_t numberOfNonzeroBlocks,
|
||||
std::size_t blockSize,
|
||||
std::size_t numberOfRows);
|
||||
|
||||
//! Create a sparse matrix by copying the sparsity structure of another matrix, not filling in the values
|
||||
//!
|
||||
@@ -84,7 +81,7 @@ public:
|
||||
//! \param[in] columnIndices the column indices of the non-zero elements
|
||||
//! \param[in] blockSize size of each block matrix (typically 3)
|
||||
//!
|
||||
GpuSparseMatrixGeneric(const GpuVector<int>& rowIndices, const GpuVector<int>& columnIndices, size_t blockSize);
|
||||
GpuSparseMatrixGeneric(const GpuVector<int>& rowIndices, const GpuVector<int>& columnIndices, std::size_t blockSize);
|
||||
|
||||
GpuSparseMatrixGeneric(const GpuSparseMatrixGeneric&);
|
||||
|
||||
@@ -116,7 +113,7 @@ public:
|
||||
/**
|
||||
* @brief N returns the number of rows (which is equal to the number of columns)
|
||||
*/
|
||||
size_t N() const
|
||||
std::size_t N() const
|
||||
{
|
||||
return detail::to_size_t(m_numberOfRows);
|
||||
}
|
||||
@@ -125,7 +122,7 @@ public:
|
||||
* @brief nonzeroes behaves as the Dune::BCRSMatrix::nonzeros() function and returns the number of non zero blocks
|
||||
* @return number of non zero blocks.
|
||||
*/
|
||||
size_t nonzeroes() const
|
||||
std::size_t nonzeroes() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -201,7 +198,7 @@ public:
|
||||
* This is equivalent to matrix.N() * matrix.blockSize()
|
||||
* @return matrix.N() * matrix.blockSize()
|
||||
*/
|
||||
size_t dim() const
|
||||
std::size_t dim() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
@@ -214,7 +211,7 @@ public:
|
||||
/**
|
||||
* @brief blockSize size of the blocks
|
||||
*/
|
||||
size_t blockSize() const
|
||||
std::size_t blockSize() const
|
||||
{
|
||||
// Technically this safe conversion is not needed since we enforce these to be
|
||||
// non-negative in the constructor, but keeping them for added sanity for now.
|
||||
|
||||
@@ -18,19 +18,20 @@
|
||||
*/
|
||||
#ifndef OPM_GPUSPARSEMATRIXWRAPPER_HPP
|
||||
#define OPM_GPUSPARSEMATRIXWRAPPER_HPP
|
||||
#include <cusparse.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrix.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixGeneric.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/CuMatrixDescription.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/CuSparseHandle.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/detail/safe_conversion.hpp>
|
||||
#include <vector>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrix.hpp>
|
||||
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixGeneric.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cusparse.h>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Opm::gpuistl
|
||||
{
|
||||
@@ -57,7 +58,6 @@ namespace Opm::gpuistl
|
||||
*/
|
||||
template <typename T>
|
||||
class GpuSparseMatrixWrapper
|
||||
|
||||
{
|
||||
public:
|
||||
using field_type = T;
|
||||
@@ -114,9 +114,9 @@ public:
|
||||
GpuSparseMatrixWrapper(const T* nonZeroElements,
|
||||
const int* rowIndices,
|
||||
const int* columnIndices,
|
||||
size_t numberOfNonzeroBlocks,
|
||||
size_t blockSize,
|
||||
size_t numberOfRows)
|
||||
std::size_t numberOfNonzeroBlocks,
|
||||
std::size_t blockSize,
|
||||
std::size_t numberOfRows)
|
||||
{
|
||||
m_matrix = std::make_unique<matrix_type>(nonZeroElements,
|
||||
rowIndices,
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
//! restrictions in the current version of cusparse. This might change in future versions.
|
||||
GpuSparseMatrixWrapper(const GpuVector<int>& rowIndices,
|
||||
const GpuVector<int>& columnIndices,
|
||||
size_t blockSize)
|
||||
std::size_t blockSize)
|
||||
{
|
||||
m_matrix = std::make_unique<matrix_type>(rowIndices, columnIndices, blockSize);
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
/**
|
||||
* @brief N returns the number of rows (which is equal to the number of columns)
|
||||
*/
|
||||
size_t N() const
|
||||
std::size_t N() const
|
||||
{
|
||||
return m_matrix->N();
|
||||
}
|
||||
@@ -234,7 +234,7 @@ public:
|
||||
* @brief nonzeroes behaves as the Dune::BCRSMatrix::nonzeros() function and returns the number of non zero blocks
|
||||
* @return number of non zero blocks.
|
||||
*/
|
||||
size_t nonzeroes() const
|
||||
std::size_t nonzeroes() const
|
||||
{
|
||||
return m_matrix->nonzeroes();
|
||||
}
|
||||
@@ -305,7 +305,7 @@ public:
|
||||
* This is equivalent to matrix.N() * matrix.blockSize()
|
||||
* @return matrix.N() * matrix.blockSize()
|
||||
*/
|
||||
size_t dim() const
|
||||
std::size_t dim() const
|
||||
{
|
||||
return m_matrix->dim();
|
||||
}
|
||||
@@ -313,7 +313,7 @@ public:
|
||||
/**
|
||||
* @brief blockSize size of the blocks
|
||||
*/
|
||||
size_t blockSize() const
|
||||
std::size_t blockSize() const
|
||||
{
|
||||
return m_matrix->blockSize();
|
||||
}
|
||||
@@ -414,8 +414,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<matrix_type> m_matrix = nullptr;
|
||||
std::unique_ptr<matrix_type> m_matrix{};
|
||||
};
|
||||
|
||||
} // namespace Opm::gpuistl
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user