Loading...
Searching...
No Matches
CuMatrixDescription.hpp
/*
Copyright 2022-2023 SINTEF AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CU_MATRIX_DESCRIPTION_HPP
#define CU_MATRIX_DESCRIPTION_HPP
#include <opm/simulators/linalg/gpuistl/detail/CuSparseResource.hpp>
#include <opm/simulators/linalg/gpuistl/detail/cusparse_safe_call.hpp>
namespace Opm::gpuistl::detail
{
using GpuSparseMatrixDescription = CuSparseResource<cusparseMatDescr_t>;
using GpuSparseMatrixDescriptionPtr = std::shared_ptr<CuSparseResource<cusparseMatDescr_t>>;
inline GpuSparseMatrixDescriptionPtr
createMatrixDescription()
{
auto description = std::make_shared<GpuSparseMatrixDescription>();
// Note: We always want to use zero base indexing.
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatType(description->get(), CUSPARSE_MATRIX_TYPE_GENERAL));
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(description->get(), CUSPARSE_INDEX_BASE_ZERO));
return description;
}
inline GpuSparseMatrixDescriptionPtr
createLowerDiagonalDescription()
{
auto description = createMatrixDescription();
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatFillMode(description->get(), CUSPARSE_FILL_MODE_LOWER));
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(description->get(), CUSPARSE_DIAG_TYPE_UNIT));
return description;
}
inline GpuSparseMatrixDescriptionPtr
createUpperDiagonalDescription()
{
auto description = createMatrixDescription();
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatFillMode(description->get(), CUSPARSE_FILL_MODE_UPPER));
OPM_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(description->get(), CUSPARSE_DIAG_TYPE_NON_UNIT));
return description;
}
} // namespace Opm::gpuistl::detail
#endif // CU_MATRIX_DESCRIPTION_HPP
Opm::gpuistl::detail::CuSparseResource
The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern.
Definition CuSparseResource.hpp:55
Opm::gpuistl::detail
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition autotuner.hpp:30
Opm::gpuistl::detail::GpuSparseMatrixDescription
CuSparseResource< cusparseMatDescr_t > GpuSparseMatrixDescription
GpuSparseMatrixDescription holder.
Definition CuMatrixDescription.hpp:30
Opm::gpuistl::detail::createLowerDiagonalDescription
GpuSparseMatrixDescriptionPtr createLowerDiagonalDescription()
createLowerDiagonalDescription creates a lower diagonal matrix description
Definition CuMatrixDescription.hpp:60
Opm::gpuistl::detail::createUpperDiagonalDescription
GpuSparseMatrixDescriptionPtr createUpperDiagonalDescription()
createUpperDiagonalDescription creates an upper diagonal matrix description
Definition CuMatrixDescription.hpp:75
Opm::gpuistl::detail::createMatrixDescription
GpuSparseMatrixDescriptionPtr createMatrixDescription()
createMatrixDescription creates a default matrix description
Definition CuMatrixDescription.hpp:42
Opm::gpuistl::detail::GpuSparseMatrixDescriptionPtr
std::shared_ptr< CuSparseResource< cusparseMatDescr_t > > GpuSparseMatrixDescriptionPtr
Pointer to GpuSparseMatrixDescription holder.
Definition CuMatrixDescription.hpp:35