Loading...
Searching...
No Matches
CuSparseResource.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 CUSPARSERESOURCE_HPP
#define CUSPARSERESOURCE_HPP
#include <cusparse.h>
#include <functional>
#include <memory>
#include <type_traits>
namespace Opm::gpuistl::detail
{
template <class T>
class CuSparseResource
{
public:
using CreatorType = typename std::function<cusparseStatus_t(T*)>;
using DeleterType = typename std::function<cusparseStatus_t(T)>;
CuSparseResource(CreatorType creator, DeleterType deleter);
CuSparseResource();
~CuSparseResource();
CuSparseResource(const CuSparseResource&);
CuSparseResource& operator=(const CuSparseResource&) = delete;
T get()
{
return m_resource;
}
private:
T m_resource;
DeleterType m_deleter;
};
} // namespace Opm::gpuistl::impl
#include <opm/simulators/linalg/gpuistl/detail/CuSparseResource_impl.hpp>
#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