StatMech
Loading...
Searching...
No Matches
ObjectOnGPU_Base< T > Class Template Reference
Inheritance diagram for ObjectOnGPU_Base< T >:
Inheritance graph
Collaboration diagram for ObjectOnGPU_Base< T >:
Collaboration graph

Public Member Functions

template<class... Args>
 ObjectOnGPU_Base (Args... args)
 Default constructor for ObjectOnGPU_Base object.
 
 ObjectOnGPU_Base (ObjectOnGPU_Base const &other)=delete
 Default constructor.
 
 ObjectOnGPU_Base (ObjectOnGPU_Base &&other)
 Move constructor for ObjectOnGPU_Base object.
 
 ~ObjectOnGPU_Base ()
 Destructor.
 
Operator overloads
ObjectOnGPU_Baseoperator= (ObjectOnGPU_Base const &other)=delete
 Copy assignment operator (yet to be implmented)
 
ObjectOnGPU_Baseoperator= (ObjectOnGPU_Base &&other)
 Move assignment operator.
 
 operator Object_t * () const
 
Object_tptr () const
 
Object_t const * const_ptr () const
 

Static Public Attributes

static constexpr bool on_GPU = true
 

Protected Types

using Object_t = T
 

Protected Attributes

T * m_ptr = nullptr
 
T ** m_ptrptr = nullptr
 

Member Typedef Documentation

◆ Object_t

template<class T >
using ObjectOnGPU_Base< T >::Object_t = T
protected

Constructor & Destructor Documentation

◆ ObjectOnGPU_Base() [1/3]

template<class T >
template<class... Args>
ObjectOnGPU_Base< T >::ObjectOnGPU_Base ( Args...  args)
inline

Default constructor for ObjectOnGPU_Base object.

Template Parameters
Args
Parameters
args
56 {
57 debug_constructor_printf((Default));
58 cuCHECK(cudaMalloc((void***)&m_ptrptr, sizeof(Object_t*)));
59 // Only pass by value to the constructor is supported
60 constructObject_kernel<<<1, 1>>>(m_ptrptr, args...);
61 cuCHECK(cudaPeekAtLastError());
62 cuCHECK(cudaMemcpy(&m_ptr, m_ptrptr, sizeof(Object_t*), cudaMemcpyDeviceToHost));
63 debug_printf("\t &m_ptrptr=%p, m_ptrptr=%p, m_ptr=%p\n", &m_ptrptr, m_ptrptr, m_ptr);
64 }
T * m_ptr
Definition ObjectOnGPU.cuh:42
T ** m_ptrptr
Definition ObjectOnGPU.cuh:43
T Object_t
Definition ObjectOnGPU.cuh:44
cuCHECK(cudaFuncGetAttributes(&attr, MatrixElementsInSector))

◆ ObjectOnGPU_Base() [2/3]

template<class T >
ObjectOnGPU_Base< T >::ObjectOnGPU_Base ( ObjectOnGPU_Base< T > const &  other)
delete

Default constructor.

Causes the following error at the function construtSubSpaceFromTotalSpaceByMove
========= Invalid global read of size 8 bytes
========= at 0x1770 in void construtSubSpaceFromTotalSpaceByMove<ManyBodySpinSpace, Complex_t<float>>(SubSpace<T1, T2> *, T1 *)

Copy constructor for ObjectOnGPU_Base object (yet to be implmented)

Parameters
other

◆ ObjectOnGPU_Base() [3/3]

template<class T >
ObjectOnGPU_Base< T >::ObjectOnGPU_Base ( ObjectOnGPU_Base< T > &&  other)
inline

Move constructor for ObjectOnGPU_Base object.

Parameters
other
85 {
86 debug_constructor_printf((Move));
87 m_ptrptr = other.m_ptrptr;
88 m_ptr = other.m_ptr;
89
90 other.m_ptrptr = nullptr;
91 other.m_ptr = nullptr;
92 }

◆ ~ObjectOnGPU_Base()

template<class T >
ObjectOnGPU_Base< T >::~ObjectOnGPU_Base ( )
inline

Destructor.

97 {
98 debug_destructor_printf("");
99 debug_printf("\t&m_ptrptr=%p, m_ptrptr=%p, m_ptr=%p\n", &m_ptrptr, m_ptrptr, m_ptr);
100 if(m_ptrptr != nullptr) {
101 destructObject_kernel<<<1, 1>>>(m_ptrptr);
102 cuCHECK(cudaPeekAtLastError());
103 cuCHECK(cudaDeviceSynchronize());
104 }
105 cuCHECK(cudaFree(m_ptrptr));
106 m_ptrptr = nullptr;
107 }

Member Function Documentation

◆ const_ptr()

template<class T >
Object_t const * ObjectOnGPU_Base< T >::const_ptr ( ) const
inline
145{ return m_ptr; }

◆ operator Object_t *()

template<class T >
ObjectOnGPU_Base< T >::operator Object_t * ( ) const
inline
143{ return m_ptr; }

◆ operator=() [1/2]

template<class T >
ObjectOnGPU_Base & ObjectOnGPU_Base< T >::operator= ( ObjectOnGPU_Base< T > &&  other)
inline

Move assignment operator.

Parameters
other
Returns
ObjectOnGPU_Base&
123 {
124 debug_printf("%s:\n\tMove assignment operator.\n", __PRETTY_FUNCTION__);
125 if(this == &other) {
126 debug_printf("\tthis(%p) == &other(%p)\n", this, &other);
127 return *this;
128 }
129 if(m_ptrptr != nullptr) {
130 destructObject_kernel<<<1, 1>>>(m_ptrptr);
131 cuCHECK(cudaPeekAtLastError());
132 }
133 cuCHECK(cudaFree(m_ptrptr));
134 m_ptr = other.m_ptr;
135 m_ptrptr = other.m_ptrptr;
136
137 other.m_ptr = nullptr;
138 other.m_ptrptr = nullptr;
139 return *this;
140 }

◆ operator=() [2/2]

template<class T >
ObjectOnGPU_Base & ObjectOnGPU_Base< T >::operator= ( ObjectOnGPU_Base< T > const &  other)
delete

Copy assignment operator (yet to be implmented)

Parameters
other

◆ ptr()

template<class T >
Object_t * ObjectOnGPU_Base< T >::ptr ( ) const
inline
144{ return m_ptr; }

Member Data Documentation

◆ m_ptr

template<class T >
T* ObjectOnGPU_Base< T >::m_ptr = nullptr
protected

◆ m_ptrptr

template<class T >
T** ObjectOnGPU_Base< T >::m_ptrptr = nullptr
protected

◆ on_GPU

template<class T >
constexpr bool ObjectOnGPU_Base< T >::on_GPU = true
staticconstexpr

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