VTK-m
2.0
vtkm
cont
cuda
internal
ScopedCudaStackSize.h
Go to the documentation of this file.
1
//============================================================================
2
// Copyright (c) Kitware, Inc.
3
// All rights reserved.
4
// See LICENSE.txt for details.
5
//
6
// This software is distributed WITHOUT ANY WARRANTY; without even
7
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
// PURPOSE. See the above copyright notice for more information.
9
//============================================================================
10
#ifndef vtk_m_cont_cuda_internal_ScopedCudaStackSize_h
11
#define vtk_m_cont_cuda_internal_ScopedCudaStackSize_h
12
13
namespace
vtkm
14
{
15
namespace
cont
16
{
17
namespace
cuda
18
{
19
namespace
internal
20
{
21
24
struct
ScopedCudaStackSize
25
{
26
ScopedCudaStackSize(std::size_t newStackSize)
27
{
28
cudaDeviceGetLimit(&this->OldStackSize, cudaLimitStackSize);
29
VTKM_LOG_S
(
vtkm::cont::LogLevel::Info
,
30
"Temporarily changing Cuda stack size from "
31
<<
vtkm::cont::GetHumanReadableSize
(
static_cast<
vtkm::UInt64
>
(this->OldStackSize))
32
<<
" to "
33
<<
vtkm::cont::GetHumanReadableSize
(
static_cast<
vtkm::UInt64
>
(newStackSize)));
34
cudaDeviceSetLimit(cudaLimitStackSize, newStackSize);
35
}
36
37
~ScopedCudaStackSize()
38
{
39
VTKM_LOG_S
(
vtkm::cont::LogLevel::Info
,
40
"Restoring Cuda stack size to "
<<
vtkm::cont::GetHumanReadableSize
(
41
static_cast<
vtkm::UInt64
>
(this->OldStackSize)));
42
cudaDeviceSetLimit(cudaLimitStackSize, this->OldStackSize);
43
}
44
45
// Disable copy
46
ScopedCudaStackSize(
const
ScopedCudaStackSize&) =
delete
;
47
ScopedCudaStackSize& operator=(
const
ScopedCudaStackSize&) =
delete
;
48
49
private
:
50
std::size_t OldStackSize;
51
};
52
}
53
}
54
}
55
}
// vtkm::cont::cuda::internal
56
57
#endif // vtk_m_cont_cuda_internal_ScopedCudaStackSize_h
vtkm
Groups connected points that have the same field value.
Definition:
Atomic.h:19
vtkm::cont::LogLevel::Info
@ Info
Information messages (detected hardware, etc) and temporary debugging output.
vtkm::cont::GetHumanReadableSize
VTKM_CONT_EXPORT VTKM_CONT std::string GetHumanReadableSize(vtkm::UInt64 bytes, int prec=2)
Convert a size in bytes to a human readable string (e.g.
VTKM_LOG_S
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition:
Logging.h:261
Generated by
1.8.17