ElfPSP_AntColony
Protein Structure Prediction using Ant Colony Optimization
|
Encapsulates a pointer to a memory region within the GPU memory space. More...
Public Member Functions | |
CUDAPointer (size_t nElems) | |
Constructor that allocates memory within the GPU. More... | |
~CUDAPointer () | |
Frees memory allocated upon construction. More... | |
T * | get () |
Returns the raw pointer stored internally. More... | |
operator T* () | |
Enables casting a CUDAPointer to the associated raw pointer type T*. More... | |
operator void * () | |
Enables casting a CUDAPointer to void*. More... | |
void | memcpyAsync (const T *src) |
Asynchronously copy elements from host memory to GPU memory. More... | |
void | copyTo (T *dest, int nElems) |
Synchronously copy elements from GPU memory to host memory. More... | |
void | copyTo (T *dest) |
Overload of copyTo(T*, int) that copies the whole memory allocated upon construction to the host memory. More... | |
Private Attributes | |
T * | dPointer |
Pointer to the memory region. More... | |
size_t | dNElems |
Number of elements, of the templated type T, that fit in the allocated memory. More... | |
Encapsulates a pointer to a memory region within the GPU memory space.
This templated class provides utilities for easy allocation and deallocation of memory in the GPU. Memory is deallocated when the CUDAPointer object runs out of scope.
|
inline |
Constructor that allocates memory within the GPU.
nElems | Number of elements, of the templated type T, that should fit in the allocated memory. |
|
inline |
Frees memory allocated upon construction.
|
inline |
Synchronously copy elements from GPU memory to host memory.
dest | Pointer to memory in host memory to which we should copy elements from GPU memory. |
nElems | Number of elements to be copied. No checks regarding illegal memory access is done, so the user is responsible for that. |
|
inline |
Overload of copyTo(T*, int)
that copies the whole memory allocated upon construction to the host memory.
|
inline |
Returns the raw pointer stored internally.
|
inline |
Asynchronously copy elements from host memory to GPU memory.
src | Pointer to memory in host memory that holds the elements that should be copied. The pointer must have the same number of elements as allocated upon construction of the CUDAPointer object in question. |
|
inline |
Enables casting a CUDAPointer to the associated raw pointer type T*.
|
inline |
Enables casting a CUDAPointer to void*.
|
private |
Number of elements, of the templated type T, that fit in the allocated memory.
|
private |
Pointer to the memory region.