Image Utilities (IU)
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Groups Pages
image_allocator_gpu.h
1 #pragma once
2 
3 #include <assert.h>
4 #include <cuda_runtime.h>
5 #include "../iucutil.h"
6 
7 #include "coredefs.h"
8 
9 namespace iuprivate {
10 
11 //--------------------------------------------------------------------------
12 template <typename PixelType>
14 {
15 public:
16  static PixelType* alloc(iu::Size<2> size, size_t *pitch)
17  {
18  if ((size.width == 0) || (size.height == 0)) throw IuException("width or height is 0", __FILE__, __FUNCTION__, __LINE__);
19  PixelType* buffer = 0;
20  IU_CUDA_SAFE_CALL(cudaMallocPitch((void **)&buffer, pitch,
21  size.width * sizeof(PixelType), size.height));
22  return buffer;
23  }
24 
25  static void free(PixelType *buffer)
26  {
27  IU_CUDA_SAFE_CALL(cudaFree((void *)buffer));
28  }
29 
30  static void copy(const PixelType *src, size_t src_pitch, PixelType *dst, size_t dst_pitch, iu::Size<2> size)
31  {
32  IU_CUDA_SAFE_CALL(cudaMemcpy2D(dst, dst_pitch, src, src_pitch,
33  size.width * sizeof(PixelType), size.height,
34  cudaMemcpyDeviceToDevice));
35  }
36 };
37 
38 } // namespace iuprivate
39 
Definition: image_allocator_gpu.h:13
unsigned int & height
Definition: vector.h:531
Exceptions with additional error information.
Definition: coredefs.h:32
unsigned int & width
Definition: vector.h:529
Template specialization for 2-d unsigned int vectors (size vectors).
Definition: vector.h:525