ext
kintinuous
kfusion
include
kfusion
cuda
device_memory.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
kfusion/exports.hpp
>
4
#include <
kfusion/cuda/kernel_containers.hpp
>
5
6
namespace
kfusion
7
{
8
namespace
cuda
9
{
11
KF_EXPORTS
void
error
(
const
char
*error_string,
const
char
*
file
,
const
int
line,
const
char
*func =
""
);
12
14
21
class
KF_EXPORTS
DeviceMemory
22
{
23
public
:
25
DeviceMemory
();
26
28
~
DeviceMemory
();
29
33
DeviceMemory
(
size_t
sizeBytes_arg);
34
39
DeviceMemory
(
void
*ptr_arg,
size_t
sizeBytes_arg);
40
42
DeviceMemory
(
const
DeviceMemory
& other_arg);
43
45
DeviceMemory
& operator=(
const
DeviceMemory
& other_arg);
46
50
void
create(
size_t
sizeBytes_arg);
51
53
void
release();
54
58
void
copyTo(
DeviceMemory
& other)
const
;
59
64
void
upload(
const
void
*host_ptr_arg,
size_t
sizeBytes_arg);
65
69
void
download(
void
*host_ptr_arg)
const
;
70
74
void
swap
(
DeviceMemory
& other_arg);
75
77
template
<
class
T> T* ptr();
78
80
template
<
class
T>
const
T* ptr()
const
;
81
83
template
<
class
U>
operator
PtrSz<U>
()
const
;
84
86
bool
empty()
const
;
87
88
size_t
sizeBytes()
const
;
89
90
private
:
92
void
*
data_
;
93
95
size_t
sizeBytes_
;
96
98
int
*
refcount_
;
99
};
100
102
109
class
KF_EXPORTS
DeviceMemory2D
110
{
111
public
:
113
DeviceMemory2D
();
114
116
~
DeviceMemory2D
();
117
122
DeviceMemory2D
(
int
rows_arg,
int
colsBytes_arg);
123
124
131
DeviceMemory2D
(
int
rows_arg,
int
colsBytes_arg,
void
*data_arg,
size_t
step_arg);
132
134
DeviceMemory2D
(
const
DeviceMemory2D
& other_arg);
135
137
DeviceMemory2D
& operator=(
const
DeviceMemory2D
& other_arg);
138
143
void
create(
int
rows_arg,
int
colsBytes_arg);
144
146
void
release();
147
151
void
copyTo(
DeviceMemory2D
& other)
const
;
152
159
void
upload(
const
void
*host_ptr_arg,
size_t
host_step_arg,
int
rows_arg,
int
colsBytes_arg);
160
165
void
download(
void
*host_ptr_arg,
size_t
host_step_arg)
const
;
166
170
void
swap
(
DeviceMemory2D
& other_arg);
171
175
template
<
class
T> T* ptr(
int
y_arg = 0);
176
180
template
<
class
T>
const
T* ptr(
int
y_arg = 0)
const
;
181
183
template
<
class
U>
operator
PtrStep<U>
()
const
;
184
186
template
<
class
U>
operator
PtrStepSz<U>
()
const
;
187
189
bool
empty()
const
;
190
192
int
colsBytes()
const
;
193
195
int
rows()
const
;
196
198
size_t
step
()
const
;
199
private
:
201
void
*
data_
;
202
204
size_t
step_
;
205
207
int
colsBytes_
;
208
210
int
rows_
;
211
213
int
*
refcount_
;
214
};
215
}
216
217
namespace
device
218
{
219
using
kfusion::cuda::DeviceMemory
;
220
using
kfusion::cuda::DeviceMemory2D
;
221
}
222
}
223
225
226
template
<
class
T>
inline
T*
kfusion::cuda::DeviceMemory::ptr
() {
return
( T*)
data_
; }
227
template
<
class
T>
inline
const
T*
kfusion::cuda::DeviceMemory::ptr
()
const
{
return
(
const
T*)data_; }
228
229
template
<
class
U>
inline
kfusion::cuda::DeviceMemory::operator
kfusion::cuda::PtrSz<U>
()
const
230
{
231
PtrSz<U>
result;
232
result.
data
= (U*)ptr<U>();
233
result.
size
= sizeBytes_/
sizeof
(U);
234
return
result;
235
}
236
238
239
template
<
class
T> T*
kfusion::cuda::DeviceMemory2D::ptr
(
int
y_arg) {
return
( T*)((
char
*)data_ + y_arg * step_); }
240
template
<
class
T>
const
T*
kfusion::cuda::DeviceMemory2D::ptr
(
int
y_arg)
const
{
return
(
const
T*)((
const
char
*)data_ + y_arg * step_); }
241
242
template
<
class
U> kfusion::cuda::DeviceMemory2D::operator
kfusion::cuda::PtrStep<U>
()
const
243
{
244
PtrStep<U>
result;
245
result.
data
= (U*)ptr<U>();
246
result.
step
= step_;
247
return
result;
248
}
249
250
template
<
class
U> kfusion::cuda::DeviceMemory2D::operator
kfusion::cuda::PtrStepSz<U>
()
const
251
{
252
PtrStepSz<U> result;
253
result.
data
= (U*)ptr<U>();
254
result.step = step_;
255
result.cols = colsBytes_/
sizeof
(U);
256
result.rows = rows_;
257
return
result;
258
}
kfusion::cuda::DeviceMemory2D::rows_
int rows_
Number of rows.
Definition:
device_memory.hpp:210
kfusion::cuda::DeviceMemory2D::step_
size_t step_
Stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywher...
Definition:
device_memory.hpp:204
exports.hpp
kfusion::cuda::DeviceMemory2D::colsBytes_
int colsBytes_
Width of the buffer in bytes.
Definition:
device_memory.hpp:207
kfusion::cuda::DeviceMemory2D::refcount_
int * refcount_
Pointer to reference counter in CPU memory.
Definition:
device_memory.hpp:213
kfusion::cuda::PtrSz::size
size_t size
Definition:
kernel_containers.hpp:37
kfusion::cuda::DeviceMemory2D::ptr
T * ptr(int y_arg=0)
Returns pointer to given row in internal buffer.
Definition:
device_memory.hpp:239
kfusion::cuda::DeviceMemory
DeviceMemory class
Definition:
device_memory.hpp:21
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::DeviceMemory2D::data_
void * data_
Device pointer.
Definition:
device_memory.hpp:201
kfusion
Utility.
Definition:
capture.hpp:8
kfusion::cuda::PtrSz
Definition:
kernel_containers.hpp:32
kfusion::cuda::DevPtr::data
T * data
Definition:
kernel_containers.hpp:22
kfusion::cuda::DeviceMemory2D
DeviceMemory2D class
Definition:
device_memory.hpp:109
kfusion::cuda::DeviceMemory::refcount_
int * refcount_
Pointer to reference counter in CPU memory.
Definition:
device_memory.hpp:98
file
FILE * file
Definition:
arithmeticencoder.cpp:77
kfusion::device::swap
__kf_hdevice__ void swap(T &a, T &b)
Definition:
temp_utils.hpp:10
kfusion::cuda::error
KF_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
Error handler. All GPU functions from this subsystem call the function to report an error....
Definition:
device_memory.cpp:7
kernel_containers.hpp
kfusion::cuda::DeviceMemory::ptr
T * ptr()
Returns pointer for internal buffer in GPU memory.
Definition:
device_memory.hpp:226
kfusion::cuda::PtrStepSz
Definition:
kernel_containers.hpp:55
kfusion::cuda::DeviceMemory::data_
void * data_
Device pointer.
Definition:
device_memory.hpp:92
kfusion::cuda::DeviceMemory::sizeBytes_
size_t sizeBytes_
Allocated size in bytes.
Definition:
device_memory.hpp:95
scripts.create_png.step
step
Definition:
create_png.py:42
KF_EXPORTS
#define KF_EXPORTS
Definition:
exports.hpp:6
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