Go to the documentation of this file.
6 #ifndef OPENMPCD_CUDA_IMPLEMENTATIONDETAILS_DEVICEMEMORYMANAGER_HPP
7 #define OPENMPCD_CUDA_IMPLEMENTATIONDETAILS_DEVICEMEMORYMANAGER_HPP
12 #include <boost/scoped_array.hpp>
23 const T*
const src, T*
const dest,
const std::size_t count)
39 cudaMemcpy(dest, src,
sizeof(T) * count, cudaMemcpyHostToDevice);
45 const T*
const src, T*
const dest,
const std::size_t count)
61 cudaMemcpy(dest, src,
sizeof(T) * count, cudaMemcpyDeviceToHost);
67 const T*
const src, T*
const dest,
const std::size_t count)
83 cudaMemcpy(dest, src,
sizeof(T) * count, cudaMemcpyDeviceToDevice);
89 T*
const start,
const std::size_t numberOfElements)
99 cudaMemset(start, 0,
sizeof(T) * numberOfElements);
105 const T*
const host,
const T*
const device,
const std::size_t count)
107 #ifdef OPENMPCD_DEBUG
124 const std::size_t byteCount =
sizeof(T) * count;
126 boost::scoped_array<char> copyFromDevice(
new char[byteCount]);
127 cudaMemcpy(copyFromDevice.get(), device, byteCount, cudaMemcpyDeviceToHost);
130 return memcmp(host, copyFromDevice.get(), byteCount) == 0;
136 #endif //OPENMPCD_CUDA_IMPLEMENTATIONDETAILS_DEVICEMEMORYMANAGER_HPP
#define OPENMPCD_CUDA_THROW_ON_ERROR
Throws if the last CUDA call was not successful.
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
static bool isDeviceMemoryPointer(const void *const ptr)
Returns whether the given pointer is a pointer to CUDA Device memory.
static void copyElementsFromHostToDevice(const T *const src, T *const dest, const std::size_t count)
Copies count elements of type T from the Host to the Device.
static bool isHostMemoryPointer(const void *const ptr)
Returns whether the given pointer is a pointer to Host memory.
static void copyElementsFromDeviceToDevice(const T *const src, T *const dest, const std::size_t count)
Copies count elements of type T from the Device to the Device.
static void zeroMemory(T *const start, const std::size_t numberOfElements)
Writes zero-bytes to the given Device memory region.
static void copyElementsFromDeviceToHost(const T *const src, T *const dest, const std::size_t count)
Copies count elements of type T from the Device to the Host.
static bool elementMemoryEqualOnHostAndDevice(const T *const host, const T *const device, const std::size_t count)
Returns whether the count elements of type T at host in Host memory have the same byte-wise represent...
Invalid argument exception.