opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
CuSparseResource.hpp
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 CUSPARSERESOURCE_HPP
20
#define CUSPARSERESOURCE_HPP
21
#include <cusparse.h>
22
#include <functional>
23
#include <memory>
24
#include <type_traits>
25
26
namespace
Opm::gpuistl::detail
27
{
28
53
template
<
class
T>
54
class
CuSparseResource
55
{
56
public
:
57
using
CreatorType =
typename
std::function<cusparseStatus_t(T*)>;
58
using
DeleterType =
typename
std::function<cusparseStatus_t(T)>;
59
67
CuSparseResource
(CreatorType creator, DeleterType deleter);
68
72
CuSparseResource
();
73
77
~CuSparseResource
();
78
79
CuSparseResource
(
const
CuSparseResource
&);
80
81
CuSparseResource
& operator=(
const
CuSparseResource
&) =
delete
;
82
86
T
get
()
87
{
88
return
m_resource;
89
}
90
91
private
:
92
T m_resource;
93
94
DeleterType m_deleter;
95
};
96
97
}
// namespace Opm::gpuistl::impl
98
#include <opm/simulators/linalg/gpuistl/detail/CuSparseResource_impl.hpp>
99
#endif
// CUSPARSERESOURCE_HPP
Opm::gpuistl::detail::CuSparseResource::get
T get()
get returns the raw pointer to the resource.
Definition
CuSparseResource.hpp:86
Opm::gpuistl::detail::CuSparseResource::CuSparseResource
CuSparseResource(CreatorType creator, DeleterType deleter)
CuSparseResource creates a new instance by calling creator, and will delete using deleter.
Definition
CuSparseResource_impl.hpp:82
Opm::gpuistl::detail::CuSparseResource::CuSparseResource
CuSparseResource()
CuSparseResource will automatically select the proper creator and deleter based on the type (and thro...
Definition
CuSparseResource_impl.hpp:91
Opm::gpuistl::detail::CuSparseResource::~CuSparseResource
~CuSparseResource()
Calls the deleter functor.
Definition
CuSparseResource_impl.hpp:104
Opm::gpuistl::detail
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition
autotuner.hpp:30
opm
simulators
linalg
gpuistl
detail
CuSparseResource.hpp
Generated by
1.17.0