|
opm-simulators
|
The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern. More...
#include <CuSparseResource.hpp>
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. | |
| 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. | |
| CuSparseResource (const CuSparseResource &) | |
| CuSparseResource & | operator= (const CuSparseResource &)=delete |
| T | get () |
| get returns the raw pointer to the resource. | |
The CuSparseResource class wraps a CuSparse resource in a proper RAII pattern.
Current we support the following types for 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:
| Opm::gpuistl::detail::CuSparseResource< T >::CuSparseResource | ( | CreatorType | creator, |
| DeleterType | deleter ) |
CuSparseResource creates a new instance by calling creator, and will delete using deleter.
| creator | a functor used to create an instance |
| deleter | a functor used to delete the instance |