gtsam_points
Loading...
Searching...
No Matches
include
gtsam_points
cuda
stream_temp_buffer_roundrobin.hpp
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2021 Kenji Koide (k.koide@aist.go.jp)
3
4
#pragma once
5
6
#include <deque>
7
#include <memory>
8
#include <unordered_map>
9
10
#include <gtsam_points/cuda/stream_roundrobin.hpp>
11
12
namespace
gtsam_points {
13
19
class
TempBufferManager
{
20
public
:
21
struct
Buffer
{
22
Buffer
(
size_t
size);
23
~Buffer
();
24
25
Buffer
(
const
Buffer
&) =
delete
;
26
Buffer
& operator=(
const
Buffer
&) =
delete
;
27
28
size_t
size;
29
char
* buffer;
30
};
31
32
using
Ptr = std::shared_ptr<TempBufferManager>;
33
34
TempBufferManager
(
size_t
init_buffer_size = 0);
35
~TempBufferManager
();
36
37
char
* get_buffer(
size_t
buffer_size);
38
39
void
clear();
40
void
clear_all();
41
42
private
:
43
std::vector<std::shared_ptr<Buffer>> buffers;
44
};
45
49
class
StreamTempBufferRoundRobin
{
50
public
:
51
StreamTempBufferRoundRobin
(
int
num_streams = 4,
size_t
init_buffer_size = 512 * 1024);
52
~StreamTempBufferRoundRobin
();
53
54
std::pair<CUstream_st*, TempBufferManager::Ptr> get_stream_buffer();
55
56
void
sync_all();
57
58
void
clear();
59
void
clear_all();
60
61
private
:
62
size_t
init_buffer_size;
63
std::unique_ptr<StreamRoundRobin> stream_roundrobin;
64
std::unordered_map<CUstream_st*, TempBufferManager::Ptr> buffer_map;
65
};
66
67
}
// namespace gtsam_points
gtsam_points::StreamTempBufferRoundRobin
Roundrobin for pairs of CUDA stream and temporary buffer manager.
Definition
stream_temp_buffer_roundrobin.hpp:49
gtsam_points::TempBufferManager
Temporary buffer manager.
Definition
stream_temp_buffer_roundrobin.hpp:19
gtsam_points::TempBufferManager::Buffer
Definition
stream_temp_buffer_roundrobin.hpp:21
Generated by
1.9.8