kernel_containers.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #if defined(__CUDACC__)
4  #define __kf_hdevice__ __host__ __device__ __forceinline__
5  #define __kf_device__ __device__ __forceinline__
6 #else
7  #define __kf_hdevice__
8  #define __kf_device__
9 #endif
10 
11 #include <cstddef>
12 
13 namespace kfusion
14 {
15  namespace cuda
16  {
17  template<typename T> struct DevPtr
18  {
19  typedef T elem_type;
20  const static size_t elem_size = sizeof(elem_type);
21 
22  T* data;
23 
25  __kf_hdevice__ DevPtr(T* data_arg) : data(data_arg) {}
26 
27  __kf_hdevice__ size_t elemSize() const { return elem_size; }
28  __kf_hdevice__ operator T*() { return data; }
29  __kf_hdevice__ operator const T*() const { return data; }
30  };
31 
32  template<typename T> struct PtrSz : public DevPtr<T>
33  {
35  __kf_hdevice__ PtrSz(T* data_arg, size_t size_arg) : DevPtr<T>(data_arg), size(size_arg) {}
36 
37  size_t size;
38  };
39 
40  template<typename T> struct PtrStep : public DevPtr<T>
41  {
43  __kf_hdevice__ PtrStep(T* data_arg, size_t step_arg) : DevPtr<T>(data_arg), step(step_arg) {}
44 
46  size_t step;
47 
48  __kf_hdevice__ T* ptr(int y = 0) { return ( T*)( ( char*)DevPtr<T>::data + y * step); }
49  __kf_hdevice__ const T* ptr(int y = 0) const { return (const T*)( (const char*)DevPtr<T>::data + y * step); }
50 
51  __kf_hdevice__ T& operator()(int y, int x) { return ptr(y)[x]; }
52  __kf_hdevice__ const T& operator()(int y, int x) const { return ptr(y)[x]; }
53  };
54 
55  template <typename T> struct PtrStepSz : public PtrStep<T>
56  {
58  __kf_hdevice__ PtrStepSz(int rows_arg, int cols_arg, T* data_arg, size_t step_arg)
59  : PtrStep<T>(data_arg, step_arg), cols(cols_arg), rows(rows_arg) {}
60 
61  int cols;
62  int rows;
63  };
64  }
65 
66  namespace device
67  {
71  }
72 }
73 
74 namespace kf = kfusion;
75 
kfusion::cuda::PtrSz::PtrSz
__kf_hdevice__ PtrSz(T *data_arg, size_t size_arg)
Definition: kernel_containers.hpp:35
kfusion::cuda::PtrStep::PtrStep
__kf_hdevice__ PtrStep()
Definition: kernel_containers.hpp:42
kfusion::cuda::PtrStep::ptr
const __kf_hdevice__ T * ptr(int y=0) const
Definition: kernel_containers.hpp:49
kfusion::cuda::PtrStep::operator()
const __kf_hdevice__ T & operator()(int y, int x) const
Definition: kernel_containers.hpp:52
kfusion::cuda::PtrSz::size
size_t size
Definition: kernel_containers.hpp:37
kfusion::cuda::PtrStep::operator()
__kf_hdevice__ T & operator()(int y, int x)
Definition: kernel_containers.hpp:51
kfusion::cuda::DevPtr::elemSize
__kf_hdevice__ size_t elemSize() const
Definition: kernel_containers.hpp:27
kfusion::cuda::PtrStep::step
size_t step
stride between two consecutive rows in bytes. Step is stored always and everywhere in bytes!...
Definition: kernel_containers.hpp:46
kfusion::cuda::DevPtr::elem_size
const static size_t elem_size
Definition: kernel_containers.hpp:20
kfusion::cuda::PtrStepSz::cols
int cols
Definition: kernel_containers.hpp:61
kfusion
Utility.
Definition: capture.hpp:8
kfusion::cuda::PtrSz
Definition: kernel_containers.hpp:32
kfusion::cuda::DevPtr::DevPtr
__kf_hdevice__ DevPtr()
Definition: kernel_containers.hpp:24
kfusion::cuda::PtrStepSz::PtrStepSz
__kf_hdevice__ PtrStepSz()
Definition: kernel_containers.hpp:57
kfusion::cuda::DevPtr::data
T * data
Definition: kernel_containers.hpp:22
kfusion::cuda::DevPtr
Definition: kernel_containers.hpp:17
kfusion::cuda::PtrStep::ptr
__kf_hdevice__ T * ptr(int y=0)
Definition: kernel_containers.hpp:48
kfusion::cuda::DevPtr::DevPtr
__kf_hdevice__ DevPtr(T *data_arg)
Definition: kernel_containers.hpp:25
kfusion::cuda::PtrStepSz::rows
int rows
Definition: kernel_containers.hpp:62
kfusion::cuda::PtrStepSz
Definition: kernel_containers.hpp:55
kfusion::cuda::PtrStep::PtrStep
__kf_hdevice__ PtrStep(T *data_arg, size_t step_arg)
Definition: kernel_containers.hpp:43
__kf_hdevice__
#define __kf_hdevice__
Definition: kernel_containers.hpp:7
kfusion::cuda::PtrSz::PtrSz
__kf_hdevice__ PtrSz()
Definition: kernel_containers.hpp:34
kfusion::cuda::PtrStepSz::PtrStepSz
__kf_hdevice__ PtrStepSz(int rows_arg, int cols_arg, T *data_arg, size_t step_arg)
Definition: kernel_containers.hpp:58
kfusion::cuda::DevPtr::elem_type
T elem_type
Definition: kernel_containers.hpp:19
kfusion::cuda::PtrStep
Definition: kernel_containers.hpp:40


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23