23 #ifndef __CUDA_MAPPED_MEMORY_H_
24 #define __CUDA_MAPPED_MEMORY_H_
46 if( !cpuPtr || !gpuPtr || size == 0 )
51 if(
CUDA_FAILED(cudaHostAlloc(cpuPtr, size, cudaHostAllocMapped)) )
54 if(
CUDA_FAILED(cudaHostGetDevicePointer(gpuPtr, *cpuPtr, 0)) )
57 memset(*cpuPtr, 0, size);
58 LogDebug(
LOG_CUDA "cudaAllocMapped %zu bytes, CPU %p GPU %p\n", size, *cpuPtr, *gpuPtr);
80 if( !ptr || size == 0 )
86 if( cpuPtr != gpuPtr )
88 LogError(
LOG_CUDA "cudaAllocMapped() - addresses of CPU and GPU pointers don't match\n");
151 template<
typename T>
inline bool cudaAllocMapped( T** ptr,
size_t width,
size_t height )