Opm::cuistl::detail::CuSparseResource< T > Class Template Reference

The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern. More...

#include <CuSparseResource.hpp>

Inheritance diagram for Opm::cuistl::detail::CuSparseResource< T >:
Inheritance graph

Public Types

using CreatorType = typename std::function< cusparseStatus_t(T *)>
 
using DeleterType = typename std::function< cusparseStatus_t(T)>
 

Public Member Functions

 CuSparseResource (CreatorType creator, DeleterType deleter)
 CuSparseResource creates a new instance by calling creator, and will delete using deleter. More...
 
 CuSparseResource ()
 CuSparseResource will automatically select the proper creator and deleter based on the type (and throw an exception if not available) More...
 
 ~CuSparseResource ()
 
 CuSparseResource (const CuSparseResource &)=delete
 
CuSparseResourceoperator= (const CuSparseResource &)=delete
 
get ()
 get returns the raw pointer to the resource. More...
 

Detailed Description

template<class T>
class Opm::cuistl::detail::CuSparseResource< T >

The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern.

Current we support the following types for T:

  • bsrilu02Info_t
  • bsrsv2Info_t
  • cusparseMatDescr_t

More types are in principle supported by supplying a manual Creator and Destructor.

In addition to acting as an easier-to-use smart_ptr specialized for these types, it also adds error checking in the construction and deletion of these resources, which a plain std::smart_ptr would not support out of the box. It also solves the caveat of the pointer types of cuSparse resources not being exposed properly.

Example usage:

#include <opm/simulator/linalg/cuistl/detail/CuSparseResource.hpp>
void someFunction() {
}
The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern.
Definition: CuSparseResource.hpp:55

Member Typedef Documentation

◆ CreatorType

template<class T >
using Opm::cuistl::detail::CuSparseResource< T >::CreatorType = typename std::function<cusparseStatus_t(T*)>

◆ DeleterType

template<class T >
using Opm::cuistl::detail::CuSparseResource< T >::DeleterType = typename std::function<cusparseStatus_t(T)>

Constructor & Destructor Documentation

◆ CuSparseResource() [1/3]

template<class T >
Opm::cuistl::detail::CuSparseResource< T >::CuSparseResource ( CreatorType  creator,
DeleterType  deleter 
)

CuSparseResource creates a new instance by calling creator, and will delete using deleter.

Parameters
creatora functor used to create an instance
deletera functor used to delete the instance
Note
Using this constructor it is possible to add support for new types not already accounted for.

References OPM_CUSPARSE_SAFE_CALL.

◆ CuSparseResource() [2/3]

template<class T >
Opm::cuistl::detail::CuSparseResource< T >::CuSparseResource

CuSparseResource will automatically select the proper creator and deleter based on the type (and throw an exception if not available)

◆ ~CuSparseResource()

Calls the deleter functor

References OPM_CUSPARSE_WARN_IF_ERROR.

◆ CuSparseResource() [3/3]

template<class T >
Opm::cuistl::detail::CuSparseResource< T >::CuSparseResource ( const CuSparseResource< T > &  )
delete

Member Function Documentation

◆ get()

template<class T >
T Opm::cuistl::detail::CuSparseResource< T >::get ( )
inline

get returns the raw pointer to the resource.

◆ operator=()

template<class T >
CuSparseResource & Opm::cuistl::detail::CuSparseResource< T >::operator= ( const CuSparseResource< T > &  )
delete

The documentation for this class was generated from the following files: