OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::gpu::cuda::device::unique_ptr< T > Class Template Reference

Managed pointer for device-side memory. More...

#include <device.h>

+ Inheritance diagram for olb::gpu::cuda::device::unique_ptr< T >:
+ Collaboration diagram for olb::gpu::cuda::device::unique_ptr< T >:

Public Member Functions

 unique_ptr ()
 
 unique_ptr (T *ptr)
 
 unique_ptr (unique_ptr &&rhs)
 
 ~unique_ptr ()
 
unique_ptroperator= (unique_ptr &&rhs)
 
void reset (T *ptr)
 
unique_ptroperator= (T *ptr)
 
T * release ()
 
const T * get () const
 
T * get ()
 

Detailed Description

template<typename T>
class olb::gpu::cuda::device::unique_ptr< T >

Managed pointer for device-side memory.

Definition at line 79 of file device.h.

Constructor & Destructor Documentation

◆ unique_ptr() [1/3]

template<typename T >
olb::gpu::cuda::device::unique_ptr< T >::unique_ptr ( )
inline

Definition at line 84 of file device.h.

84 :
85 _ptr{nullptr} { }

◆ unique_ptr() [2/3]

template<typename T >
olb::gpu::cuda::device::unique_ptr< T >::unique_ptr ( T * ptr)
inline

Definition at line 86 of file device.h.

86 :
87 _ptr{ptr} { }

◆ unique_ptr() [3/3]

template<typename T >
olb::gpu::cuda::device::unique_ptr< T >::unique_ptr ( unique_ptr< T > && rhs)
inline

Definition at line 88 of file device.h.

88 :
89 _ptr{rhs.release()} { }

◆ ~unique_ptr()

template<typename T >
olb::gpu::cuda::device::unique_ptr< T >::~unique_ptr ( )

Definition at line 108 of file device.hh.

108 {
109 if (_ptr != nullptr) {
110 cudaFree(_ptr);
111 check();
112 }
113}
void check()
Check errors.
Definition device.hh:48

References olb::gpu::cuda::device::check().

+ Here is the call graph for this function:

Member Function Documentation

◆ get() [1/2]

template<typename T >
T * olb::gpu::cuda::device::unique_ptr< T >::get ( )
inline

Definition at line 113 of file device.h.

113 {
114 return _ptr;
115 }

◆ get() [2/2]

template<typename T >
const T * olb::gpu::cuda::device::unique_ptr< T >::get ( ) const
inline

Definition at line 110 of file device.h.

110 {
111 return _ptr;
112 }
+ Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename T >
unique_ptr & olb::gpu::cuda::device::unique_ptr< T >::operator= ( T * ptr)
inline

Definition at line 99 of file device.h.

99 {
100 reset(ptr);
101 return *this;
102 }

References olb::gpu::cuda::device::unique_ptr< T >::reset().

+ Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T >
unique_ptr< T > & olb::gpu::cuda::device::unique_ptr< T >::operator= ( unique_ptr< T > && rhs)

Definition at line 116 of file device.hh.

116 {
117 if (_ptr != nullptr) {
118 cudaFree(_ptr);
119 check();
120 }
121 _ptr = rhs.release();
122 return *this;
123}

References olb::gpu::cuda::device::check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ release()

template<typename T >
T * olb::gpu::cuda::device::unique_ptr< T >::release ( )
inline

Definition at line 104 of file device.h.

104 {
105 T* ptr = _ptr;
106 _ptr = nullptr;
107 return ptr;
108 }

◆ reset()

template<typename T >
void olb::gpu::cuda::device::unique_ptr< T >::reset ( T * ptr)
inline

Definition at line 95 of file device.h.

95 {
96 operator=(unique_ptr<T>(ptr));
97 }
unique_ptr & operator=(unique_ptr &&rhs)
Definition device.hh:116

References olb::gpu::cuda::device::unique_ptr< T >::operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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