CuMatrixDescription.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022-2023 SINTEF AS
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef CU_MATRIX_DESCRIPTION_HPP
20#define CU_MATRIX_DESCRIPTION_HPP
23
24namespace Opm::cuistl::detail
25{
26
31
35using CuSparseMatrixDescriptionPtr = std::shared_ptr<CuSparseResource<cusparseMatDescr_t>>;
36
43{
44 auto description = std::make_shared<CuSparseMatrixDescription>();
45
46 // Note: We always want to use zero base indexing.
47 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatType(description->get(), CUSPARSE_MATRIX_TYPE_GENERAL));
48 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(description->get(), CUSPARSE_INDEX_BASE_ZERO));
49
50 return description;
51}
52
61{
62 auto description = createMatrixDescription();
63 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatFillMode(description->get(), CUSPARSE_FILL_MODE_LOWER));
64 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(description->get(), CUSPARSE_DIAG_TYPE_UNIT));
65 return description;
66}
67
76{
77 auto description = createMatrixDescription();
78 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatFillMode(description->get(), CUSPARSE_FILL_MODE_UPPER));
79 OPM_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(description->get(), CUSPARSE_DIAG_TYPE_NON_UNIT));
80
81 return description;
82}
83
84} // namespace Opm::cuistl::detail
85
86#endif // CU_MATRIX_DESCRIPTION_HPP
The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern.
Definition: CuSparseResource.hpp:55
#define OPM_CUSPARSE_SAFE_CALL(expression)
OPM_CUSPARSE_SAFE_CALL checks the return type of the cusparse expression (function call) and throws a...
Definition: cusparse_safe_call.hpp:185
Definition: cublas_safe_call.hpp:32
CuSparseMatrixDescriptionPtr createLowerDiagonalDescription()
createLowerDiagonalDescription creates a lower diagonal matrix description
Definition: CuMatrixDescription.hpp:60
std::shared_ptr< CuSparseResource< cusparseMatDescr_t > > CuSparseMatrixDescriptionPtr
Definition: CuMatrixDescription.hpp:35
CuSparseMatrixDescriptionPtr createMatrixDescription()
createMatrixDescription creates a default matrix description
Definition: CuMatrixDescription.hpp:42
CuSparseMatrixDescriptionPtr createUpperDiagonalDescription()
createUpperDiagonalDescription creates an upper diagonal matrix description
Definition: CuMatrixDescription.hpp:75