ReUseX
0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
device.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <cuda_runtime.h>
3
4
namespace
ReUseX::vision::tensor_rt
{
5
class
AutoDevice
{
6
public
:
7
explicit
AutoDevice
(
int
device_id) {
8
cudaGetDevice(&prev_device_);
9
if
(prev_device_ != device_id) {
10
cudaSetDevice(device_id);
11
switched_ =
true
;
12
}
13
}
14
15
~AutoDevice
() {
16
if
(switched_) {
17
cudaSetDevice(prev_device_);
18
}
19
}
20
21
// Copy and assignment are prohibited
22
AutoDevice
(
const
AutoDevice
&) =
delete
;
23
AutoDevice
&
operator=
(
const
AutoDevice
&) =
delete
;
24
25
private
:
26
int
prev_device_ = 0;
27
bool
switched_ =
false
;
28
};
29
}
// namespace ReUseX::vision::tensor_rt
ReUseX::vision::tensor_rt::AutoDevice::AutoDevice
AutoDevice(const AutoDevice &)=delete
ReUseX::vision::tensor_rt::AutoDevice::AutoDevice
AutoDevice(int device_id)
Definition
device.hpp:7
ReUseX::vision::tensor_rt::AutoDevice::~AutoDevice
~AutoDevice()
Definition
device.hpp:15
ReUseX::vision::tensor_rt::AutoDevice::operator=
AutoDevice & operator=(const AutoDevice &)=delete
ReUseX::vision::tensor_rt
Definition
Backend.hpp:6
libs
reusex
include
ReUseX
vision
tensor_rt
common
device.hpp
Generated by
1.16.1