4 #include <cuda_runtime.h>
6 #include "../iucutil.h"
11 template <
typename PixelType>
15 static PixelType* alloc(
iu::Size<3> size,
size_t *pitch)
18 throw IuException(
"width, height or depth is 0", __FILE__,__FUNCTION__, __LINE__);
19 PixelType* buffer = 0;
20 cudaError_t status = cudaMallocPitch((
void **)&buffer, pitch, size.
width *
sizeof(PixelType), size.
height*size.
depth);
21 if (buffer == 0)
throw std::bad_alloc();
22 if (status != cudaSuccess)
23 throw IuException(
"cudaMallocPitch returned error code", __FILE__, __FUNCTION__, __LINE__);
28 static void free(PixelType *buffer)
30 IU_CUDA_SAFE_CALL(cudaFree((
void *)buffer));
33 static void copy(
const PixelType *src,
size_t src_pitch, PixelType *dst,
size_t dst_pitch,
iu::Size<3> size)
35 IU_CUDA_SAFE_CALL(cudaMemcpy2D(dst, dst_pitch, src, src_pitch,
37 cudaMemcpyDeviceToDevice));
unsigned int & depth
Definition: vector.h:613
unsigned int & height
Definition: vector.h:611
Exceptions with additional error information.
Definition: coredefs.h:32
Template specialization for 3-d unsigned int vectors (size vectors).
Definition: vector.h:605
unsigned int & width
Definition: vector.h:609
Definition: volume_allocator_gpu.h:12