Commit c751d466 authored by incardon's avatar incardon

Modification for GPU

parent b96cc98b
......@@ -276,6 +276,25 @@ void CudaMemory::deviceToHost()
CUDA_SAFE_CALL(cudaMemcpy(hm,dm,sz,cudaMemcpyDeviceToHost));
}
/*! \brief Return a readable pointer with your data
*
* \return a readable pointer with your data
*
*/
void CudaMemory::deviceToHost(size_t start, size_t stop)
{
// allocate an host memory if not allocated
if (hm == NULL)
allocate_host(sz);
//! copy from device to host memory
CUDA_SAFE_CALL(cudaMemcpy(((unsigned char *)hm)+start,((unsigned char *)dm)+start,(stop-start),cudaMemcpyDeviceToHost));
}
/*! \brief Return a readable pointer with your data
*
* \return a readable pointer with your data
......@@ -302,7 +321,8 @@ const void * CudaMemory::getPointer() const
void CudaMemory::fill(unsigned char c)
{
CUDA_SAFE_CALL(cudaMemset(dm,c,size()));
memset(hm,c,size());
if (hm != NULL)
{memset(hm,c,size());}
}
/*! \brief Return the CUDA device pointer
......
......@@ -92,6 +92,9 @@ public:
//! Move memory from device to host
virtual void deviceToHost();
//! Move memory from device to host, just one chunk
virtual void deviceToHost(size_t start, size_t stop);
//! get the device pointer, but do not copy the memory from host to device
virtual void * getDevicePointerNoCopy();
......
......@@ -180,6 +180,9 @@ public:
//! Do nothing
virtual void deviceToHost(){};
//! Do nothing
virtual void deviceToHost(size_t start, size_t stop) {};
/*! \brief Return the pointer of the last allocation
*
* \return the pointer
......
......@@ -18,6 +18,7 @@ static const int extra_pad = 512;
#include "Memleak_check.hpp"
#endif
/*! \brief fill host and device memory with the selected byte
*
* \param byte to fill
......
......@@ -96,6 +96,9 @@ public:
//! Do nothing
virtual void deviceToHost(){};
//! Do nothing
virtual void deviceToHost(size_t start, size_t stop) {};
//! Increment the reference counter
virtual void incRef()
{ref_cnt++;}
......
......@@ -88,6 +88,9 @@ public:
//! Do nothing
virtual void deviceToHost(){};
//! Do nothing
virtual void deviceToHost(size_t start, size_t stop) {};
/*! \brief fill memory with the selected byte
*
*
......
......@@ -131,6 +131,14 @@ class memory
*/
virtual void deviceToHost() = 0;
/*! \brief Copy the memory from device to host
*
* \param start from start
* \param stop to stop
*
*/
virtual void deviceToHost(size_t start, size_t stop) = 0;
/*! \brief Get the device pointer (Do not copy from host to device)
*
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment